Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion docgen/content-sources/HOME.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# Firebase Functions SDK Reference

Functions SDK!!!
The `firebase-functions` package provides an SDK for defining Cloud Functions for Firebase.

To get started using Cloud Functions, see
[Get started: write, test, and deploy your first functions](/docs/functions/get-started).

For source code, see the [Cloud Functions for Firebase GitHub repo](https://github.com/firebase/firebase-functions).
2 changes: 2 additions & 0 deletions docgen/content-sources/toc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ toc:
section:
- title: 'HttpsError'
path: /docs/reference/functions/providers_https_.httpserror.html
- title: 'CallableContext'
path: /docs/reference/functions/providers_https_.callablecontext.html

- title: 'functions.pubsub'
path: /docs/reference/functions/providers_pubsub_.html
Expand Down
14 changes: 12 additions & 2 deletions src/providers/https.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import { apps } from '../apps';
import { HttpsFunction, optionsToTrigger, Runnable } from '../cloud-functions';
import { DeploymentOptions } from '../function-configuration';

/** @hidden */
export interface Request extends express.Request {
rawBody: Buffer;
}
Expand Down Expand Up @@ -127,6 +128,7 @@ export type FunctionsErrorCode =
| 'data-loss'
| 'unauthenticated';

/** @hidden */
export type CanonicalErrorCodeName =
| 'OK'
| 'CANCELLED'
Expand All @@ -146,6 +148,7 @@ export type CanonicalErrorCodeName =
| 'UNAVAILABLE'
| 'DATA_LOSS';

/** @hidden */
interface HttpErrorCode {
canonicalName: CanonicalErrorCodeName;
status: number;
Expand Down Expand Up @@ -180,6 +183,7 @@ const errorCodeMap: { [name in FunctionsErrorCode]: HttpErrorCode } = {
'data-loss': { canonicalName: 'DATA_LOSS', status: 500 },
};

/** @hidden */
interface HttpErrorWireFormat {
details?: unknown;
message: string;
Expand Down Expand Up @@ -261,19 +265,22 @@ export interface CallableContext {
rawRequest: Request;
}

// The allowed interface for an http request for a callable function.
// The allowed interface for an HTTP request to a Callable function.
/** @hidden*/
interface HttpRequest extends Request {
body: {
data: any;
};
}

// The format for the http body response to a callable function.
/** @hidden */
// The format for an HTTP body response from a Callable function.
interface HttpResponseBody {
result?: any;
error?: HttpsError;
}

/** @hidden */
// Returns true if req is a properly formatted callable request.
function isValidRequest(req: Request): req is HttpRequest {
// The body must not be empty.
Expand Down Expand Up @@ -317,7 +324,9 @@ function isValidRequest(req: Request): req is HttpRequest {
return true;
}

/** @hidden */
const LONG_TYPE = 'type.googleapis.com/google.protobuf.Int64Value';
/** @hidden */
const UNSIGNED_LONG_TYPE = 'type.googleapis.com/google.protobuf.UInt64Value';

/**
Expand Down Expand Up @@ -400,6 +409,7 @@ export function decode(data: any): any {
return data;
}

/** @hidden */
const corsHandler = cors({ origin: true, methods: 'POST' });

/** @hidden */
Expand Down
1 change: 1 addition & 0 deletions src/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

/** @hidden */
import { firebaseConfig } from './config';

// Set up for config and vars
Expand Down
2 changes: 1 addition & 1 deletion src/utilities/assertions.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**
/** @hidden
* @file Provides common assertion helpers which can be used to improve
* strictness of both type checking and runtime.
*/
Expand Down
2 changes: 1 addition & 1 deletion src/utilities/path.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**
/** @hidden
* Removes leading and trailing slashes from a path.
*
* @param path A path to normalize, in POSIX format.
Expand Down
1 change: 1 addition & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

/** @hidden */
import * as _ from 'lodash';

export function applyChange(src: any, dest: any) {
Expand Down