@aldel/test-func-kit 0.0.0-stage → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +33 -0
- package/README.md +2 -2
- package/aldel-test-func-kit-0.0.1.tgz +0 -0
- package/lib/index.d.ts +9 -0
- package/lib/index.js +44 -0
- package/package.json +35 -4
- package/src/index.ts +49 -0
- package/tsconfig.dev.json +9 -0
- package/tsconfig.json +20 -0
package/.eslintrc.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
root: true,
|
|
3
|
+
env: {
|
|
4
|
+
es6: true,
|
|
5
|
+
node: true,
|
|
6
|
+
},
|
|
7
|
+
extends: [
|
|
8
|
+
"eslint:recommended",
|
|
9
|
+
"plugin:import/errors",
|
|
10
|
+
"plugin:import/warnings",
|
|
11
|
+
"plugin:import/typescript",
|
|
12
|
+
"google",
|
|
13
|
+
"plugin:@typescript-eslint/recommended",
|
|
14
|
+
],
|
|
15
|
+
parser: "@typescript-eslint/parser",
|
|
16
|
+
parserOptions: {
|
|
17
|
+
project: ["tsconfig.json", "tsconfig.dev.json"],
|
|
18
|
+
sourceType: "module",
|
|
19
|
+
},
|
|
20
|
+
ignorePatterns: [
|
|
21
|
+
"/lib/**/*", // Ignore built files.
|
|
22
|
+
"/generated/**/*", // Ignore generated files.
|
|
23
|
+
],
|
|
24
|
+
plugins: [
|
|
25
|
+
"@typescript-eslint",
|
|
26
|
+
"import",
|
|
27
|
+
],
|
|
28
|
+
rules: {
|
|
29
|
+
"quotes": ["error", "double"],
|
|
30
|
+
"import/no-unresolved": 0,
|
|
31
|
+
"indent": ["error", 2],
|
|
32
|
+
},
|
|
33
|
+
};
|
package/README.md
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
#
|
|
1
|
+
# test-func-kit
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A minimal, experimental Firebase Function Kit.
|
|
Binary file
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Import function triggers from their respective submodules:
|
|
3
|
+
*
|
|
4
|
+
* import {onCall} from "firebase-functions/v2/https";
|
|
5
|
+
* import {onDocumentWritten} from "firebase-functions/v2/firestore";
|
|
6
|
+
*
|
|
7
|
+
* See a full list of supported triggers at https://firebase.google.com/docs/functions
|
|
8
|
+
*/
|
|
9
|
+
export declare const helloWorld: import("firebase-functions/https").HttpsFunction;
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Import function triggers from their respective submodules:
|
|
4
|
+
*
|
|
5
|
+
* import {onCall} from "firebase-functions/v2/https";
|
|
6
|
+
* import {onDocumentWritten} from "firebase-functions/v2/firestore";
|
|
7
|
+
*
|
|
8
|
+
* See a full list of supported triggers at https://firebase.google.com/docs/functions
|
|
9
|
+
*/
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.helloWorld = void 0;
|
|
12
|
+
const firebase_functions_1 = require("firebase-functions");
|
|
13
|
+
const https_1 = require("firebase-functions/https");
|
|
14
|
+
const params_1 = require("firebase-functions/params");
|
|
15
|
+
// import * as logger from "firebase-functions/logger";
|
|
16
|
+
const message = (0, params_1.defineString)('MESSAGE', {
|
|
17
|
+
label: 'Message sent by the helloWorld function',
|
|
18
|
+
description: 'The message to be sent by the helloWorld function. Must begin with "Hello".',
|
|
19
|
+
default: 'Hello, World!',
|
|
20
|
+
input: {
|
|
21
|
+
text: {
|
|
22
|
+
validationRegex: /^Hello\b/i,
|
|
23
|
+
validationErrorMessage: 'Must begin with "Hello"',
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
// Start writing functions
|
|
28
|
+
// https://firebase.google.com/docs/functions/typescript
|
|
29
|
+
// For cost control, you can set the maximum number of containers that can be
|
|
30
|
+
// running at the same time. This helps mitigate the impact of unexpected
|
|
31
|
+
// traffic spikes by instead downgrading performance. This limit is a
|
|
32
|
+
// per-function limit. You can override the limit for each function using the
|
|
33
|
+
// `maxInstances` option in the function's options, e.g.
|
|
34
|
+
// `onRequest({ maxInstances: 5 }, (req, res) => { ... })`.
|
|
35
|
+
// NOTE: setGlobalOptions does not apply to functions using the v1 API. V1
|
|
36
|
+
// functions should each use functions.runWith({ maxInstances: 10 }) instead.
|
|
37
|
+
// In the v1 API, each function can only serve one request per container, so
|
|
38
|
+
// this will be the maximum concurrent request count.
|
|
39
|
+
(0, firebase_functions_1.setGlobalOptions)({ maxInstances: 10 });
|
|
40
|
+
exports.helloWorld = (0, https_1.onRequest)((request, response) => {
|
|
41
|
+
console.log("Hello logs!", { structuredData: true });
|
|
42
|
+
response.send(message.value());
|
|
43
|
+
});
|
|
44
|
+
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,37 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aldel/test-func-kit",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"description": "A minimal, experimental function kit for Firebase.",
|
|
4
|
+
"version": "0.0.2",
|
|
5
|
+
"publishConfig": {
|
|
6
|
+
"access": "public"
|
|
7
|
+
},
|
|
8
|
+
"scripts": {
|
|
9
|
+
"lint": "eslint --ext .js,.ts .",
|
|
10
|
+
"build": "tsc",
|
|
11
|
+
"build:watch": "tsc --watch",
|
|
12
|
+
"serve": "npm run build && firebase emulators:start --only functions",
|
|
13
|
+
"shell": "npm run build && firebase functions:shell",
|
|
14
|
+
"start": "npm run shell",
|
|
15
|
+
"deploy": "firebase deploy --only functions",
|
|
16
|
+
"logs": "firebase functions:log",
|
|
17
|
+
"prepack": "npm run build"
|
|
18
|
+
},
|
|
19
|
+
"engines": {
|
|
20
|
+
"node": "24"
|
|
21
|
+
},
|
|
22
|
+
"main": "lib/index.js",
|
|
23
|
+
"types": "lib/index.d.ts",
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"firebase-admin": "^13.6.0",
|
|
26
|
+
"firebase-functions": "^7.0.0"
|
|
27
|
+
},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"@typescript-eslint/eslint-plugin": "^8.0.0",
|
|
30
|
+
"@typescript-eslint/parser": "^8.0.0",
|
|
31
|
+
"eslint": "^8.57.0",
|
|
32
|
+
"eslint-config-google": "^0.14.0",
|
|
33
|
+
"eslint-plugin-import": "^2.25.4",
|
|
34
|
+
"firebase-functions-test": "^3.4.1",
|
|
35
|
+
"typescript": "^6.0.0"
|
|
36
|
+
}
|
|
37
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Import function triggers from their respective submodules:
|
|
3
|
+
*
|
|
4
|
+
* import {onCall} from "firebase-functions/v2/https";
|
|
5
|
+
* import {onDocumentWritten} from "firebase-functions/v2/firestore";
|
|
6
|
+
*
|
|
7
|
+
* See a full list of supported triggers at https://firebase.google.com/docs/functions
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import {setGlobalOptions} from "firebase-functions";
|
|
11
|
+
import {onRequest} from "firebase-functions/https";
|
|
12
|
+
import { defineString } from 'firebase-functions/params';
|
|
13
|
+
// import * as logger from "firebase-functions/logger";
|
|
14
|
+
|
|
15
|
+
const message = defineString(
|
|
16
|
+
'MESSAGE',
|
|
17
|
+
{
|
|
18
|
+
label: 'Message sent by the helloWorld function',
|
|
19
|
+
description: 'The message to be sent by the helloWorld function. Must begin with "Hello".',
|
|
20
|
+
default: 'Hello, World!',
|
|
21
|
+
input: {
|
|
22
|
+
text: {
|
|
23
|
+
validationRegex: /^Hello\b/i,
|
|
24
|
+
validationErrorMessage: 'Must begin with "Hello"',
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
// Start writing functions
|
|
32
|
+
// https://firebase.google.com/docs/functions/typescript
|
|
33
|
+
|
|
34
|
+
// For cost control, you can set the maximum number of containers that can be
|
|
35
|
+
// running at the same time. This helps mitigate the impact of unexpected
|
|
36
|
+
// traffic spikes by instead downgrading performance. This limit is a
|
|
37
|
+
// per-function limit. You can override the limit for each function using the
|
|
38
|
+
// `maxInstances` option in the function's options, e.g.
|
|
39
|
+
// `onRequest({ maxInstances: 5 }, (req, res) => { ... })`.
|
|
40
|
+
// NOTE: setGlobalOptions does not apply to functions using the v1 API. V1
|
|
41
|
+
// functions should each use functions.runWith({ maxInstances: 10 }) instead.
|
|
42
|
+
// In the v1 API, each function can only serve one request per container, so
|
|
43
|
+
// this will be the maximum concurrent request count.
|
|
44
|
+
setGlobalOptions({maxInstances: 10});
|
|
45
|
+
|
|
46
|
+
export const helloWorld = onRequest((request, response) => {
|
|
47
|
+
console.log("Hello logs!", {structuredData: true});
|
|
48
|
+
response.send(message.value());
|
|
49
|
+
});
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"module": "NodeNext",
|
|
4
|
+
"declaration": true,
|
|
5
|
+
"esModuleInterop": true,
|
|
6
|
+
"moduleResolution": "nodenext",
|
|
7
|
+
"noImplicitReturns": true,
|
|
8
|
+
"noUnusedLocals": true,
|
|
9
|
+
"outDir": "lib",
|
|
10
|
+
"rootDir": "src",
|
|
11
|
+
"sourceMap": true,
|
|
12
|
+
"strict": true,
|
|
13
|
+
"target": "es2017",
|
|
14
|
+
"skipLibCheck": true
|
|
15
|
+
},
|
|
16
|
+
"compileOnSave": true,
|
|
17
|
+
"include": [
|
|
18
|
+
"src"
|
|
19
|
+
]
|
|
20
|
+
}
|