@flowerforce/flowerbase 1.8.4-beta.6 → 1.8.4-beta.7
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/index.d.ts +12 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -4
- package/package.json +1 -1
- package/src/index.ts +19 -2
package/dist/index.d.ts
CHANGED
|
@@ -6,6 +6,16 @@ export type CorsConfig = {
|
|
|
6
6
|
origin: string;
|
|
7
7
|
methods: ALLOWED_METHODS[];
|
|
8
8
|
};
|
|
9
|
+
export type FastifyTimeoutConfig = {
|
|
10
|
+
/** Milliseconds to wait for a new connection (default: 0 = disabled) */
|
|
11
|
+
connectionTimeout?: number;
|
|
12
|
+
/** Milliseconds to keep idle keep-alive connections open (default: 72000) */
|
|
13
|
+
keepAliveTimeout?: number;
|
|
14
|
+
/** Milliseconds to wait for an incoming request body (default: 0 = disabled) */
|
|
15
|
+
requestTimeout?: number;
|
|
16
|
+
/** Milliseconds to wait for a plugin to load (default: 10000) */
|
|
17
|
+
pluginTimeout?: number;
|
|
18
|
+
};
|
|
9
19
|
export type InitializeConfig = {
|
|
10
20
|
projectId: string;
|
|
11
21
|
mongodbUrl?: string;
|
|
@@ -15,6 +25,7 @@ export type InitializeConfig = {
|
|
|
15
25
|
corsConfig?: CorsConfig;
|
|
16
26
|
basePath?: string;
|
|
17
27
|
mongodbEncryptionConfig?: MongoDbEncryptionConfig;
|
|
28
|
+
timeoutConfig?: FastifyTimeoutConfig;
|
|
18
29
|
};
|
|
19
30
|
/**
|
|
20
31
|
* > Used to initialize fastify app
|
|
@@ -24,5 +35,5 @@ export type InitializeConfig = {
|
|
|
24
35
|
* @param port -> the serve port number
|
|
25
36
|
* @param mongodbUrl -> the database connection string
|
|
26
37
|
*/
|
|
27
|
-
export declare function initialize({ projectId, host, jwtSecret, port, mongodbUrl, corsConfig, basePath, mongodbEncryptionConfig }: InitializeConfig): Promise<void>;
|
|
38
|
+
export declare function initialize({ projectId, host, jwtSecret, port, mongodbUrl, corsConfig, basePath, mongodbEncryptionConfig, timeoutConfig }: InitializeConfig): Promise<void>;
|
|
28
39
|
//# sourceMappingURL=index.d.ts.map
|
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;AAetB,OAAO,EAAE,KAAK,uBAAuB,EAAE,MAAM,kCAAkC,CAAA;AAC/E,cAAc,SAAS,CAAA;AAGvB,MAAM,MAAM,eAAe,GAAG,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,QAAQ,CAAA;AAE/D,MAAM,MAAM,UAAU,GAAG;IACvB,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,EAAE,eAAe,EAAE,CAAA;CAC3B,CAAA;AAED,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;IACb,UAAU,CAAC,EAAE,UAAU,CAAA;IACvB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,uBAAuB,CAAC,EAAE,uBAAuB,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,eAAe,CAAA;AAetB,OAAO,EAAE,KAAK,uBAAuB,EAAE,MAAM,kCAAkC,CAAA;AAC/E,cAAc,SAAS,CAAA;AAGvB,MAAM,MAAM,eAAe,GAAG,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,QAAQ,CAAA;AAE/D,MAAM,MAAM,UAAU,GAAG;IACvB,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,EAAE,eAAe,EAAE,CAAA;CAC3B,CAAA;AAED,MAAM,MAAM,oBAAoB,GAAG;IACjC,wEAAwE;IACxE,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,6EAA6E;IAC7E,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,gFAAgF;IAChF,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,iEAAiE;IACjE,aAAa,CAAC,EAAE,MAAM,CAAA;CACvB,CAAA;AAED,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;IACb,UAAU,CAAC,EAAE,UAAU,CAAA;IACvB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,uBAAuB,CAAC,EAAE,uBAAuB,CAAA;IACjD,aAAa,CAAC,EAAE,oBAAoB,CAAA;CACrC,CAAA;AAED;;;;;;;GAOG;AACH,wBAAsB,UAAU,CAAC,EAC/B,SAAS,EACT,IAA0B,EAC1B,SAAqC,EACrC,IAA0B,EAC1B,UAAuC,EACvC,UAAwC,EACxC,QAAQ,EACR,uBAAuB,EACvB,aAAa,EACd,EAAE,gBAAgB,iBAiIlB"}
|
package/dist/index.js
CHANGED
|
@@ -74,15 +74,13 @@ __exportStar(require("./model"), exports);
|
|
|
74
74
|
* @param mongodbUrl -> the database connection string
|
|
75
75
|
*/
|
|
76
76
|
function initialize(_a) {
|
|
77
|
-
return __awaiter(this, arguments, void 0, function* ({ projectId, host = constants_1.DEFAULT_CONFIG.HOST, jwtSecret = constants_1.DEFAULT_CONFIG.JWT_SECRET, port = constants_1.DEFAULT_CONFIG.PORT, mongodbUrl = constants_1.DEFAULT_CONFIG.MONGODB_URL, corsConfig = constants_1.DEFAULT_CONFIG.CORS_OPTIONS, basePath, mongodbEncryptionConfig }) {
|
|
77
|
+
return __awaiter(this, arguments, void 0, function* ({ projectId, host = constants_1.DEFAULT_CONFIG.HOST, jwtSecret = constants_1.DEFAULT_CONFIG.JWT_SECRET, port = constants_1.DEFAULT_CONFIG.PORT, mongodbUrl = constants_1.DEFAULT_CONFIG.MONGODB_URL, corsConfig = constants_1.DEFAULT_CONFIG.CORS_OPTIONS, basePath, mongodbEncryptionConfig, timeoutConfig }) {
|
|
78
78
|
var _b, _c;
|
|
79
79
|
if (!jwtSecret || jwtSecret.trim().length === 0) {
|
|
80
80
|
throw new Error('JWT secret missing: set JWT_SECRET or pass jwtSecret to initialize()');
|
|
81
81
|
}
|
|
82
82
|
const resolvedBasePath = (_c = basePath !== null && basePath !== void 0 ? basePath : (_b = require.main) === null || _b === void 0 ? void 0 : _b.path) !== null && _c !== void 0 ? _c : process.cwd();
|
|
83
|
-
const fastify = (0, fastify_1.default)({
|
|
84
|
-
logger: !!constants_1.DEFAULT_CONFIG.ENABLE_LOGGER
|
|
85
|
-
});
|
|
83
|
+
const fastify = (0, fastify_1.default)(Object.assign(Object.assign(Object.assign(Object.assign({ logger: !!constants_1.DEFAULT_CONFIG.ENABLE_LOGGER }, ((timeoutConfig === null || timeoutConfig === void 0 ? void 0 : timeoutConfig.connectionTimeout) !== undefined && { connectionTimeout: timeoutConfig.connectionTimeout })), ((timeoutConfig === null || timeoutConfig === void 0 ? void 0 : timeoutConfig.keepAliveTimeout) !== undefined && { keepAliveTimeout: timeoutConfig.keepAliveTimeout })), ((timeoutConfig === null || timeoutConfig === void 0 ? void 0 : timeoutConfig.requestTimeout) !== undefined && { requestTimeout: timeoutConfig.requestTimeout })), ((timeoutConfig === null || timeoutConfig === void 0 ? void 0 : timeoutConfig.pluginTimeout) !== undefined && { pluginTimeout: timeoutConfig.pluginTimeout })));
|
|
86
84
|
const isTest = process.env.NODE_ENV === 'test' || process.env.JEST_WORKER_ID !== undefined;
|
|
87
85
|
const logInfo = (...args) => {
|
|
88
86
|
if (!isTest) {
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -24,6 +24,17 @@ export type CorsConfig = {
|
|
|
24
24
|
methods: ALLOWED_METHODS[]
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
+
export type FastifyTimeoutConfig = {
|
|
28
|
+
/** Milliseconds to wait for a new connection (default: 0 = disabled) */
|
|
29
|
+
connectionTimeout?: number
|
|
30
|
+
/** Milliseconds to keep idle keep-alive connections open (default: 72000) */
|
|
31
|
+
keepAliveTimeout?: number
|
|
32
|
+
/** Milliseconds to wait for an incoming request body (default: 0 = disabled) */
|
|
33
|
+
requestTimeout?: number
|
|
34
|
+
/** Milliseconds to wait for a plugin to load (default: 10000) */
|
|
35
|
+
pluginTimeout?: number
|
|
36
|
+
}
|
|
37
|
+
|
|
27
38
|
export type InitializeConfig = {
|
|
28
39
|
projectId: string
|
|
29
40
|
mongodbUrl?: string
|
|
@@ -33,6 +44,7 @@ export type InitializeConfig = {
|
|
|
33
44
|
corsConfig?: CorsConfig
|
|
34
45
|
basePath?: string
|
|
35
46
|
mongodbEncryptionConfig?: MongoDbEncryptionConfig
|
|
47
|
+
timeoutConfig?: FastifyTimeoutConfig
|
|
36
48
|
}
|
|
37
49
|
|
|
38
50
|
/**
|
|
@@ -51,7 +63,8 @@ export async function initialize({
|
|
|
51
63
|
mongodbUrl = DEFAULT_CONFIG.MONGODB_URL,
|
|
52
64
|
corsConfig = DEFAULT_CONFIG.CORS_OPTIONS,
|
|
53
65
|
basePath,
|
|
54
|
-
mongodbEncryptionConfig
|
|
66
|
+
mongodbEncryptionConfig,
|
|
67
|
+
timeoutConfig
|
|
55
68
|
}: InitializeConfig) {
|
|
56
69
|
if (!jwtSecret || jwtSecret.trim().length === 0) {
|
|
57
70
|
throw new Error('JWT secret missing: set JWT_SECRET or pass jwtSecret to initialize()')
|
|
@@ -59,7 +72,11 @@ export async function initialize({
|
|
|
59
72
|
|
|
60
73
|
const resolvedBasePath = basePath ?? require.main?.path ?? process.cwd()
|
|
61
74
|
const fastify = Fastify({
|
|
62
|
-
logger: !!DEFAULT_CONFIG.ENABLE_LOGGER
|
|
75
|
+
logger: !!DEFAULT_CONFIG.ENABLE_LOGGER,
|
|
76
|
+
...(timeoutConfig?.connectionTimeout !== undefined && { connectionTimeout: timeoutConfig.connectionTimeout }),
|
|
77
|
+
...(timeoutConfig?.keepAliveTimeout !== undefined && { keepAliveTimeout: timeoutConfig.keepAliveTimeout }),
|
|
78
|
+
...(timeoutConfig?.requestTimeout !== undefined && { requestTimeout: timeoutConfig.requestTimeout }),
|
|
79
|
+
...(timeoutConfig?.pluginTimeout !== undefined && { pluginTimeout: timeoutConfig.pluginTimeout })
|
|
63
80
|
})
|
|
64
81
|
|
|
65
82
|
const isTest = process.env.NODE_ENV === 'test' || process.env.JEST_WORKER_ID !== undefined
|