@flowerforce/flowerbase 1.0.1-beta.4 → 1.0.1-beta.6
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/dist/constants.d.ts +2 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +3 -1
- package/dist/features/triggers/index.d.ts.map +1 -1
- package/dist/features/triggers/index.js +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -2
- package/dist/utils/initializer/exposeRoutes.js +2 -2
- package/package.json +4 -5
- package/src/constants.ts +3 -1
- package/src/features/triggers/index.ts +2 -0
- package/src/index.ts +7 -2
- package/src/utils/initializer/exposeRoutes.ts +3 -3
package/dist/constants.d.ts
CHANGED
package/dist/constants.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,cAAc
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,cAAc;;;;;;;;CAQ1B,CAAA;AACD,eAAO,MAAM,WAAW,QAA8C,CAAA;AACtE,eAAO,MAAM,YAAY,QAA8B,CAAA;AACvD,eAAO,MAAM,OAAO,QAAgB,CAAA;AACpC,eAAO,MAAM,WAAW;;;;;;CAMvB,CAAA"}
|
package/dist/constants.js
CHANGED
|
@@ -20,7 +20,9 @@ exports.DEFAULT_CONFIG = {
|
|
|
20
20
|
MONGODB_URL: process.env.MONGODB_URL || '',
|
|
21
21
|
JWT_SECRET: process.env.JWT_SECRET || '',
|
|
22
22
|
API_VERSION: process.env.API_VERSION || "v2.0",
|
|
23
|
-
HTTPS_SCHEMA: process.env.HTTPS_SCHEMA || 'https'
|
|
23
|
+
HTTPS_SCHEMA: process.env.HTTPS_SCHEMA || 'https',
|
|
24
|
+
HOST: process.env.HOST || '0.0.0.0',
|
|
25
|
+
ENABLE_LOGGER: process.env.ENABLE_LOGGER
|
|
24
26
|
};
|
|
25
27
|
exports.API_VERSION = `/api/client/${exports.DEFAULT_CONFIG.API_VERSION}`;
|
|
26
28
|
exports.HTTPS_SCHEMA = exports.DEFAULT_CONFIG.HTTPS_SCHEMA;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/features/triggers/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,sBAAsB,EAAE,MAAM,QAAQ,CAAA;AAG/C;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,GAAU,0CAIpC,sBAAsB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/features/triggers/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,sBAAsB,EAAE,MAAM,QAAQ,CAAA;AAG/C;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,GAAU,0CAIpC,sBAAsB,kBAiBxB,CAAA"}
|
|
@@ -29,6 +29,7 @@ const utils_1 = require("./utils");
|
|
|
29
29
|
const activateTriggers = (_a) => __awaiter(void 0, [_a], void 0, function* ({ fastify, triggersList, functionsList }) {
|
|
30
30
|
var _b, triggersList_1, triggersList_1_1;
|
|
31
31
|
var _c, e_1, _d, _e;
|
|
32
|
+
console.log("START ACTIVATION TRIGGERS");
|
|
32
33
|
try {
|
|
33
34
|
try {
|
|
34
35
|
for (_b = true, triggersList_1 = __asyncValues(triggersList); triggersList_1_1 = yield triggersList_1.next(), _c = triggersList_1_1.done, !_c; _b = true) {
|
|
@@ -49,6 +50,7 @@ const activateTriggers = (_a) => __awaiter(void 0, [_a], void 0, function* ({ fa
|
|
|
49
50
|
}
|
|
50
51
|
finally { if (e_1) throw e_1.error; }
|
|
51
52
|
}
|
|
53
|
+
console.log("TRIGGERS ACTIVATION COMPLETED");
|
|
52
54
|
}
|
|
53
55
|
catch (e) {
|
|
54
56
|
console.error('Error while activating triggers', e.message);
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,eAAe,CAAA;AActB,cAAc,SAAS,CAAC;AAExB,MAAM,MAAM,gBAAgB,GAAG;IAC7B,SAAS,EAAE,MAAM,CAAA;IACjB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;CACd,CAAA;AAED;;;;;;;GAOG;AACH,wBAAsB,UAAU,CAAC,EAC/B,SAAS,EACT,IAAI,EACJ,SAAqC,EACrC,IAA0B,EAC1B,UAAuC,EACxC,EAAE,gBAAgB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,eAAe,CAAA;AActB,cAAc,SAAS,CAAC;AAExB,MAAM,MAAM,gBAAgB,GAAG;IAC7B,SAAS,EAAE,MAAM,CAAA;IACjB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;CACd,CAAA;AAED;;;;;;;GAOG;AACH,wBAAsB,UAAU,CAAC,EAC/B,SAAS,EACT,IAAI,EACJ,SAAqC,EACrC,IAA0B,EAC1B,UAAuC,EACxC,EAAE,gBAAgB,iBAgDlB"}
|
package/dist/index.js
CHANGED
|
@@ -53,8 +53,10 @@ __exportStar(require("./model"), exports);
|
|
|
53
53
|
function initialize(_a) {
|
|
54
54
|
return __awaiter(this, arguments, void 0, function* ({ projectId, host, jwtSecret = constants_1.DEFAULT_CONFIG.JWT_SECRET, port = constants_1.DEFAULT_CONFIG.PORT, mongodbUrl = constants_1.DEFAULT_CONFIG.MONGODB_URL }) {
|
|
55
55
|
const fastify = (0, fastify_1.default)({
|
|
56
|
-
logger:
|
|
56
|
+
logger: !!constants_1.DEFAULT_CONFIG.ENABLE_LOGGER
|
|
57
57
|
});
|
|
58
|
+
console.log("CURRENT PORT", port);
|
|
59
|
+
console.log("CURRENT HOST", host);
|
|
58
60
|
const functionsList = yield (0, utils_2.loadFunctions)();
|
|
59
61
|
console.log("Functions LOADED");
|
|
60
62
|
const triggersList = yield (0, utils_4.loadTriggers)();
|
|
@@ -85,7 +87,10 @@ function initialize(_a) {
|
|
|
85
87
|
console.log("Functions registration COMPLETED");
|
|
86
88
|
yield (0, endpoints_1.generateEndpoints)({ app: fastify, functionsList, endpointsList });
|
|
87
89
|
console.log("HTTP Endpoints registration COMPLETED");
|
|
88
|
-
fastify.ready(() =>
|
|
90
|
+
fastify.ready(() => {
|
|
91
|
+
console.log("FASTIFY IS READY");
|
|
92
|
+
(triggersList === null || triggersList === void 0 ? void 0 : triggersList.length) > 0 && (0, triggers_1.activateTriggers)({ fastify, triggersList, functionsList });
|
|
93
|
+
});
|
|
89
94
|
yield fastify.listen({ port, host });
|
|
90
95
|
fastify.log.info(`[${projectId}] Server listening on port ${port}`);
|
|
91
96
|
});
|
|
@@ -23,8 +23,8 @@ const exposeRoutes = (fastify) => __awaiter(void 0, void 0, void 0, function* ()
|
|
|
23
23
|
return ({
|
|
24
24
|
deployment_model: 'LOCAL',
|
|
25
25
|
location: 'IE',
|
|
26
|
-
hostname:
|
|
27
|
-
ws_hostname:
|
|
26
|
+
hostname: `${constants_1.DEFAULT_CONFIG.HTTPS_SCHEMA}://${req.headers.host}`,
|
|
27
|
+
ws_hostname: `${constants_1.DEFAULT_CONFIG.HTTPS_SCHEMA === "https" ? "wss" : "ws"}://${req.headers.host}`
|
|
28
28
|
});
|
|
29
29
|
}));
|
|
30
30
|
fastify.get('/health', () => __awaiter(void 0, void 0, void 0, function* () {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flowerforce/flowerbase",
|
|
3
|
-
"version": "1.0.1-beta.
|
|
3
|
+
"version": "1.0.1-beta.6",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"scripts": {
|
|
11
11
|
"test": "npx jest",
|
|
12
12
|
"build": "rm -rf dist/ && tsc",
|
|
13
|
-
"start": "node src/index.ts"
|
|
13
|
+
"start": "node dist/src/index.ts"
|
|
14
14
|
},
|
|
15
15
|
"keywords": [],
|
|
16
16
|
"author": "",
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
"@fastify/cors": "^10.0.1",
|
|
20
20
|
"@fastify/jwt": "^9.0.1",
|
|
21
21
|
"@fastify/mongodb": "^9.0.1",
|
|
22
|
+
"@sendgrid/mail": "^8.1.4",
|
|
22
23
|
"aws-sdk": "^2.1692.0",
|
|
23
24
|
"bson": "^6.8.0",
|
|
24
25
|
"dotenv": "^16.4.7",
|
|
@@ -27,7 +28,6 @@
|
|
|
27
28
|
"fastify-plugin": "^5.0.1",
|
|
28
29
|
"lodash": "^4.17.21",
|
|
29
30
|
"node-cron": "^3.0.3",
|
|
30
|
-
"@sendgrid/mail": "^8.1.4",
|
|
31
31
|
"nodemon": "^3.1.7",
|
|
32
32
|
"undici": "^7.1.0"
|
|
33
33
|
},
|
|
@@ -58,6 +58,5 @@
|
|
|
58
58
|
"ts-node": "^10.9.2",
|
|
59
59
|
"typescript": "^5.6.2",
|
|
60
60
|
"typescript-eslint": "^8.8.1"
|
|
61
|
-
}
|
|
62
|
-
"peerDependencies": {}
|
|
61
|
+
}
|
|
63
62
|
}
|
package/src/constants.ts
CHANGED
|
@@ -8,7 +8,9 @@ export const DEFAULT_CONFIG = {
|
|
|
8
8
|
MONGODB_URL: process.env.MONGODB_URL || '',
|
|
9
9
|
JWT_SECRET: process.env.JWT_SECRET || '',
|
|
10
10
|
API_VERSION: process.env.API_VERSION || "v2.0",
|
|
11
|
-
HTTPS_SCHEMA: process.env.HTTPS_SCHEMA || 'https'
|
|
11
|
+
HTTPS_SCHEMA: process.env.HTTPS_SCHEMA || 'https',
|
|
12
|
+
HOST: process.env.HOST || '0.0.0.0',
|
|
13
|
+
ENABLE_LOGGER: process.env.ENABLE_LOGGER
|
|
12
14
|
}
|
|
13
15
|
export const API_VERSION = `/api/client/${DEFAULT_CONFIG.API_VERSION}`
|
|
14
16
|
export const HTTPS_SCHEMA = DEFAULT_CONFIG.HTTPS_SCHEMA
|
|
@@ -15,6 +15,7 @@ export const activateTriggers = async ({
|
|
|
15
15
|
triggersList,
|
|
16
16
|
functionsList
|
|
17
17
|
}: ActivateTriggersParams) => {
|
|
18
|
+
console.log("START ACTIVATION TRIGGERS")
|
|
18
19
|
try {
|
|
19
20
|
for await (const trigger of triggersList) {
|
|
20
21
|
const { content } = trigger
|
|
@@ -26,6 +27,7 @@ export const activateTriggers = async ({
|
|
|
26
27
|
await TRIGGER_HANDLERS[type]({ config, triggerHandler, app: fastify, services, functionsList })
|
|
27
28
|
|
|
28
29
|
}
|
|
30
|
+
console.log("TRIGGERS ACTIVATION COMPLETED")
|
|
29
31
|
} catch (e) {
|
|
30
32
|
console.error('Error while activating triggers', (e as Error).message)
|
|
31
33
|
}
|
package/src/index.ts
CHANGED
|
@@ -38,9 +38,11 @@ export async function initialize({
|
|
|
38
38
|
mongodbUrl = DEFAULT_CONFIG.MONGODB_URL
|
|
39
39
|
}: InitializeConfig) {
|
|
40
40
|
const fastify = Fastify({
|
|
41
|
-
logger:
|
|
41
|
+
logger: !!DEFAULT_CONFIG.ENABLE_LOGGER
|
|
42
42
|
})
|
|
43
43
|
|
|
44
|
+
console.log("CURRENT PORT", port)
|
|
45
|
+
console.log("CURRENT HOST", host)
|
|
44
46
|
|
|
45
47
|
const functionsList = await loadFunctions()
|
|
46
48
|
console.log("Functions LOADED")
|
|
@@ -75,7 +77,10 @@ export async function initialize({
|
|
|
75
77
|
console.log("Functions registration COMPLETED")
|
|
76
78
|
await generateEndpoints({ app: fastify, functionsList, endpointsList })
|
|
77
79
|
console.log("HTTP Endpoints registration COMPLETED")
|
|
78
|
-
fastify.ready(() =>
|
|
80
|
+
fastify.ready(() => {
|
|
81
|
+
console.log("FASTIFY IS READY")
|
|
82
|
+
triggersList?.length > 0 && activateTriggers({ fastify, triggersList, functionsList })
|
|
83
|
+
})
|
|
79
84
|
await fastify.listen({ port, host })
|
|
80
85
|
|
|
81
86
|
fastify.log.info(`[${projectId}] Server listening on port ${port}`)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { uptime } from 'node:process'
|
|
2
2
|
import { FastifyInstance } from 'fastify'
|
|
3
|
-
import { API_VERSION } from '../../constants'
|
|
3
|
+
import { API_VERSION, DEFAULT_CONFIG } from '../../constants'
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* > Used to expose all app routes
|
|
@@ -12,8 +12,8 @@ export const exposeRoutes = async (fastify: FastifyInstance) => {
|
|
|
12
12
|
fastify.get(`${API_VERSION}/app/:appId/location`, async (req) => ({
|
|
13
13
|
deployment_model: 'LOCAL',
|
|
14
14
|
location: 'IE',
|
|
15
|
-
hostname:
|
|
16
|
-
ws_hostname:
|
|
15
|
+
hostname: `${DEFAULT_CONFIG.HTTPS_SCHEMA}://${req.headers.host}`,
|
|
16
|
+
ws_hostname: `${DEFAULT_CONFIG.HTTPS_SCHEMA === "https" ? "wss" : "ws"}://${req.headers.host}`
|
|
17
17
|
}))
|
|
18
18
|
|
|
19
19
|
fastify.get('/health', async () => ({
|