@forklaunch/core 0.1.0 → 0.1.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/.prettierignore +2 -0
- package/.prettierrc +6 -0
- package/dist/cache/index.d.ts +3 -0
- package/dist/cache/index.js +20 -0
- package/dist/cache/index.js.map +1 -0
- package/dist/cache/interfaces/ttlCache.interface.d.ts +1 -1
- package/dist/cache/redisTtlCache.d.ts +3 -2
- package/dist/cache/redisTtlCache.js +2 -2
- package/dist/cache/redisTtlCache.js.map +1 -1
- package/dist/cache/types/{ttlCacheRecord.js → ttlCacheRecord.types.js} +1 -1
- package/dist/cache/types/ttlCacheRecord.types.js.map +1 -0
- package/dist/controllers/index.d.ts +1 -0
- package/dist/controllers/index.js +18 -0
- package/dist/controllers/index.js.map +1 -0
- package/dist/database/index.d.ts +1 -0
- package/dist/database/index.js +18 -0
- package/dist/database/index.js.map +1 -0
- package/dist/database/mikro/models/entities/base.entity.js +1 -1
- package/dist/entityMapper/index.d.ts +2 -0
- package/dist/entityMapper/index.js +19 -0
- package/dist/entityMapper/index.js.map +1 -0
- package/dist/entityMapper/interfaces/entityMapper.interface.d.ts +3 -3
- package/dist/entityMapper/models/baseEntityMapper.model.d.ts +23 -23
- package/dist/entityMapper/models/baseEntityMapper.model.js +17 -17
- package/dist/entityMapper/models/baseEntityMapper.model.js.map +1 -1
- package/dist/entityMapper/models/requestEntityMapper.model.d.ts +17 -23
- package/dist/entityMapper/models/requestEntityMapper.model.js +13 -19
- package/dist/entityMapper/models/requestEntityMapper.model.js.map +1 -1
- package/dist/entityMapper/models/responseEntityMapper.model.d.ts +15 -16
- package/dist/entityMapper/models/responseEntityMapper.model.js +8 -8
- package/dist/entityMapper/models/responseEntityMapper.model.js.map +1 -1
- package/dist/entityMapper/types/entityMapper.types.d.ts +3 -22
- package/dist/http/index.d.ts +2 -0
- package/dist/http/index.js +19 -0
- package/dist/http/index.js.map +1 -0
- package/dist/http/middlewares/index.d.ts +2 -0
- package/dist/http/middlewares/index.js +19 -0
- package/dist/http/middlewares/index.js.map +1 -0
- package/dist/http/middlewares/request.middleware.d.ts +11 -11
- package/dist/http/middlewares/request.middleware.js +32 -31
- package/dist/http/middlewares/request.middleware.js.map +1 -1
- package/dist/http/middlewares/response.middleware.d.ts +3 -2
- package/dist/http/middlewares/response.middleware.js +9 -6
- package/dist/http/middlewares/response.middleware.js.map +1 -1
- package/dist/http/types/api.types.d.ts +16 -13
- package/dist/http/types/index.d.ts +2 -0
- package/dist/http/types/index.js +19 -0
- package/dist/http/types/index.js.map +1 -0
- package/dist/http/types/primitive.types.d.ts +14 -13
- package/dist/index.d.ts +6 -1
- package/dist/index.js +20 -5
- package/dist/index.js.map +1 -1
- package/dist/services/index.d.ts +1 -0
- package/dist/services/index.js +18 -0
- package/dist/services/index.js.map +1 -0
- package/dist/services/interfaces/baseService.d.ts +1 -1
- package/dist/tests/{dto.test.js → entityMapper.test.js} +10 -32
- package/dist/tests/entityMapper.test.js.map +1 -0
- package/dist/tests/http.middleware.test.d.ts +1 -0
- package/dist/tests/http.middleware.test.js +79 -0
- package/dist/tests/http.middleware.test.js.map +1 -0
- package/dist/tests/redisTtlCache.test.js +32 -15
- package/dist/tests/redisTtlCache.test.js.map +1 -1
- package/entityMapper/index.ts +2 -0
- package/entityMapper/interfaces/entityMapper.interface.ts +11 -11
- package/entityMapper/models/baseEntityMapper.model.ts +90 -73
- package/entityMapper/models/requestEntityMapper.model.ts +96 -76
- package/entityMapper/models/responseEntityMapper.model.ts +83 -62
- package/entityMapper/types/entityMapper.types.ts +6 -23
- package/http/index.ts +2 -0
- package/http/middlewares/index.ts +2 -0
- package/http/middlewares/request.middleware.ts +118 -62
- package/http/middlewares/response.middleware.ts +56 -30
- package/http/types/api.types.ts +43 -25
- package/http/types/index.ts +2 -0
- package/http/types/primitive.types.ts +65 -44
- package/index.ts +6 -5
- package/jest.config.ts +2 -2
- package/package.json +13 -4
- package/tests/entityMapper.test.ts +219 -0
- package/tests/http.middleware.test.ts +99 -0
- package/tests/redisTtlCache.test.ts +49 -29
- package/dist/cache/types/ttlCacheRecord.js.map +0 -1
- package/dist/tests/dto.test.js.map +0 -1
- package/tests/dto.test.ts +0 -235
- /package/dist/cache/types/{ttlCacheRecord.d.ts → ttlCacheRecord.types.d.ts} +0 -0
- /package/dist/tests/{dto.test.d.ts → entityMapper.test.d.ts} +0 -0
@@ -1,28 +1,9 @@
|
|
1
|
-
import {
|
2
|
-
import {
|
3
|
-
import { UnboxedObjectSchema } from "@forklaunch/validator/types";
|
4
|
-
import { BaseEntityMapper } from "../models/baseEntityMapper.model";
|
1
|
+
import { AnySchemaValidator } from '@forklaunch/validator';
|
2
|
+
import { UnboxedObjectSchema } from '@forklaunch/validator/types';
|
5
3
|
/**
|
6
4
|
* Type representing a schema validator object for an entity mapper.
|
7
5
|
*
|
8
6
|
* @template SV - A type that extends SchemaValidator.
|
9
7
|
* @typedef {ValidSchemaObject<SV> | UnboxedObjectSchema<SchemaCatchall<SV>> & {}} EntityMapperSchemaValidatorObject
|
10
8
|
*/
|
11
|
-
export type EntityMapperSchemaValidatorObject<SV extends
|
12
|
-
/**
|
13
|
-
* Type representing the static schema of an entity mapper.
|
14
|
-
*
|
15
|
-
* @template T - A type that extends BaseEntityMapper with a schema property.
|
16
|
-
* @typedef {Schema<T['schema'], T['_SV']> & {}} EntityMapperStaticSchema
|
17
|
-
*/
|
18
|
-
export type EntityMapperStaticSchema<T extends BaseEntityMapper<any> & {
|
19
|
-
schema: any;
|
20
|
-
}> = Schema<T['schema'], T['_SV']>;
|
21
|
-
/**
|
22
|
-
* Type representing the schema of an entity mapper.
|
23
|
-
*
|
24
|
-
* @template T - A type that extends ValidSchemaObject or UnboxedObjectSchema with SchemaCatchall.
|
25
|
-
* @template SV - A type that extends SchemaValidator.
|
26
|
-
* @typedef {Schema<T, SV> & {}} EntityMapperSchema
|
27
|
-
*/
|
28
|
-
export type EntityMapperSchema<T extends ValidSchemaObject<SV> | UnboxedObjectSchema<SchemaCatchall<SV>>, SV extends SchemaValidator> = Schema<T, SV>;
|
9
|
+
export type EntityMapperSchemaValidatorObject<SV extends AnySchemaValidator> = SV['_ValidSchemaObject'] | UnboxedObjectSchema<SV>;
|
@@ -0,0 +1,19 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
+
if (k2 === undefined) k2 = k;
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
7
|
+
}
|
8
|
+
Object.defineProperty(o, k2, desc);
|
9
|
+
}) : (function(o, m, k, k2) {
|
10
|
+
if (k2 === undefined) k2 = k;
|
11
|
+
o[k2] = m[k];
|
12
|
+
}));
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
15
|
+
};
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
17
|
+
__exportStar(require("./middlewares"), exports);
|
18
|
+
__exportStar(require("./types"), exports);
|
19
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../http/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gDAA8B;AAC9B,0CAAwB"}
|
@@ -0,0 +1,19 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
+
if (k2 === undefined) k2 = k;
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
7
|
+
}
|
8
|
+
Object.defineProperty(o, k2, desc);
|
9
|
+
}) : (function(o, m, k, k2) {
|
10
|
+
if (k2 === undefined) k2 = k;
|
11
|
+
o[k2] = m[k];
|
12
|
+
}));
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
15
|
+
};
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
17
|
+
__exportStar(require("./request.middleware"), exports);
|
18
|
+
__exportStar(require("./response.middleware"), exports);
|
19
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../http/middlewares/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,uDAAqC;AACrC,wDAAsC"}
|
@@ -1,11 +1,11 @@
|
|
1
|
-
import { SchemaValidator } from
|
2
|
-
import { ForklaunchNextFunction, ForklaunchRequest, ForklaunchResponse } from
|
3
|
-
import { HttpContractDetails, PathParamHttpContractDetails, StringOnlyObject } from
|
4
|
-
export declare function createRequestContext<
|
5
|
-
export declare function enrichRequestDetails<SV extends
|
6
|
-
export declare function preHandlerParse<SV extends
|
7
|
-
export declare function parseRequestParams<
|
8
|
-
export declare function parseRequestBody<
|
9
|
-
export declare function parseRequestHeaders<
|
10
|
-
export declare function parseRequestQuery<
|
11
|
-
export declare function parseRequestAuth<
|
1
|
+
import { AnySchemaValidator, SchemaValidator } from '@forklaunch/validator';
|
2
|
+
import { ForklaunchNextFunction, ForklaunchRequest, ForklaunchResponse } from '../types/api.types';
|
3
|
+
import { HttpContractDetails, PathParamHttpContractDetails, StringOnlyObject } from '../types/primitive.types';
|
4
|
+
export declare function createRequestContext<SV extends AnySchemaValidator, Request extends ForklaunchRequest<SV>, Response extends ForklaunchResponse, NextFunction extends ForklaunchNextFunction>(schemaValidator: SV): (req: Request, res: Response, next?: NextFunction) => void;
|
5
|
+
export declare function enrichRequestDetails<SV extends AnySchemaValidator, Request extends ForklaunchRequest<SV>, Response extends ForklaunchResponse, NextFunction extends ForklaunchNextFunction>(contractDetails: PathParamHttpContractDetails<SV> | HttpContractDetails<SV>): (req: Request, _res: Response, next?: NextFunction) => void;
|
6
|
+
export declare function preHandlerParse<SV extends AnySchemaValidator>(schemaValidator: SchemaValidator, object: unknown, schemaInput?: StringOnlyObject<SV>): 400 | undefined;
|
7
|
+
export declare function parseRequestParams<SV extends AnySchemaValidator, Request extends ForklaunchRequest<SV>, Response extends ForklaunchResponse, NextFunction extends ForklaunchNextFunction>(req: Request, res: Response, next?: NextFunction): void;
|
8
|
+
export declare function parseRequestBody<SV extends AnySchemaValidator, Request extends ForklaunchRequest<SV>, Response extends ForklaunchResponse, NextFunction extends ForklaunchNextFunction>(req: Request, res: Response, next?: NextFunction): void;
|
9
|
+
export declare function parseRequestHeaders<SV extends AnySchemaValidator, Request extends ForklaunchRequest<SV>, Response extends ForklaunchResponse, NextFunction extends ForklaunchNextFunction>(req: Request, res: Response, next?: NextFunction): void;
|
10
|
+
export declare function parseRequestQuery<SV extends AnySchemaValidator, Request extends ForklaunchRequest<SV>, Response extends ForklaunchResponse, NextFunction extends ForklaunchNextFunction>(req: Request, res: Response, next?: NextFunction): void;
|
11
|
+
export declare function parseRequestAuth<SV extends AnySchemaValidator, Request extends ForklaunchRequest<SV>, Response extends ForklaunchResponse, NextFunction extends ForklaunchNextFunction>(req: Request, res: Response, next?: NextFunction): Promise<void>;
|
@@ -23,7 +23,14 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
23
23
|
return result;
|
24
24
|
};
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
26
|
-
exports.
|
26
|
+
exports.createRequestContext = createRequestContext;
|
27
|
+
exports.enrichRequestDetails = enrichRequestDetails;
|
28
|
+
exports.preHandlerParse = preHandlerParse;
|
29
|
+
exports.parseRequestParams = parseRequestParams;
|
30
|
+
exports.parseRequestBody = parseRequestBody;
|
31
|
+
exports.parseRequestHeaders = parseRequestHeaders;
|
32
|
+
exports.parseRequestQuery = parseRequestQuery;
|
33
|
+
exports.parseRequestAuth = parseRequestAuth;
|
27
34
|
const jose = __importStar(require("jose"));
|
28
35
|
const uuid_1 = require("uuid");
|
29
36
|
function createRequestContext(schemaValidator) {
|
@@ -42,7 +49,6 @@ function createRequestContext(schemaValidator) {
|
|
42
49
|
}
|
43
50
|
};
|
44
51
|
}
|
45
|
-
exports.createRequestContext = createRequestContext;
|
46
52
|
function enrichRequestDetails(contractDetails) {
|
47
53
|
return (req, _res, next) => {
|
48
54
|
req.contractDetails = contractDetails;
|
@@ -51,7 +57,6 @@ function enrichRequestDetails(contractDetails) {
|
|
51
57
|
}
|
52
58
|
};
|
53
59
|
}
|
54
|
-
exports.enrichRequestDetails = enrichRequestDetails;
|
55
60
|
function preHandlerParse(schemaValidator, object, schemaInput) {
|
56
61
|
if (!schemaInput) {
|
57
62
|
return;
|
@@ -61,28 +66,26 @@ function preHandlerParse(schemaValidator, object, schemaInput) {
|
|
61
66
|
return 400;
|
62
67
|
}
|
63
68
|
}
|
64
|
-
exports.preHandlerParse = preHandlerParse;
|
65
69
|
function parseRequestParams(req, res, next) {
|
66
70
|
const params = req.contractDetails.params;
|
67
71
|
if (preHandlerParse(req.schemaValidator, req.params, params) === 400) {
|
68
|
-
res.status(400).send(
|
72
|
+
res.status(400).send('Invalid request parameters.');
|
69
73
|
if (next) {
|
70
|
-
next(new Error(
|
74
|
+
next(new Error('Invalid request parameters.'));
|
71
75
|
}
|
72
76
|
}
|
73
|
-
;
|
74
77
|
if (next) {
|
75
78
|
next();
|
76
79
|
}
|
77
80
|
}
|
78
|
-
exports.parseRequestParams = parseRequestParams;
|
79
81
|
function parseRequestBody(req, res, next) {
|
80
82
|
if (req.headers['content-type'] === 'application/json') {
|
81
|
-
const body = (req.schemaValidator,
|
82
|
-
|
83
|
-
|
83
|
+
const body = (req.schemaValidator,
|
84
|
+
req.contractDetails).body;
|
85
|
+
if (preHandlerParse(req.schemaValidator, req.body, body) === 400) {
|
86
|
+
res.status(400).send('Invalid request body.');
|
84
87
|
if (next) {
|
85
|
-
next(new Error(
|
88
|
+
next(new Error('Invalid request body.'));
|
86
89
|
}
|
87
90
|
}
|
88
91
|
}
|
@@ -90,41 +93,38 @@ function parseRequestBody(req, res, next) {
|
|
90
93
|
next();
|
91
94
|
}
|
92
95
|
}
|
93
|
-
exports.parseRequestBody = parseRequestBody;
|
94
96
|
function parseRequestHeaders(req, res, next) {
|
95
97
|
const headers = req.contractDetails.requestHeaders;
|
96
98
|
if (preHandlerParse(req.schemaValidator, req.headers, headers) === 400) {
|
97
|
-
res.status(400).send(
|
99
|
+
res.status(400).send('Invalid request headers.');
|
98
100
|
if (next) {
|
99
|
-
next(new Error(
|
101
|
+
next(new Error('Invalid request headers.'));
|
100
102
|
}
|
101
103
|
}
|
102
104
|
if (next) {
|
103
105
|
next();
|
104
106
|
}
|
105
107
|
}
|
106
|
-
exports.parseRequestHeaders = parseRequestHeaders;
|
107
108
|
function parseRequestQuery(req, res, next) {
|
108
109
|
const query = req.contractDetails.query;
|
109
|
-
if (preHandlerParse(req.query, query) === 400) {
|
110
|
-
res.status(400).send(
|
110
|
+
if (preHandlerParse(req.schemaValidator, req.query, query) === 400) {
|
111
|
+
res.status(400).send('Invalid request query.');
|
111
112
|
if (next) {
|
112
|
-
next(new Error(
|
113
|
+
next(new Error('Invalid request query.'));
|
113
114
|
}
|
114
115
|
}
|
115
116
|
if (next) {
|
116
117
|
next();
|
117
118
|
}
|
118
119
|
}
|
119
|
-
exports.parseRequestQuery = parseRequestQuery;
|
120
120
|
async function checkAuthorizationToken(authorizationMethod, authorizationString) {
|
121
121
|
if (!authorizationString) {
|
122
|
-
return [401,
|
122
|
+
return [401, 'No Authorization token provided.'];
|
123
123
|
}
|
124
124
|
switch (authorizationMethod) {
|
125
125
|
case 'jwt': {
|
126
126
|
if (!authorizationString.startsWith('Bearer ')) {
|
127
|
-
return [401,
|
127
|
+
return [401, 'Invalid Authorization token format.'];
|
128
128
|
}
|
129
129
|
try {
|
130
130
|
const decodedJwt = await jose.jwtVerify(authorizationString.split(' ')[1], new TextEncoder().encode(process.env.JWT_SECRET || 'your-256-bit-secret'));
|
@@ -132,11 +132,11 @@ async function checkAuthorizationToken(authorizationMethod, authorizationString)
|
|
132
132
|
}
|
133
133
|
catch (error) {
|
134
134
|
console.error(error);
|
135
|
-
return [403,
|
135
|
+
return [403, 'Invalid Authorization token.'];
|
136
136
|
}
|
137
137
|
}
|
138
138
|
default:
|
139
|
-
return [401,
|
139
|
+
return [401, 'Invalid Authorization method.'];
|
140
140
|
}
|
141
141
|
}
|
142
142
|
function mapRoles(authorizationType, authorizationToken) {
|
@@ -158,20 +158,22 @@ async function parseRequestAuth(req, res, next) {
|
|
158
158
|
// TODO: Implement role and permission checking
|
159
159
|
const permissionSlugs = mapPermissions(auth.method, req.headers.authorization);
|
160
160
|
const roles = mapRoles(auth.method, req.headers.authorization);
|
161
|
-
const permissionErrorMessage =
|
162
|
-
const roleErrorMessage =
|
161
|
+
const permissionErrorMessage = 'User does not have sufficient permissions to perform action.';
|
162
|
+
const roleErrorMessage = 'User does not have correct role to perform action.';
|
163
163
|
// this is wrong, we need to check if any of the user's permissions are in the allowed permissions, while checking that any of the permissions is not in the forbidden slugs
|
164
164
|
// currently this is checking if any of the user's permissions are NOT in the allowed permissions
|
165
|
-
permissionSlugs.forEach(permissionSlug => {
|
166
|
-
if (!req.contractDetails.auth?.allowedSlugs?.has(permissionSlug) ||
|
165
|
+
permissionSlugs.forEach((permissionSlug) => {
|
166
|
+
if (!req.contractDetails.auth?.allowedSlugs?.has(permissionSlug) ||
|
167
|
+
req.contractDetails.auth?.forbiddenSlugs?.has(permissionSlug)) {
|
167
168
|
res.status(403).send(permissionErrorMessage);
|
168
169
|
if (next) {
|
169
170
|
next(new Error(permissionErrorMessage));
|
170
171
|
}
|
171
172
|
}
|
172
173
|
});
|
173
|
-
roles.forEach(role => {
|
174
|
-
if (!req.contractDetails.auth?.allowedRoles?.has(role) ||
|
174
|
+
roles.forEach((role) => {
|
175
|
+
if (!req.contractDetails.auth?.allowedRoles?.has(role) ||
|
176
|
+
req.contractDetails.auth?.forbiddenRoles?.has(role)) {
|
175
177
|
res.status(403).send(roleErrorMessage);
|
176
178
|
if (next) {
|
177
179
|
next(new Error(roleErrorMessage));
|
@@ -183,5 +185,4 @@ async function parseRequestAuth(req, res, next) {
|
|
183
185
|
// next();
|
184
186
|
// }
|
185
187
|
}
|
186
|
-
exports.parseRequestAuth = parseRequestAuth;
|
187
188
|
//# sourceMappingURL=request.middleware.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"request.middleware.js","sourceRoot":"","sources":["../../../http/middlewares/request.middleware.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"request.middleware.js","sourceRoot":"","sources":["../../../http/middlewares/request.middleware.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAeA,oDAyBC;AAED,oDAaC;AAED,0CAaC;AAED,gDAgBC;AAED,4CAyBC;AAED,kDAgBC;AAED,8CAgBC;AA6CD,4CA4DC;AA/PD,2CAA6B;AAC7B,+BAA0B;AAa1B,SAAgB,oBAAoB,CAKlC,eAAmB;IACjB,OAAO,CAAC,GAAY,EAAE,GAAa,EAAE,IAAmB,EAAE,EAAE;QACxD,GAAG,CAAC,eAAe,GAAG,eAAkC,CAAC;QAEzD,IAAI,aAAa,GAAG,IAAA,SAAE,GAAE,CAAC;QAEzB,IAAI,GAAG,CAAC,OAAO,CAAC,kBAAkB,CAAC,EAAE,CAAC;YAClC,aAAa,GAAG,GAAG,CAAC,OAAO,CAAC,kBAAkB,CAAW,CAAC;QAC9D,CAAC;QAED,GAAG,CAAC,SAAS,CAAC,kBAAkB,EAAE,aAAa,CAAC,CAAC;QAEjD,GAAG,CAAC,OAAO,GAAG;YACV,aAAa,EAAE,aAAa;SAC/B,CAAC;QAEF,IA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,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;gBAC7C,IAAI,IAAI,EAAE,CAAC;oBACP,IAAI,CAAC,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC,CAAC;gBAC5C,CAAC;YACL,CAAC;QACL,CAAC,CAAC,CAAC;QACH,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;YACnB,IACI,CAAC,GAAG,CAAC,eAAe,CAAC,IAAI,EAAE,YAAY,EAAE,GAAG,CAAC,IAAI,CAAC;gBAClD,GAAG,CAAC,eAAe,CAAC,IAAI,EAAE,cAAc,EAAE,GAAG,CAAC,IAAI,CAAC,EACrD,CAAC;gBACC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;gBACvC,IAAI,IAAI,EAAE,CAAC;oBACP,IAAI,CAAC,IAAI,KAAK,CAAC,gBAAgB,CAAC,CAAC,CAAC;gBACtC,CAAC;YACL,CAAC;QACL,CAAC,CAAC,CAAC;IACP,CAAC;IAED,cAAc;IACd,cAAc;IACd,IAAI;AACR,CAAC"}
|
@@ -1,2 +1,3 @@
|
|
1
|
-
import {
|
2
|
-
|
1
|
+
import { AnySchemaValidator } from '@forklaunch/validator';
|
2
|
+
import { ForklaunchNextFunction, ForklaunchRequest, ForklaunchResponse } from '../types/api.types';
|
3
|
+
export declare function parseResponse<SV extends AnySchemaValidator, Request extends ForklaunchRequest<SV>, Response extends ForklaunchResponse, NextFunction extends ForklaunchNextFunction>(req: Request, res: Response, next?: NextFunction): void;
|
@@ -1,8 +1,11 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.parseResponse =
|
3
|
+
exports.parseResponse = parseResponse;
|
4
4
|
function checkAnyValidation(contractDetails) {
|
5
|
-
return contractDetails.body ||
|
5
|
+
return (contractDetails.body ||
|
6
|
+
contractDetails.params ||
|
7
|
+
contractDetails.requestHeaders ||
|
8
|
+
contractDetails.query);
|
6
9
|
}
|
7
10
|
function parseResponse(req, res, next) {
|
8
11
|
if (req.contractDetails.responseHeaders) {
|
@@ -11,14 +14,15 @@ function parseResponse(req, res, next) {
|
|
11
14
|
}
|
12
15
|
if (res.statusCode === 500 ||
|
13
16
|
(checkAnyValidation(req.contractDetails) && res.statusCode === 400) ||
|
14
|
-
(req.contractDetails.auth &&
|
17
|
+
(req.contractDetails.auth &&
|
18
|
+
(res.statusCode === 401 || res.statusCode === 403))) {
|
19
|
+
req.schemaValidator.validate(req.schemaValidator.string, res.bodyData);
|
15
20
|
return;
|
16
21
|
}
|
17
|
-
if (!req.contractDetails.responses
|
22
|
+
if (Object.prototype.hasOwnProperty.call(!req.contractDetails.responses, res.statusCode)) {
|
18
23
|
if (next) {
|
19
24
|
next(new Error(`Response code ${res.statusCode} not defined in contract.`));
|
20
25
|
}
|
21
|
-
;
|
22
26
|
}
|
23
27
|
const schema = req.schemaValidator.schemify(req.contractDetails.responses[res.statusCode]);
|
24
28
|
req.schemaValidator.validate(schema, res.bodyData);
|
@@ -26,5 +30,4 @@ function parseResponse(req, res, next) {
|
|
26
30
|
next();
|
27
31
|
}
|
28
32
|
}
|
29
|
-
exports.parseResponse = parseResponse;
|
30
33
|
//# sourceMappingURL=response.middleware.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"response.middleware.js","sourceRoot":"","sources":["../../../http/middlewares/response.middleware.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"response.middleware.js","sourceRoot":"","sources":["../../../http/middlewares/response.middleware.ts"],"names":[],"mappings":";;AAmBA,sCA2CC;AAtDD,SAAS,kBAAkB,CACzB,eAAwC;IAExC,OAAO,CACL,eAAe,CAAC,IAAI;QACpB,eAAe,CAAC,MAAM;QACtB,eAAe,CAAC,cAAc;QAC9B,eAAe,CAAC,KAAK,CACtB,CAAC;AACJ,CAAC;AAED,SAAgB,aAAa,CA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,IAAI,EAAE,CAAC;IACT,CAAC;AACH,CAAC"}
|
@@ -1,25 +1,28 @@
|
|
1
|
-
|
2
|
-
import {
|
3
|
-
import {
|
4
|
-
import {
|
5
|
-
import {
|
6
|
-
import {
|
7
|
-
import { ParsedQs } from "qs";
|
8
|
-
import { HttpContractDetails, ParamsDictionary, PathParamHttpContractDetails } from "./primitive.types";
|
1
|
+
import { Prettify } from '@forklaunch/common';
|
2
|
+
import { AnySchemaValidator, Schema } from '@forklaunch/validator';
|
3
|
+
import { IdiomaticSchema, SchemaValidator } from '@forklaunch/validator/types';
|
4
|
+
import { IncomingHttpHeaders, OutgoingHttpHeader } from 'http';
|
5
|
+
import { ParsedQs } from 'qs';
|
6
|
+
import { HttpContractDetails, ParamsDictionary, PathParamHttpContractDetails } from './primitive.types';
|
9
7
|
export interface RequestContext {
|
10
8
|
correlationId: string;
|
11
9
|
idempotencyKey?: string;
|
12
10
|
}
|
13
|
-
export interface ForklaunchRequest<SV extends
|
11
|
+
export interface ForklaunchRequest<SV extends AnySchemaValidator, P = ParamsDictionary, ReqBody = unknown, ReqQuery = ParsedQs, Headers = IncomingHttpHeaders> {
|
14
12
|
context: Prettify<RequestContext>;
|
15
13
|
contractDetails: HttpContractDetails<SV> | PathParamHttpContractDetails<SV>;
|
16
|
-
schemaValidator:
|
14
|
+
schemaValidator: SchemaValidator;
|
17
15
|
params: P;
|
18
16
|
headers: Headers;
|
19
17
|
body: ReqBody;
|
20
18
|
query: ReqQuery;
|
21
19
|
}
|
22
|
-
export interface ForklaunchResponse<ResBody =
|
20
|
+
export interface ForklaunchResponse<ResBody = {
|
21
|
+
400: unknown;
|
22
|
+
401: unknown;
|
23
|
+
403: unknown;
|
24
|
+
500: unknown;
|
25
|
+
}, StatusCode = number> {
|
23
26
|
bodyData: unknown;
|
24
27
|
statusCode: StatusCode;
|
25
28
|
corked: boolean;
|
@@ -44,7 +47,7 @@ export interface ForklaunchResponse<ResBody = any, StatusCode = number> {
|
|
44
47
|
<T>(body?: ResBody): T;
|
45
48
|
};
|
46
49
|
}
|
47
|
-
export type MapSchema<SV extends
|
50
|
+
export type MapSchema<SV extends AnySchemaValidator, T extends IdiomaticSchema<SV> | SV['_ValidSchemaObject']> = Schema<T, SV> extends infer U ? {
|
48
51
|
[key: string]: unknown;
|
49
52
|
} extends U ? never : U : never;
|
50
|
-
export type ForklaunchNextFunction = (err?:
|
53
|
+
export type ForklaunchNextFunction = (err?: unknown) => void;
|
@@ -0,0 +1,19 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
+
if (k2 === undefined) k2 = k;
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
7
|
+
}
|
8
|
+
Object.defineProperty(o, k2, desc);
|
9
|
+
}) : (function(o, m, k, k2) {
|
10
|
+
if (k2 === undefined) k2 = k;
|
11
|
+
o[k2] = m[k];
|
12
|
+
}));
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
15
|
+
};
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
17
|
+
__exportStar(require("./api.types"), exports);
|
18
|
+
__exportStar(require("./primitive.types"), exports);
|
19
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../http/types/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAA4B;AAC5B,oDAAkC"}
|
@@ -1,19 +1,20 @@
|
|
1
|
-
import {
|
2
|
-
import {
|
3
|
-
import { UnboxedObjectSchema } from "@forklaunch/validator/types";
|
1
|
+
import { AnySchemaValidator } from '@forklaunch/validator';
|
2
|
+
import { UnboxedObjectSchema } from '@forklaunch/validator/types';
|
4
3
|
export type ParamsDictionary = {
|
5
4
|
[key: string]: string;
|
6
5
|
};
|
7
|
-
export type StringOnlyObject<SV extends
|
8
|
-
export type NumberOnlyObject<SV extends
|
9
|
-
export type BodyObject<SV extends
|
10
|
-
export type ParamsObject<SV extends
|
11
|
-
export type QueryObject<SV extends
|
12
|
-
export type HeadersObject<SV extends
|
13
|
-
export type ResponsesObject<SV extends
|
14
|
-
|
6
|
+
export type StringOnlyObject<SV extends AnySchemaValidator> = Omit<UnboxedObjectSchema<SV>, number | symbol>;
|
7
|
+
export type NumberOnlyObject<SV extends AnySchemaValidator> = Omit<UnboxedObjectSchema<SV>, string | symbol>;
|
8
|
+
export type BodyObject<SV extends AnySchemaValidator> = StringOnlyObject<SV> & unknown;
|
9
|
+
export type ParamsObject<SV extends AnySchemaValidator> = StringOnlyObject<SV> & unknown;
|
10
|
+
export type QueryObject<SV extends AnySchemaValidator> = StringOnlyObject<SV> & unknown;
|
11
|
+
export type HeadersObject<SV extends AnySchemaValidator> = StringOnlyObject<SV> & unknown;
|
12
|
+
export type ResponsesObject<SV extends AnySchemaValidator> = {
|
13
|
+
[key: number]: SV['_ValidSchemaObject'] | UnboxedObjectSchema<SV> | string | SV['string'];
|
14
|
+
} & unknown;
|
15
|
+
export type Body<SV extends AnySchemaValidator> = BodyObject<SV> | SV['_ValidSchemaObject'] | SV['_SchemaCatchall'];
|
15
16
|
export type AuthMethod = 'jwt' | 'session';
|
16
|
-
export interface PathParamHttpContractDetails<SV extends
|
17
|
+
export interface PathParamHttpContractDetails<SV extends AnySchemaValidator, ParamSchemas extends ParamsObject<SV> = ParamsObject<SV>, ResponseSchemas extends ResponsesObject<SV> = ResponsesObject<SV>, QuerySchemas extends QueryObject<SV> = QueryObject<SV>> {
|
17
18
|
name: string;
|
18
19
|
summary: string;
|
19
20
|
responses: ResponseSchemas;
|
@@ -29,7 +30,7 @@ export interface PathParamHttpContractDetails<SV extends SchemaValidator, ParamS
|
|
29
30
|
forbiddenRoles?: Set<string>;
|
30
31
|
};
|
31
32
|
}
|
32
|
-
export interface HttpContractDetails<SV extends
|
33
|
+
export interface HttpContractDetails<SV extends AnySchemaValidator, ParamSchemas extends ParamsObject<SV> = ParamsObject<SV>, ResponseSchemas extends ResponsesObject<SV> = ResponsesObject<SV>, BodySchema extends Body<SV> = Body<SV>, QuerySchemas extends QueryObject<SV> = QueryObject<SV>> extends PathParamHttpContractDetails<SV, ParamSchemas, ResponseSchemas, QuerySchemas> {
|
33
34
|
body?: BodySchema;
|
34
35
|
contentType?: 'application/json' | 'multipart/form-data' | 'application/x-www-form-urlencoded';
|
35
36
|
}
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
@@ -1,8 +1,23 @@
|
|
1
1
|
"use strict";
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
+
if (k2 === undefined) k2 = k;
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
7
|
+
}
|
8
|
+
Object.defineProperty(o, k2, desc);
|
9
|
+
}) : (function(o, m, k, k2) {
|
10
|
+
if (k2 === undefined) k2 = k;
|
11
|
+
o[k2] = m[k];
|
12
|
+
}));
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
15
|
+
};
|
2
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
17
|
+
__exportStar(require("./cache"), exports);
|
18
|
+
__exportStar(require("./controllers"), exports);
|
19
|
+
__exportStar(require("./database"), exports);
|
20
|
+
__exportStar(require("./entityMapper"), exports);
|
21
|
+
__exportStar(require("./http"), exports);
|
22
|
+
__exportStar(require("./services"), exports);
|
8
23
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAwB;AACxB,gDAA8B;AAC9B,6CAA2B;AAC3B,iDAA+B;AAC/B,yCAAuB;AACvB,6CAA2B"}
|
@@ -0,0 +1 @@
|
|
1
|
+
export * from './interfaces/baseService';
|
@@ -0,0 +1,18 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
+
if (k2 === undefined) k2 = k;
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
7
|
+
}
|
8
|
+
Object.defineProperty(o, k2, desc);
|
9
|
+
}) : (function(o, m, k, k2) {
|
10
|
+
if (k2 === undefined) k2 = k;
|
11
|
+
o[k2] = m[k];
|
12
|
+
}));
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
15
|
+
};
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
17
|
+
__exportStar(require("./interfaces/baseService"), exports);
|
18
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../services/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2DAAyC"}
|