@openaddresses/batch-schema 9.4.0 → 10.0.1
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/.eslintrc.json +5 -47
- package/.github/workflows/release.yml +5 -2
- package/CHANGELOG.md +8 -0
- package/LICENSE +1 -1
- package/README.md +21 -17
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/api.js +46 -0
- package/dist/lib/api.js.map +1 -0
- package/{lib → dist/lib}/openapi.js +35 -29
- package/dist/lib/openapi.js.map +1 -0
- package/dist/lib/schema.js +237 -0
- package/dist/lib/schema.js.map +1 -0
- package/dist/lib/types.js +2 -0
- package/dist/lib/types.js.map +1 -0
- package/dist/test/schema.srv.test.js +98 -0
- package/dist/test/schema.srv.test.js.map +1 -0
- package/docs/assets/style.css +1354 -87
- package/docs/index.html +74 -792
- package/{routes/schema.js → lib/api.ts} +11 -4
- package/lib/openapi.ts +122 -0
- package/lib/schema.ts +293 -0
- package/lib/types.ts +32 -0
- package/package.json +16 -11
- package/test/{schema.srv.test.js → schema.srv.test.ts} +9 -20
- package/tsconfig.json +27 -0
- package/docs/assets/anchor.js +0 -350
- package/docs/assets/bass-addons.css +0 -12
- package/docs/assets/bass.css +0 -544
- package/docs/assets/fonts/EOT/SourceCodePro-Bold.eot +0 -0
- package/docs/assets/fonts/EOT/SourceCodePro-Regular.eot +0 -0
- package/docs/assets/fonts/LICENSE.txt +0 -93
- package/docs/assets/fonts/OTF/SourceCodePro-Bold.otf +0 -0
- package/docs/assets/fonts/OTF/SourceCodePro-Regular.otf +0 -0
- package/docs/assets/fonts/TTF/SourceCodePro-Bold.ttf +0 -0
- package/docs/assets/fonts/TTF/SourceCodePro-Regular.ttf +0 -0
- package/docs/assets/fonts/WOFF/OTF/SourceCodePro-Bold.otf.woff +0 -0
- package/docs/assets/fonts/WOFF/OTF/SourceCodePro-Regular.otf.woff +0 -0
- package/docs/assets/fonts/WOFF/TTF/SourceCodePro-Bold.ttf.woff +0 -0
- package/docs/assets/fonts/WOFF/TTF/SourceCodePro-Regular.ttf.woff +0 -0
- package/docs/assets/fonts/WOFF2/OTF/SourceCodePro-Bold.otf.woff2 +0 -0
- package/docs/assets/fonts/WOFF2/OTF/SourceCodePro-Regular.otf.woff2 +0 -0
- package/docs/assets/fonts/WOFF2/TTF/SourceCodePro-Bold.ttf.woff2 +0 -0
- package/docs/assets/fonts/WOFF2/TTF/SourceCodePro-Regular.ttf.woff2 +0 -0
- package/docs/assets/fonts/source-code-pro.css +0 -23
- package/docs/assets/github.css +0 -123
- package/docs/assets/site.js +0 -168
- package/docs/assets/split.css +0 -15
- package/docs/assets/split.js +0 -782
- package/lib/middleware.js +0 -159
- package/lib/param.js +0 -29
- package/lib/schema.js +0 -254
- package/schema/req.query.ListSchema.json +0 -25
- package/schema/res.ListSchema.json +0 -47
- package/test/schema.test.js +0 -33
- /package/{index.js → index.ts} +0 -0
package/.eslintrc.json
CHANGED
|
@@ -1,52 +1,10 @@
|
|
|
1
1
|
{
|
|
2
|
-
"extends": "eslint:recommended",
|
|
2
|
+
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
|
|
3
|
+
"parser": "@typescript-eslint/parser",
|
|
4
|
+
"plugins": ["@typescript-eslint"],
|
|
3
5
|
"root": true,
|
|
4
|
-
"env": {
|
|
5
|
-
"node": true
|
|
6
|
-
},
|
|
7
|
-
"globals": {
|
|
8
|
-
"Map": true,
|
|
9
|
-
"Promise": true
|
|
10
|
-
},
|
|
11
|
-
"parserOptions": {
|
|
12
|
-
"ecmaVersion": 13,
|
|
13
|
-
"sourceType": "module"
|
|
14
|
-
},
|
|
15
|
-
"plugins": [ "node" ],
|
|
16
6
|
"rules": {
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"no-var": "error",
|
|
20
|
-
"prefer-const": "error",
|
|
21
|
-
"array-bracket-spacing": [ "error", "never" ],
|
|
22
|
-
"comma-dangle": [ "error", "never" ],
|
|
23
|
-
"computed-property-spacing": [ "error", "never" ],
|
|
24
|
-
"eol-last": "error",
|
|
25
|
-
"eqeqeq": [ "error", "smart" ],
|
|
26
|
-
"indent": [ "error", 4, { "SwitchCase": 1 } ],
|
|
27
|
-
"no-confusing-arrow": [ "error", { "allowParens": false } ],
|
|
28
|
-
"no-extend-native": "error",
|
|
29
|
-
"no-mixed-spaces-and-tabs": "error",
|
|
30
|
-
"func-call-spacing": [ "error", "never" ],
|
|
31
|
-
"no-trailing-spaces": "error",
|
|
32
|
-
"no-unused-vars": "error",
|
|
33
|
-
"no-use-before-define": [ "error", "nofunc" ],
|
|
34
|
-
"object-curly-spacing": [ "error", "always" ],
|
|
35
|
-
"prefer-arrow-callback": "error",
|
|
36
|
-
"quotes": [ "error", "single", "avoid-escape" ],
|
|
37
|
-
"semi": [ "error", "always" ],
|
|
38
|
-
"space-infix-ops": "error",
|
|
39
|
-
"spaced-comment": [ "error", "always" ],
|
|
40
|
-
"keyword-spacing": [ "error", { "before": true, "after": true } ],
|
|
41
|
-
"template-curly-spacing": [ "error", "never" ],
|
|
42
|
-
"semi-spacing": "error",
|
|
43
|
-
"strict": "error",
|
|
44
|
-
"node/no-missing-require": "error",
|
|
45
|
-
"valid-jsdoc": ["error", {
|
|
46
|
-
"requireParamDescription": false,
|
|
47
|
-
"requireReturnDescription": false,
|
|
48
|
-
"requireReturnType": false,
|
|
49
|
-
"requireReturn": false
|
|
50
|
-
}]
|
|
7
|
+
"@typescript-eslint/ban-ts-comment": 1,
|
|
8
|
+
"@typescript-eslint/no-explicit-any": 1
|
|
51
9
|
}
|
|
52
10
|
}
|
|
@@ -9,13 +9,13 @@ jobs:
|
|
|
9
9
|
build:
|
|
10
10
|
runs-on: ubuntu-latest
|
|
11
11
|
steps:
|
|
12
|
-
- uses: actions/checkout@
|
|
12
|
+
- uses: actions/checkout@v3
|
|
13
13
|
|
|
14
14
|
- name: Get tag
|
|
15
15
|
id: tag
|
|
16
16
|
uses: dawidd6/action-get-tag@v1
|
|
17
17
|
|
|
18
|
-
- uses: actions/setup-node@
|
|
18
|
+
- uses: actions/setup-node@v4
|
|
19
19
|
with:
|
|
20
20
|
node-version: 18
|
|
21
21
|
registry-url: https://registry.npmjs.org/
|
|
@@ -23,6 +23,9 @@ jobs:
|
|
|
23
23
|
- name: npm install
|
|
24
24
|
run: npm install
|
|
25
25
|
|
|
26
|
+
- name: npm build
|
|
27
|
+
run: npm run build
|
|
28
|
+
|
|
26
29
|
- name: npm publish
|
|
27
30
|
run: npm publish
|
|
28
31
|
env:
|
package/CHANGELOG.md
CHANGED
|
@@ -10,6 +10,14 @@
|
|
|
10
10
|
|
|
11
11
|
## Version History
|
|
12
12
|
|
|
13
|
+
### v10.0.1
|
|
14
|
+
|
|
15
|
+
- :bug: Include dist files in npm bundle
|
|
16
|
+
|
|
17
|
+
### v10.0.0
|
|
18
|
+
|
|
19
|
+
- :rocket: Very rough support for Typescript based routes
|
|
20
|
+
|
|
13
21
|
### v9.4.0
|
|
14
22
|
|
|
15
23
|
- :rocket: Add support for `private` key which will hide endpoint in swagger
|
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<h1 align=center>Batch-Schema</h1>
|
|
2
2
|
|
|
3
|
-
<p align=center>Express Plugin for
|
|
3
|
+
<p align=center>Express Plugin for [TypeBox](https://github.com/sinclairzx81/typebox) Request and Response Validation</p>
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
@@ -11,13 +11,14 @@ npm i @openaddresses/batch-schema
|
|
|
11
11
|
## Example Usage
|
|
12
12
|
|
|
13
13
|
```js
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
import express from 'express';
|
|
15
|
+
import Schema from '@openaddresses/batch-schema';
|
|
16
|
+
import { Type } from '@sinclair/typebox';
|
|
17
17
|
|
|
18
18
|
const app = express();
|
|
19
19
|
const schema = new Schema(express.Router(), {
|
|
20
|
-
|
|
20
|
+
logging: true, // Enable Morgan Logging
|
|
21
|
+
limit: 50 // Body size for parsing JSON
|
|
21
22
|
});
|
|
22
23
|
|
|
23
24
|
app.use('/api', schema.router);
|
|
@@ -26,22 +27,25 @@ server();
|
|
|
26
27
|
|
|
27
28
|
async function server() {
|
|
28
29
|
await schema.post('/api/:param1/:param2', {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
query: Type.Object({
|
|
31
|
+
example: Type.Optional(Type.Uppercase(Type.String()))
|
|
32
|
+
}),
|
|
33
|
+
params: Type.Object({
|
|
34
|
+
param1: Type.String(),
|
|
35
|
+
param2: Type.Number(),
|
|
36
|
+
}),
|
|
37
|
+
body: Type.Object({
|
|
38
|
+
username: Type.String(),
|
|
39
|
+
password: Type.String(),
|
|
40
|
+
}),
|
|
41
|
+
res: Type.Object({
|
|
42
|
+
token: Type.String()
|
|
43
|
+
}),
|
|
34
44
|
}, (req, res) => {
|
|
35
45
|
return res.json({
|
|
36
|
-
|
|
46
|
+
token: 'I only return if the request meets the query & body schemas'
|
|
37
47
|
});
|
|
38
48
|
});
|
|
39
|
-
|
|
40
|
-
// Handle Unmatched Routes
|
|
41
|
-
schema.not_found();
|
|
42
|
-
|
|
43
|
-
// Handle Validation Errors => JSON Middleware
|
|
44
|
-
schema.error();
|
|
45
49
|
}
|
|
46
50
|
```
|
|
47
51
|
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAErC,eAAe,MAAM,CAAC"}
|
package/dist/lib/api.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import Err from '@openaddresses/batch-error';
|
|
2
|
+
import { OpenAPIV3 as Doc } from 'openapi-types';
|
|
3
|
+
import { Type } from '@sinclair/typebox';
|
|
4
|
+
export default async function router(schema) {
|
|
5
|
+
await schema.get('/schema', {
|
|
6
|
+
query: Type.Object({
|
|
7
|
+
method: Type.Optional(Type.Uppercase(Type.Enum(Doc.HttpMethods))),
|
|
8
|
+
url: Type.Optional(Type.String())
|
|
9
|
+
}),
|
|
10
|
+
res: Type.Object({}),
|
|
11
|
+
description: `
|
|
12
|
+
List all JSON Schemas in use
|
|
13
|
+
With no parameters this API will return a list of all the endpoints that have a form of schema validation
|
|
14
|
+
If the url/method params are used, the schemas themselves are returned
|
|
15
|
+
|
|
16
|
+
Note: If url or method params are used, they must be used together
|
|
17
|
+
`
|
|
18
|
+
}, async (req, res) => {
|
|
19
|
+
try {
|
|
20
|
+
if (req.query.url && req.query.method) {
|
|
21
|
+
res.json(schema.query(req.query.method, req.query.url));
|
|
22
|
+
}
|
|
23
|
+
else if (req.query.url || req.query.method) {
|
|
24
|
+
throw new Err(400, null, 'url & method params must be used together');
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
return res.json(schema.list());
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
catch (err) {
|
|
31
|
+
return Err.respond(err, res);
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
await schema.get('/openapi', {
|
|
35
|
+
description: 'Return a OpenAPI Schema for the API',
|
|
36
|
+
res: Type.Object({})
|
|
37
|
+
}, async (req, res) => {
|
|
38
|
+
try {
|
|
39
|
+
return res.json(schema.docs.base);
|
|
40
|
+
}
|
|
41
|
+
catch (err) {
|
|
42
|
+
return Err.respond(err, res);
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=api.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.js","sourceRoot":"","sources":["../../lib/api.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,4BAA4B,CAAC;AAE7C,OAAO,EAAE,SAAS,IAAI,GAAG,EAAE,MAAM,eAAe,CAAA;AAChD,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CA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E;QACzB,WAAW,EAAE,qCAAqC;QAClD,GAAG,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;KACvB,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE;QAClB,IAAI,CAAC;YACD,OAAO,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACtC,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACX,OAAO,GAAG,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;QACjC,CAAC;IACL,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* @class
|
|
3
3
|
*/
|
|
4
4
|
export default class Docs {
|
|
5
|
+
base;
|
|
5
6
|
constructor(info) {
|
|
6
7
|
this.base = {
|
|
7
8
|
openapi: '3.0.3',
|
|
@@ -12,43 +13,38 @@ export default class Docs {
|
|
|
12
13
|
paths: {}
|
|
13
14
|
};
|
|
14
15
|
}
|
|
15
|
-
|
|
16
16
|
push(parsed, schemas) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
for (let sec of parsed[1].split('/')) {
|
|
17
|
+
const path = [];
|
|
18
|
+
for (let sec of parsed.path.split('/')) {
|
|
21
19
|
for (const lit of ['.', '-']) { // These chars are used literally and can't be part of a param name
|
|
22
20
|
const mini = [];
|
|
23
21
|
for (const s of sec.split(lit)) {
|
|
24
|
-
if (s[0] === ':')
|
|
25
|
-
|
|
22
|
+
if (s[0] === ':')
|
|
23
|
+
mini.push(`{${s}}`);
|
|
24
|
+
else
|
|
25
|
+
mini.push(s);
|
|
26
26
|
}
|
|
27
27
|
sec = mini.join(lit);
|
|
28
28
|
}
|
|
29
29
|
path.push(sec);
|
|
30
30
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
const pathstr = path.join('/');
|
|
32
|
+
// @ts-ignore
|
|
33
|
+
if (this.base.paths[pathstr] && this.base.paths[pathstr][parsed.method])
|
|
34
|
+
throw new Error(`Duplicate Path: ${parsed.method}: ${parsed.path}`);
|
|
34
35
|
if (!schemas.private) {
|
|
35
|
-
if (!this.base.paths[
|
|
36
|
-
|
|
37
|
-
if (this.base.paths[path][method]) throw new Error(`Duplicate Path: ${parsed.join(' ')}`);
|
|
38
|
-
|
|
36
|
+
if (!this.base.paths[pathstr])
|
|
37
|
+
this.base.paths[pathstr] = {};
|
|
39
38
|
const document = {
|
|
40
39
|
summary: schemas.description || 'No Description',
|
|
41
|
-
tags: [schemas.group || 'Default'],
|
|
42
40
|
parameters: [],
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
description: 'Successful Response'
|
|
46
|
-
}
|
|
47
|
-
}
|
|
41
|
+
tags: [schemas.group || 'Default'],
|
|
42
|
+
responses: {}
|
|
48
43
|
};
|
|
49
|
-
|
|
50
44
|
for (const key in schemas) {
|
|
51
45
|
if (key[0] === ':') {
|
|
46
|
+
if (!document.parameters)
|
|
47
|
+
document.parameters = [];
|
|
52
48
|
document.parameters.push({
|
|
53
49
|
in: 'path',
|
|
54
50
|
name: key,
|
|
@@ -59,10 +55,11 @@ export default class Docs {
|
|
|
59
55
|
});
|
|
60
56
|
}
|
|
61
57
|
}
|
|
62
|
-
|
|
63
58
|
if (schemas.query && schemas.query.type === 'object') {
|
|
64
59
|
for (const name in (schemas.query.properties || {})) {
|
|
65
60
|
const query = schemas.query.properties[name];
|
|
61
|
+
if (!document.parameters)
|
|
62
|
+
document.parameters = [];
|
|
66
63
|
document.parameters.push({
|
|
67
64
|
in: 'query',
|
|
68
65
|
name,
|
|
@@ -72,15 +69,23 @@ export default class Docs {
|
|
|
72
69
|
});
|
|
73
70
|
}
|
|
74
71
|
}
|
|
75
|
-
|
|
76
72
|
if (schemas.res) {
|
|
77
|
-
|
|
78
|
-
'
|
|
79
|
-
|
|
73
|
+
const response = {
|
|
74
|
+
description: 'Successful Response',
|
|
75
|
+
content: {
|
|
76
|
+
'application/json': {
|
|
77
|
+
schema: schemas.res
|
|
78
|
+
}
|
|
80
79
|
}
|
|
81
80
|
};
|
|
81
|
+
document.responses['200'] = response;
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
const response = {
|
|
85
|
+
description: 'Successful Response'
|
|
86
|
+
};
|
|
87
|
+
document.responses['200'] = response;
|
|
82
88
|
}
|
|
83
|
-
|
|
84
89
|
if (schemas.body) {
|
|
85
90
|
document.requestBody = {
|
|
86
91
|
required: true,
|
|
@@ -91,8 +96,9 @@ export default class Docs {
|
|
|
91
96
|
}
|
|
92
97
|
};
|
|
93
98
|
}
|
|
94
|
-
|
|
95
|
-
this.base.paths[
|
|
99
|
+
// @ts-ignore
|
|
100
|
+
this.base.paths[pathstr][parsed.method] = document;
|
|
96
101
|
}
|
|
97
102
|
}
|
|
98
103
|
}
|
|
104
|
+
//# sourceMappingURL=openapi.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openapi.js","sourceRoot":"","sources":["../../lib/openapi.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,IAAI;IACrB,IAAI,CAAe;IAEnB,YAAY,IAIX;QACG,IAAI,CAAC,IAAI,GAAG;YACR,OAAO,EAAE,OAAO;YAChB,IAAI,EAAE,IAAI,IAAI;gBACV,KAAK,EAAE,gBAAgB;gBACvB,OAAO,EAAE,OAAO;aACnB;YACD,KAAK,EAAE,EAAE;SACZ,CAAC;IACN,CAAC;IAED,IAAI,CACA,MAGC,EACD,OAA8C;QAE9C,MAAM,IAAI,GAAkB,EAAE,CAAC;QAE/B,KAAK,IAAI,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC;YACrC,KAAK,MAAM,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC,mEAAmE;gBAC/F,MAAM,IAAI,GAAkB,EAAE,CAAC;gBAC/B,KAA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C;iBAAM,CAAC;gBACJ,MAAM,QAAQ,GAAwB;oBAClC,WAAW,EAAE,qBAAqB;iBACrC,CAAA;gBACD,QAAQ,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,QAAQ,CAAC;YACzC,CAAC;YAED,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;gBACf,QAAQ,CAAC,WAAW,GAAG;oBACnB,QAAQ,EAAE,IAAI;oBACd,OAAO,EAAE;wBACL,kBAAkB,EAAE;4BAChB,MAAM,EAAE,OAAO,CAAC,IAAI;yBACvB;qBACJ;iBACJ,CAAC;YACN,CAAC;YAED,aAAa;YACb,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,QAAQ,CAAC;QACvD,CAAC;IACL,CAAC;CACJ"}
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import morgan from 'morgan';
|
|
4
|
+
import bodyparser from 'body-parser';
|
|
5
|
+
import Err from '@openaddresses/batch-error';
|
|
6
|
+
import { OpenAPIV3 as Doc } from 'openapi-types';
|
|
7
|
+
import { TypeCompiler } from '@sinclair/typebox/compiler';
|
|
8
|
+
import SchemaAPI from './api.js';
|
|
9
|
+
import Docs from './openapi.js';
|
|
10
|
+
/**
|
|
11
|
+
* @class
|
|
12
|
+
*
|
|
13
|
+
* @param {Object} router Express Router Object
|
|
14
|
+
* @param {Object} opts Options Object
|
|
15
|
+
* @param {boolean|string} [opts.morgan=true] disable logging with false
|
|
16
|
+
* @param {number} [opts.limit=50] body size limit in mb
|
|
17
|
+
*
|
|
18
|
+
* @param {URL} [opts.apidoc] apidoc file location
|
|
19
|
+
*/
|
|
20
|
+
export default class Schemas {
|
|
21
|
+
router;
|
|
22
|
+
docs;
|
|
23
|
+
schemas;
|
|
24
|
+
constructor(router, opts = {}) {
|
|
25
|
+
if (!router)
|
|
26
|
+
throw new Error('Router Param Required');
|
|
27
|
+
this.router = router;
|
|
28
|
+
if (opts.logging !== false)
|
|
29
|
+
this.router.use(morgan('combined'));
|
|
30
|
+
this.router.use(bodyparser.urlencoded({ extended: true }));
|
|
31
|
+
this.router.use(bodyparser.json({ limit: `${opts.limit || 50}mb` }));
|
|
32
|
+
this.docs = new Docs();
|
|
33
|
+
this.schemas = new Map();
|
|
34
|
+
}
|
|
35
|
+
async api() {
|
|
36
|
+
await SchemaAPI(this);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Load routes directory. All .js files in the given directory will be loaded (ES Module)
|
|
40
|
+
* and the default method run
|
|
41
|
+
*
|
|
42
|
+
* @param {String} dirpath Directory to load
|
|
43
|
+
* @param {object} config Config Object
|
|
44
|
+
* @param {Object} opts Options Object
|
|
45
|
+
* @param {boolean} opts.silent Squelch StdOut
|
|
46
|
+
*/
|
|
47
|
+
async load(dirpath, config, opts = {
|
|
48
|
+
silent: false
|
|
49
|
+
}) {
|
|
50
|
+
if (dirpath instanceof URL)
|
|
51
|
+
dirpath = dirpath.pathname;
|
|
52
|
+
else
|
|
53
|
+
dirpath = String(dirpath);
|
|
54
|
+
const routes = [];
|
|
55
|
+
// Load dynamic routes directory
|
|
56
|
+
for (const r of fs.readdirSync(dirpath)) {
|
|
57
|
+
if (!opts.silent)
|
|
58
|
+
console.log(`ok - loaded routes/${r}`);
|
|
59
|
+
if (!['.ts', '.js'].includes(path.parse(r).ext))
|
|
60
|
+
continue;
|
|
61
|
+
routes.push((await import(path.resolve(dirpath, r))).default(this, config));
|
|
62
|
+
}
|
|
63
|
+
await Promise.all(routes);
|
|
64
|
+
this.not_found();
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Load a blueprint into the router
|
|
68
|
+
*
|
|
69
|
+
* @param {Object} bp_class Blueprint Class with blueprint() fn
|
|
70
|
+
* @param {object} config Config Object
|
|
71
|
+
* @param {Object} opts Options Object
|
|
72
|
+
* @param {boolean} opts.silent Squelch StdOut
|
|
73
|
+
*/
|
|
74
|
+
async blueprint(bp_class, config, opts = { silent: false }) {
|
|
75
|
+
if (!opts.silent)
|
|
76
|
+
console.log(`ok - loaded ${bp_class.name}`);
|
|
77
|
+
await bp_class.blueprint(this, config);
|
|
78
|
+
}
|
|
79
|
+
async get(path, opts = {}, handler) {
|
|
80
|
+
try {
|
|
81
|
+
this.docs.push({ method: Doc.HttpMethods.GET, path: path }, opts);
|
|
82
|
+
this.schemas.set(`GET ${path}`, opts);
|
|
83
|
+
const paramsValidation = opts.params && TypeCompiler.Compile(opts.params);
|
|
84
|
+
const queryValidation = opts.query && TypeCompiler.Compile(opts.query);
|
|
85
|
+
if (opts.body)
|
|
86
|
+
throw new Error(`Body not allowed`);
|
|
87
|
+
const _handler = (req, res, next) => {
|
|
88
|
+
const errors = [];
|
|
89
|
+
if (paramsValidation && !paramsValidation.Check(req.params))
|
|
90
|
+
errors.push({ type: 'Params', errors: Array.from(paramsValidation.Errors(req.params)) });
|
|
91
|
+
if (queryValidation && !queryValidation.Check(req.query))
|
|
92
|
+
errors.push({ type: 'Query', errors: Array.from(queryValidation.Errors(req.query)) });
|
|
93
|
+
if (errors.length)
|
|
94
|
+
return Err.respond(new Err(400, null, 'Validation Error'), res, errors);
|
|
95
|
+
return handler(req, res, next);
|
|
96
|
+
};
|
|
97
|
+
this.router.get(path, _handler);
|
|
98
|
+
}
|
|
99
|
+
catch (err) {
|
|
100
|
+
throw new Error(`Get: ${path}: ` + err);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
async delete(path, opts = {}, handler) {
|
|
104
|
+
try {
|
|
105
|
+
this.docs.push({ method: Doc.HttpMethods.DELETE, path: path }, opts);
|
|
106
|
+
this.schemas.set(`DELETE ${path}`, opts);
|
|
107
|
+
const paramsValidation = opts.params && TypeCompiler.Compile(opts.params);
|
|
108
|
+
const queryValidation = opts.query && TypeCompiler.Compile(opts.query);
|
|
109
|
+
if (opts.body)
|
|
110
|
+
throw new Error(`Body not allowed`);
|
|
111
|
+
const _handler = (req, res, next) => {
|
|
112
|
+
const errors = [];
|
|
113
|
+
if (paramsValidation && !paramsValidation.Check(req.params))
|
|
114
|
+
errors.push({ type: 'Params', errors: Array.from(paramsValidation.Errors(req.params)) });
|
|
115
|
+
if (queryValidation && !queryValidation.Check(req.query))
|
|
116
|
+
errors.push({ type: 'Query', errors: Array.from(queryValidation.Errors(req.query)) });
|
|
117
|
+
if (errors.length)
|
|
118
|
+
return Err.respond(new Err(400, null, 'Validation Error'), res, errors);
|
|
119
|
+
return handler(req, res, next);
|
|
120
|
+
};
|
|
121
|
+
this.router.get(path, _handler);
|
|
122
|
+
}
|
|
123
|
+
catch (err) {
|
|
124
|
+
throw new Error(`Delete: ${path}: ` + String(err));
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
async post(path, opts = {}, handler) {
|
|
128
|
+
try {
|
|
129
|
+
this.docs.push({ method: Doc.HttpMethods.POST, path: path }, opts);
|
|
130
|
+
this.schemas.set(`POST ${path}`, opts);
|
|
131
|
+
const paramsValidation = opts.params && TypeCompiler.Compile(opts.params);
|
|
132
|
+
const queryValidation = opts.query && TypeCompiler.Compile(opts.query);
|
|
133
|
+
const bodyValidation = opts.body && TypeCompiler.Compile(opts.body);
|
|
134
|
+
const _handler = (req, res, next) => {
|
|
135
|
+
const errors = [];
|
|
136
|
+
if (paramsValidation && !paramsValidation.Check(req.params))
|
|
137
|
+
errors.push({ type: 'Params', errors: Array.from(paramsValidation.Errors(req.params)) });
|
|
138
|
+
if (queryValidation && !queryValidation.Check(req.query))
|
|
139
|
+
errors.push({ type: 'Query', errors: Array.from(queryValidation.Errors(req.query)) });
|
|
140
|
+
if (bodyValidation && !bodyValidation.Check(req.body))
|
|
141
|
+
errors.push({ type: 'Body', errors: Array.from(bodyValidation.Errors(req.body)) });
|
|
142
|
+
if (errors.length)
|
|
143
|
+
return Err.respond(new Err(400, null, 'Validation Error'), res, errors);
|
|
144
|
+
return handler(req, res, next);
|
|
145
|
+
};
|
|
146
|
+
this.router.get(path, _handler);
|
|
147
|
+
}
|
|
148
|
+
catch (err) {
|
|
149
|
+
throw new Error(`Post: ${path}: ` + String(err));
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
async patch(path, opts = {}, handler) {
|
|
153
|
+
try {
|
|
154
|
+
this.docs.push({ method: Doc.HttpMethods.PATCH, path: path }, opts);
|
|
155
|
+
this.schemas.set(`PATCH ${path}`, opts);
|
|
156
|
+
const paramsValidation = opts.params && TypeCompiler.Compile(opts.params);
|
|
157
|
+
const queryValidation = opts.query && TypeCompiler.Compile(opts.query);
|
|
158
|
+
const bodyValidation = opts.body && TypeCompiler.Compile(opts.body);
|
|
159
|
+
const _handler = (req, res, next) => {
|
|
160
|
+
const errors = [];
|
|
161
|
+
if (paramsValidation && !paramsValidation.Check(req.params))
|
|
162
|
+
errors.push({ type: 'Params', errors: Array.from(paramsValidation.Errors(req.params)) });
|
|
163
|
+
if (queryValidation && !queryValidation.Check(req.query))
|
|
164
|
+
errors.push({ type: 'Query', errors: Array.from(queryValidation.Errors(req.query)) });
|
|
165
|
+
if (bodyValidation && !bodyValidation.Check(req.body))
|
|
166
|
+
errors.push({ type: 'Body', errors: Array.from(bodyValidation.Errors(req.body)) });
|
|
167
|
+
if (errors.length)
|
|
168
|
+
return Err.respond(new Err(400, null, 'Validation Error'), res, errors);
|
|
169
|
+
return handler(req, res, next);
|
|
170
|
+
};
|
|
171
|
+
this.router.get(path, _handler);
|
|
172
|
+
}
|
|
173
|
+
catch (err) {
|
|
174
|
+
throw new Error(`Patch: ${path}: ` + String(err));
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
async put(path, opts = {}, handler) {
|
|
178
|
+
try {
|
|
179
|
+
this.docs.push({ method: Doc.HttpMethods.PUT, path: path }, opts);
|
|
180
|
+
this.schemas.set(`PUT ${path}`, opts);
|
|
181
|
+
const paramsValidation = opts.params && TypeCompiler.Compile(opts.params);
|
|
182
|
+
const queryValidation = opts.query && TypeCompiler.Compile(opts.query);
|
|
183
|
+
const bodyValidation = opts.body && TypeCompiler.Compile(opts.body);
|
|
184
|
+
const _handler = (req, res, next) => {
|
|
185
|
+
const errors = [];
|
|
186
|
+
if (paramsValidation && !paramsValidation.Check(req.params))
|
|
187
|
+
errors.push({ type: 'Params', errors: Array.from(paramsValidation.Errors(req.params)) });
|
|
188
|
+
if (queryValidation && !queryValidation.Check(req.query))
|
|
189
|
+
errors.push({ type: 'Query', errors: Array.from(queryValidation.Errors(req.query)) });
|
|
190
|
+
if (bodyValidation && !bodyValidation.Check(req.body))
|
|
191
|
+
errors.push({ type: 'Body', errors: Array.from(bodyValidation.Errors(req.body)) });
|
|
192
|
+
if (errors.length)
|
|
193
|
+
return Err.respond(new Err(400, null, 'Validation Error'), res, errors);
|
|
194
|
+
return handler(req, res, next);
|
|
195
|
+
};
|
|
196
|
+
this.router.get(path, _handler);
|
|
197
|
+
}
|
|
198
|
+
catch (err) {
|
|
199
|
+
throw new Error(`Put: ${path}: ` + String(err));
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
not_found() {
|
|
203
|
+
this.router.all('*', (req, res) => {
|
|
204
|
+
return res.status(404).json({
|
|
205
|
+
status: 404,
|
|
206
|
+
message: 'API endpoint does not exist!',
|
|
207
|
+
messages: []
|
|
208
|
+
});
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
query(method, url) {
|
|
212
|
+
if (!this.schemas.has(`${method} ${url}`)) {
|
|
213
|
+
return {};
|
|
214
|
+
}
|
|
215
|
+
const schema = JSON.parse(JSON.stringify(this.schemas.get(`${method} ${url}`)));
|
|
216
|
+
return {
|
|
217
|
+
query: schema.query,
|
|
218
|
+
body: schema.body,
|
|
219
|
+
res: schema.res
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
list() {
|
|
223
|
+
const lite = {};
|
|
224
|
+
for (const key of this.schemas.keys()) {
|
|
225
|
+
const schema = this.schemas.get(key);
|
|
226
|
+
if (!schema)
|
|
227
|
+
continue;
|
|
228
|
+
lite[key] = {
|
|
229
|
+
body: !!schema.body,
|
|
230
|
+
query: !!schema.query,
|
|
231
|
+
res: !!schema.res
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
return lite;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../lib/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,UAAU,MAAM,aAAa,CAAC;AACrC,OAAO,GAAG,MAAM,4BAA4B,CAAC;AAE7C,OAAO,EAAE,SAAS,IAAI,GAAG,EAAE,MAAM,eAAe,CAAA;AAEhD,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAI1D,OAAO,SAAS,MAAM,UAAU,CAAC;AACjC,OAAO,IAAI,MAAM,cAAc,CAAC;AAIhC;;;;;;;;;GASG;AACH,MAAM,CAAC,OAAO,OAAO,OAAO;IACxB,MAAM,CAAS;IACf,IAAI,CAAO;IACX,OAAO,CAAoD;IAE3D,YAAY,MAAc,EAAE,OAGxB,EAAE;QACF,IAAI,CAAC,MAAM;YAAE,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAC;QAEtD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QAErB,IAAI,IAAI,CAAC,OAAO,KAAK,KAAK;YAAE,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC;QAChE,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;QAC3D,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,UAA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