@flowerforce/flowerbase 1.0.3-beta.7 → 1.0.3-beta.8
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/features/endpoints/utils.d.ts.map +1 -1
- package/dist/features/endpoints/utils.js +33 -8
- package/dist/utils/initializer/registerPlugins.d.ts.map +1 -1
- package/dist/utils/initializer/registerPlugins.js +13 -0
- package/package.json +2 -1
- package/src/features/endpoints/utils.ts +33 -8
- package/src/utils/initializer/registerPlugins.ts +13 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/features/endpoints/utils.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAKvE,OAAO,EAAE,SAAS,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA;AAE9D;;;GAGG;AACH,eAAO,MAAM,aAAa,GAAU,gBAAuB,KAAG,OAAO,CAAC,SAAS,CAmB9E,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,GAC3B,KAAK,eAAe,EACpB,SAAS,UAAU,CAAC,OAAO,eAAe,CAAC,EAC3C,UAAU,MAAM;;;;;;;
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/features/endpoints/utils.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAKvE,OAAO,EAAE,SAAS,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA;AAE9D;;;GAGG;AACH,eAAO,MAAM,aAAa,GAAU,gBAAuB,KAAG,OAAO,CAAC,SAAS,CAmB9E,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,GAC3B,KAAK,eAAe,EACpB,SAAS,UAAU,CAAC,OAAO,eAAe,CAAC,EAC3C,UAAU,MAAM;;;;;;;CAgChB,CAAA;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,GAAI,oDAK7B,qBAAqB,MACR,KAAK,cAAc,EAAE,KAAK,YAAY,gBA4CrD,CAAA"}
|
|
@@ -57,12 +57,36 @@ exports.loadEndpoints = loadEndpoints;
|
|
|
57
57
|
* @param endpoint -> the current endpoint
|
|
58
58
|
*/
|
|
59
59
|
const getMethodsConfig = (app, handler, endpoint) => ({
|
|
60
|
-
ALL: () => app.all(endpoint,
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
60
|
+
ALL: () => app.all(endpoint, {
|
|
61
|
+
config: {
|
|
62
|
+
rawBody: true
|
|
63
|
+
},
|
|
64
|
+
}, handler),
|
|
65
|
+
GET: () => app.get(endpoint, {
|
|
66
|
+
config: {
|
|
67
|
+
rawBody: true
|
|
68
|
+
},
|
|
69
|
+
}, handler),
|
|
70
|
+
POST: () => app.post(endpoint, {
|
|
71
|
+
config: {
|
|
72
|
+
rawBody: true
|
|
73
|
+
},
|
|
74
|
+
}, handler),
|
|
75
|
+
PUT: () => app.put(endpoint, {
|
|
76
|
+
config: {
|
|
77
|
+
rawBody: true
|
|
78
|
+
},
|
|
79
|
+
}, handler),
|
|
80
|
+
PATCH: () => app.patch(endpoint, {
|
|
81
|
+
config: {
|
|
82
|
+
rawBody: true
|
|
83
|
+
},
|
|
84
|
+
}, handler),
|
|
85
|
+
DELETE: () => app.delete(endpoint, {
|
|
86
|
+
config: {
|
|
87
|
+
rawBody: true
|
|
88
|
+
},
|
|
89
|
+
}, handler)
|
|
66
90
|
});
|
|
67
91
|
exports.getMethodsConfig = getMethodsConfig;
|
|
68
92
|
/**
|
|
@@ -75,9 +99,10 @@ exports.getMethodsConfig = getMethodsConfig;
|
|
|
75
99
|
const generateHandler = ({ app, currentFunction, functionsList, rulesList }) => {
|
|
76
100
|
return (req, res) => __awaiter(void 0, void 0, void 0, function* () {
|
|
77
101
|
var _a;
|
|
78
|
-
const { body: originalBody, headers, query } = req;
|
|
102
|
+
const { body: originalBody, headers, query, rawBody } = req;
|
|
79
103
|
const customBody = {
|
|
80
|
-
text: () => JSON.stringify(originalBody)
|
|
104
|
+
text: () => JSON.stringify(originalBody),
|
|
105
|
+
rawBody
|
|
81
106
|
};
|
|
82
107
|
const customResponseBody = {
|
|
83
108
|
data: null
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registerPlugins.d.ts","sourceRoot":"","sources":["../../../src/utils/initializer/registerPlugins.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"registerPlugins.d.ts","sourceRoot":"","sources":["../../../src/utils/initializer/registerPlugins.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAOzC,OAAO,EAAE,SAAS,EAAE,MAAM,oCAAoC,CAAA;AAE9D,KAAK,gBAAgB,GAAG,eAAe,CAAC,UAAU,CAAC,CAAA;AAGnD,KAAK,qBAAqB,GAAG;IAC3B,QAAQ,EAAE,gBAAgB,CAAA;IAC1B,UAAU,EAAE,MAAM,CAAA;IAClB,SAAS,EAAE,MAAM,CAAA;IACjB,aAAa,EAAE,SAAS,CAAA;CACzB,CAAA;AAQD;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,GAAU,oDAKnC,qBAAqB,kBAoBvB,CAAA"}
|
|
@@ -15,6 +15,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
15
|
exports.registerPlugins = void 0;
|
|
16
16
|
const cors_1 = __importDefault(require("@fastify/cors"));
|
|
17
17
|
const mongodb_1 = __importDefault(require("@fastify/mongodb"));
|
|
18
|
+
const fastify_raw_body_1 = __importDefault(require("fastify-raw-body"));
|
|
18
19
|
const controller_1 = require("../../auth/controller");
|
|
19
20
|
const jwt_1 = __importDefault(require("../../auth/plugins/jwt"));
|
|
20
21
|
const controller_2 = require("../../auth/providers/custom-function/controller");
|
|
@@ -81,6 +82,18 @@ const getRegisterConfig = (_a) => __awaiter(void 0, [_a], void 0, function* ({ m
|
|
|
81
82
|
secret: jwtSecret
|
|
82
83
|
}
|
|
83
84
|
},
|
|
85
|
+
{
|
|
86
|
+
pluginName: 'fastifyRawBody',
|
|
87
|
+
plugin: fastify_raw_body_1.default,
|
|
88
|
+
options: {
|
|
89
|
+
field: 'rawBody',
|
|
90
|
+
global: false,
|
|
91
|
+
encoding: 'utf8',
|
|
92
|
+
runFirst: true,
|
|
93
|
+
routes: [],
|
|
94
|
+
jsonContentTypes: [],
|
|
95
|
+
}
|
|
96
|
+
},
|
|
84
97
|
{
|
|
85
98
|
pluginName: 'authController',
|
|
86
99
|
plugin: controller_1.authController,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flowerforce/flowerbase",
|
|
3
|
-
"version": "1.0.3-beta.
|
|
3
|
+
"version": "1.0.3-beta.8",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -32,6 +32,7 @@
|
|
|
32
32
|
"fastify": "^5.0.0",
|
|
33
33
|
"fastify-mongoose-driver": "^3.2.0",
|
|
34
34
|
"fastify-plugin": "^5.0.1",
|
|
35
|
+
"fastify-raw-body": "^5.0.0",
|
|
35
36
|
"lodash": "^4.17.21",
|
|
36
37
|
"node-cron": "^3.0.3",
|
|
37
38
|
"nodemon": "^3.1.7",
|
|
@@ -44,12 +44,36 @@ export const getMethodsConfig = (
|
|
|
44
44
|
handler: ReturnType<typeof generateHandler>,
|
|
45
45
|
endpoint: string
|
|
46
46
|
) => ({
|
|
47
|
-
ALL: () => app.all(endpoint,
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
47
|
+
ALL: () => app.all(endpoint, {
|
|
48
|
+
config: {
|
|
49
|
+
rawBody: true
|
|
50
|
+
},
|
|
51
|
+
}, handler),
|
|
52
|
+
GET: () => app.get(endpoint, {
|
|
53
|
+
config: {
|
|
54
|
+
rawBody: true
|
|
55
|
+
},
|
|
56
|
+
}, handler),
|
|
57
|
+
POST: () => app.post(endpoint, {
|
|
58
|
+
config: {
|
|
59
|
+
rawBody: true
|
|
60
|
+
},
|
|
61
|
+
}, handler),
|
|
62
|
+
PUT: () => app.put(endpoint, {
|
|
63
|
+
config: {
|
|
64
|
+
rawBody: true
|
|
65
|
+
},
|
|
66
|
+
}, handler),
|
|
67
|
+
PATCH: () => app.patch(endpoint, {
|
|
68
|
+
config: {
|
|
69
|
+
rawBody: true
|
|
70
|
+
},
|
|
71
|
+
}, handler),
|
|
72
|
+
DELETE: () => app.delete(endpoint, {
|
|
73
|
+
config: {
|
|
74
|
+
rawBody: true
|
|
75
|
+
},
|
|
76
|
+
}, handler)
|
|
53
77
|
})
|
|
54
78
|
|
|
55
79
|
/**
|
|
@@ -66,10 +90,11 @@ export const generateHandler = ({
|
|
|
66
90
|
rulesList
|
|
67
91
|
}: GenerateHandlerParams) => {
|
|
68
92
|
return async (req: FastifyRequest, res: FastifyReply) => {
|
|
69
|
-
const { body: originalBody, headers, query } = req
|
|
93
|
+
const { body: originalBody, headers, query, rawBody } = req
|
|
70
94
|
|
|
71
95
|
const customBody = {
|
|
72
|
-
text: () => JSON.stringify(originalBody)
|
|
96
|
+
text: () => JSON.stringify(originalBody),
|
|
97
|
+
rawBody
|
|
73
98
|
}
|
|
74
99
|
|
|
75
100
|
const customResponseBody: {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import cors from '@fastify/cors'
|
|
2
2
|
import fastifyMongodb from '@fastify/mongodb'
|
|
3
3
|
import { FastifyInstance } from 'fastify'
|
|
4
|
+
import fastifyRawBody from 'fastify-raw-body'
|
|
4
5
|
import { authController } from '../../auth/controller'
|
|
5
6
|
import jwtAuthPlugin from '../../auth/plugins/jwt'
|
|
6
7
|
import { customFunctionController } from '../../auth/providers/custom-function/controller'
|
|
@@ -94,6 +95,18 @@ const getRegisterConfig = async ({
|
|
|
94
95
|
secret: jwtSecret
|
|
95
96
|
}
|
|
96
97
|
},
|
|
98
|
+
{
|
|
99
|
+
pluginName: 'fastifyRawBody',
|
|
100
|
+
plugin: fastifyRawBody,
|
|
101
|
+
options: {
|
|
102
|
+
field: 'rawBody',
|
|
103
|
+
global: false,
|
|
104
|
+
encoding: 'utf8',
|
|
105
|
+
runFirst: true,
|
|
106
|
+
routes: [],
|
|
107
|
+
jsonContentTypes: [],
|
|
108
|
+
}
|
|
109
|
+
},
|
|
97
110
|
{
|
|
98
111
|
pluginName: 'authController',
|
|
99
112
|
plugin: authController,
|