temba 0.12.0 → 0.12.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/README.md +7 -9
- package/config/index.d.ts +3 -3
- package/index.js +5 -1
- package/index.js.map +1 -1
- package/package.json +17 -17
- package/queries/queries.d.ts +8 -0
- package/routes/types.d.ts +3 -3
package/README.md
CHANGED
|
@@ -246,22 +246,20 @@ To change the response body of a `GET` request, configure a `responseBodyInterce
|
|
|
246
246
|
|
|
247
247
|
```js
|
|
248
248
|
const config = {
|
|
249
|
-
responseBodyInterceptor: (resourceName,
|
|
250
|
-
|
|
249
|
+
responseBodyInterceptor: (resourceName, responseBody, id) => {
|
|
250
|
+
if (resourceName === 'movies') {
|
|
251
251
|
if (id) {
|
|
252
252
|
// responseBody is an object
|
|
253
253
|
return {
|
|
254
254
|
...responseBody,
|
|
255
255
|
stuff: 'more stuff',
|
|
256
256
|
}
|
|
257
|
-
}
|
|
257
|
+
} else {
|
|
258
258
|
// responseBody is an array
|
|
259
|
-
return responseBody.map(x => (
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
}
|
|
264
|
-
))
|
|
259
|
+
return responseBody.map((x) => ({
|
|
260
|
+
...x,
|
|
261
|
+
stuff: 'more stuff',
|
|
262
|
+
}))
|
|
265
263
|
}
|
|
266
264
|
}
|
|
267
265
|
|
package/config/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Router } from 'express';
|
|
2
2
|
import { RequestBodyValidator, ResponseBodyInterceptor } from '../routes/types';
|
|
3
|
-
export
|
|
3
|
+
export type Config = {
|
|
4
4
|
validateResources: boolean;
|
|
5
5
|
resourceNames: string[];
|
|
6
6
|
apiPrefix: string;
|
|
@@ -12,8 +12,8 @@ export declare type Config = {
|
|
|
12
12
|
delay: number;
|
|
13
13
|
customRouter: Router;
|
|
14
14
|
};
|
|
15
|
-
export
|
|
16
|
-
export
|
|
15
|
+
export type RouterConfig = Pick<Config, 'validateResources' | 'resourceNames' | 'apiPrefix' | 'cacheControl' | 'requestBodyValidator' | 'responseBodyInterceptor'>;
|
|
16
|
+
export type UserConfig = {
|
|
17
17
|
resourceNames?: string[];
|
|
18
18
|
validateResources?: boolean;
|
|
19
19
|
staticFolder?: string;
|
package/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
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);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mDAAuC;AACvC,oDAA2B;AAC3B,4CAA8C;AAC9C,4CAKwB;AACxB,+CAAiD;AACjD,qCAAyD;AACzD,gDAAuB;AACvB,6DAA+D;AAE/D,SAAS,YAAY,CAAC,UAAuB;IAC3C,MAAM,MAAM,GAAG,IAAA,mBAAU,EAAC,UAAU,CAAC,CAAA;IAErC,MAAM,OAAO,GAAG,IAAA,uBAAa,EAAC,MAAM,CAAC,gBAAgB,CAAC,CAAA;IAEtD,MAAM,GAAG,GAAG,IAAA,iBAAO,GAAE,CAAA;IACrB,GAAG,CAAC,GAAG,CAAC,IAAA,cAAI,G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AAE;QACpB,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,uBAAc,CAAC,CAAA;QAC5B,GAAG,CAAC,IAAI,CAAC,GAAG,EAAE,uBAAc,CAAC,CAAA;QAC7B,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,uBAAc,CAAC,CAAA;QAC5B,GAAG,CAAC,MAAM,CAAC,GAAG,EAAE,uBAAc,CAAC,CAAA;KAChC;IAED,gDAAgD;IAChD,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,+BAAsB,CAAC,CAAA;IACpC,IAAI,MAAM,CAAC,SAAS;QAAE,GAAG,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,SAAS,GAAG,EAAE,+BAAsB,CAAC,CAAA;IAE7E,oBAAoB;IACpB,GAAG,CAAC,GAAG,CAAC,qBAAY,CAAC,CAAA;IAErB,OAAO,GAAG,CAAA;AACZ,CAAC;AAED,SAAgB,MAAM,CAAC,UAAmB;IACxC,OAAO,YAAY,CAAC,UAAU,CAAC,CAAA;AACjC,CAAC;AAFD,wBAEC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "temba",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.2",
|
|
4
4
|
"description": "Get a simple MongoDB REST API with zero coding in less than 30 seconds (seriously).",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -18,27 +18,27 @@
|
|
|
18
18
|
"author": "Bouwe (https://bouwe.io)",
|
|
19
19
|
"license": "ISC",
|
|
20
20
|
"devDependencies": {
|
|
21
|
-
"@types/cors": "^2.8.
|
|
22
|
-
"@types/express": "^4.17.
|
|
23
|
-
"@types/jest": "^
|
|
24
|
-
"@types/morgan": "^1.9.
|
|
25
|
-
"@types/supertest": "^2.0.
|
|
26
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
27
|
-
"@typescript-eslint/parser": "^
|
|
28
|
-
"eslint": "^8.
|
|
29
|
-
"eslint-config-prettier": "^8.
|
|
30
|
-
"jest": "^
|
|
31
|
-
"jest-extended": "^0.
|
|
32
|
-
"prettier": "^
|
|
33
|
-
"supertest": "^6.
|
|
34
|
-
"ts-jest": "^
|
|
35
|
-
"typescript": "^
|
|
21
|
+
"@types/cors": "^2.8.13",
|
|
22
|
+
"@types/express": "^4.17.17",
|
|
23
|
+
"@types/jest": "^29.5.3",
|
|
24
|
+
"@types/morgan": "^1.9.4",
|
|
25
|
+
"@types/supertest": "^2.0.12",
|
|
26
|
+
"@typescript-eslint/eslint-plugin": "^6.0.0",
|
|
27
|
+
"@typescript-eslint/parser": "^6.0.0",
|
|
28
|
+
"eslint": "^8.45.0",
|
|
29
|
+
"eslint-config-prettier": "^8.8.0",
|
|
30
|
+
"jest": "^29.6.1",
|
|
31
|
+
"jest-extended": "^4.0.0",
|
|
32
|
+
"prettier": "^3.0.0",
|
|
33
|
+
"supertest": "^6.3.3",
|
|
34
|
+
"ts-jest": "^29.1.1",
|
|
35
|
+
"typescript": "^5.1.6"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@rakered/mongo": "^1.6.0",
|
|
39
39
|
"connect-pause": "^0.1.0",
|
|
40
40
|
"cors": "^2.8.5",
|
|
41
|
-
"express": "^4.
|
|
41
|
+
"express": "^4.18.2",
|
|
42
42
|
"morgan": "^1.10.0"
|
|
43
43
|
}
|
|
44
44
|
}
|
package/queries/queries.d.ts
CHANGED
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
declare function createQueries(connectionString: any): {
|
|
2
|
+
connectToDatabase: () => Promise<void>;
|
|
3
|
+
getAll: (resourceName: any) => Promise<any>;
|
|
4
|
+
getById: (resourceName: any, id: any) => Promise<any>;
|
|
5
|
+
create: (resourceName: any, item: any) => Promise<any>;
|
|
6
|
+
update: (resourceName: any, item: any) => Promise<any>;
|
|
7
|
+
deleteById: (resourceName: any, id: any) => Promise<void>;
|
|
8
|
+
deleteAll: (resourceName: any) => Promise<void>;
|
|
9
|
+
} | {
|
|
2
10
|
connectToDatabase: () => void;
|
|
3
11
|
getAll: (resourceName: any) => Promise<unknown>;
|
|
4
12
|
getById: (resourceName: any, id: any) => Promise<unknown>;
|
package/routes/types.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
1
|
+
export type ValidatorCallback = (resourceName: string, requestBody: unknown) => void | string | object;
|
|
2
|
+
export type RequestBodyValidator = {
|
|
3
3
|
post?: ValidatorCallback;
|
|
4
4
|
patch?: ValidatorCallback;
|
|
5
5
|
put?: ValidatorCallback;
|
|
6
6
|
};
|
|
7
|
-
export
|
|
7
|
+
export type ResponseBodyInterceptor = (resourceName: string, responseBody: unknown, id?: string) => unknown;
|