equipped 5.0.0-alpha.3 → 5.0.0-alpha.5
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/CHANGELOG.md +9 -0
- package/lib/db/mongoose/changes.d.ts +0 -25
- package/lib/db/mongoose/index.d.ts +0 -25
- package/lib/db/mongoose/query.d.ts +0 -25
- package/lib/events/kafka.d.ts +1 -1
- package/lib/events/rabbit.d.ts +1 -1
- package/lib/listeners/emitter.d.ts +4 -1
- package/lib/listeners/emitter.js +1 -1
- package/lib/scripts/json-schema.js +1 -2
- package/lib/server/impls/base.d.ts +1 -3
- package/lib/server/impls/base.js +58 -13
- package/lib/server/impls/express.d.ts +0 -1
- package/lib/server/impls/express.js +5 -3
- package/lib/server/impls/fastify.d.ts +1 -3
- package/lib/server/impls/fastify.js +4 -3
- package/lib/server/middlewares/errorHandler.d.ts +1 -1
- package/lib/server/middlewares/notFoundHandler.d.ts +1 -1
- package/lib/server/middlewares/parseAuthUser.d.ts +1 -1
- package/lib/server/middlewares/requireAuthUser.d.ts +1 -1
- package/lib/server/middlewares/requireRefreshUser.d.ts +1 -1
- package/lib/server/requests.d.ts +0 -1
- package/lib/server/types.d.ts +8 -3
- package/lib/storage/index.d.ts +0 -1
- package/lib/utils/auth.d.ts +5 -5
- package/lib/utils/media.d.ts +0 -1
- package/lib/utils/utils.js +2 -2
- package/lib/validations/index.d.ts +63 -73
- package/lib/validations/index.js +2 -2
- package/package.json +1 -2
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
## [5.0.0-alpha.5](https://github.com/kevinand11/equipped/compare/v5.0.0-alpha.4...v5.0.0-alpha.5) (2024-06-26)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* route tag descriptions ([644ef9f](https://github.com/kevinand11/equipped/commit/644ef9f5f929b738aabc99f55d3c61af8a85266e))
|
|
11
|
+
|
|
12
|
+
## [5.0.0-alpha.4](https://github.com/kevinand11/equipped/compare/v5.0.0-alpha.3...v5.0.0-alpha.4) (2024-06-18)
|
|
13
|
+
|
|
5
14
|
## [5.0.0-alpha.3](https://github.com/kevinand11/equipped/compare/v5.0.0-alpha.2...v5.0.0-alpha.3) (2024-06-18)
|
|
6
15
|
|
|
7
16
|
## [5.0.0-alpha.2](https://github.com/kevinand11/equipped/compare/v5.0.0-alpha.1...v5.0.0-alpha.2) (2024-06-16)
|
|
@@ -1,28 +1,3 @@
|
|
|
1
|
-
/// <reference types="mongoose/types/aggregate" />
|
|
2
|
-
/// <reference types="mongoose/types/callback" />
|
|
3
|
-
/// <reference types="mongoose/types/collection" />
|
|
4
|
-
/// <reference types="mongoose/types/connection" />
|
|
5
|
-
/// <reference types="mongoose/types/cursor" />
|
|
6
|
-
/// <reference types="mongoose/types/document" />
|
|
7
|
-
/// <reference types="mongoose/types/error" />
|
|
8
|
-
/// <reference types="mongoose/types/expressions" />
|
|
9
|
-
/// <reference types="mongoose/types/helpers" />
|
|
10
|
-
/// <reference types="mongoose/types/middlewares" />
|
|
11
|
-
/// <reference types="mongoose/types/indexes" />
|
|
12
|
-
/// <reference types="mongoose/types/models" />
|
|
13
|
-
/// <reference types="mongoose/types/mongooseoptions" />
|
|
14
|
-
/// <reference types="mongoose/types/pipelinestage" />
|
|
15
|
-
/// <reference types="mongoose/types/populate" />
|
|
16
|
-
/// <reference types="mongoose/types/query" />
|
|
17
|
-
/// <reference types="mongoose/types/schemaoptions" />
|
|
18
|
-
/// <reference types="mongoose/types/schematypes" />
|
|
19
|
-
/// <reference types="mongoose/types/session" />
|
|
20
|
-
/// <reference types="mongoose/types/types" />
|
|
21
|
-
/// <reference types="mongoose/types/utility" />
|
|
22
|
-
/// <reference types="mongoose/types/validation" />
|
|
23
|
-
/// <reference types="mongoose/types/virtuals" />
|
|
24
|
-
/// <reference types="mongoose/types/inferschematype" />
|
|
25
|
-
/// <reference types="mongoose/types/inferrawdoctype" />
|
|
26
1
|
import mongoose from 'mongoose';
|
|
27
2
|
import { BaseEntity } from '../../structure';
|
|
28
3
|
import { DbChange, DbChangeCallbacks } from '../_instance';
|
|
@@ -1,28 +1,3 @@
|
|
|
1
|
-
/// <reference types="mongoose/types/aggregate" />
|
|
2
|
-
/// <reference types="mongoose/types/callback" />
|
|
3
|
-
/// <reference types="mongoose/types/collection" />
|
|
4
|
-
/// <reference types="mongoose/types/connection" />
|
|
5
|
-
/// <reference types="mongoose/types/cursor" />
|
|
6
|
-
/// <reference types="mongoose/types/document" />
|
|
7
|
-
/// <reference types="mongoose/types/error" />
|
|
8
|
-
/// <reference types="mongoose/types/expressions" />
|
|
9
|
-
/// <reference types="mongoose/types/helpers" />
|
|
10
|
-
/// <reference types="mongoose/types/middlewares" />
|
|
11
|
-
/// <reference types="mongoose/types/indexes" />
|
|
12
|
-
/// <reference types="mongoose/types/models" />
|
|
13
|
-
/// <reference types="mongoose/types/mongooseoptions" />
|
|
14
|
-
/// <reference types="mongoose/types/pipelinestage" />
|
|
15
|
-
/// <reference types="mongoose/types/populate" />
|
|
16
|
-
/// <reference types="mongoose/types/query" />
|
|
17
|
-
/// <reference types="mongoose/types/schemaoptions" />
|
|
18
|
-
/// <reference types="mongoose/types/schematypes" />
|
|
19
|
-
/// <reference types="mongoose/types/session" />
|
|
20
|
-
/// <reference types="mongoose/types/types" />
|
|
21
|
-
/// <reference types="mongoose/types/utility" />
|
|
22
|
-
/// <reference types="mongoose/types/validation" />
|
|
23
|
-
/// <reference types="mongoose/types/virtuals" />
|
|
24
|
-
/// <reference types="mongoose/types/inferschematype" />
|
|
25
|
-
/// <reference types="mongoose/types/inferrawdoctype" />
|
|
26
1
|
import mongoose from 'mongoose';
|
|
27
2
|
import { BaseEntity } from '../../structure';
|
|
28
3
|
import { Db, DbChangeCallbacks } from '../_instance';
|
|
@@ -1,28 +1,3 @@
|
|
|
1
|
-
/// <reference types="mongoose/types/aggregate" />
|
|
2
|
-
/// <reference types="mongoose/types/callback" />
|
|
3
|
-
/// <reference types="mongoose/types/collection" />
|
|
4
|
-
/// <reference types="mongoose/types/connection" />
|
|
5
|
-
/// <reference types="mongoose/types/cursor" />
|
|
6
|
-
/// <reference types="mongoose/types/document" />
|
|
7
|
-
/// <reference types="mongoose/types/error" />
|
|
8
|
-
/// <reference types="mongoose/types/expressions" />
|
|
9
|
-
/// <reference types="mongoose/types/helpers" />
|
|
10
|
-
/// <reference types="mongoose/types/middlewares" />
|
|
11
|
-
/// <reference types="mongoose/types/indexes" />
|
|
12
|
-
/// <reference types="mongoose/types/models" />
|
|
13
|
-
/// <reference types="mongoose/types/mongooseoptions" />
|
|
14
|
-
/// <reference types="mongoose/types/pipelinestage" />
|
|
15
|
-
/// <reference types="mongoose/types/populate" />
|
|
16
|
-
/// <reference types="mongoose/types/query" />
|
|
17
|
-
/// <reference types="mongoose/types/schemaoptions" />
|
|
18
|
-
/// <reference types="mongoose/types/schematypes" />
|
|
19
|
-
/// <reference types="mongoose/types/session" />
|
|
20
|
-
/// <reference types="mongoose/types/types" />
|
|
21
|
-
/// <reference types="mongoose/types/utility" />
|
|
22
|
-
/// <reference types="mongoose/types/validation" />
|
|
23
|
-
/// <reference types="mongoose/types/virtuals" />
|
|
24
|
-
/// <reference types="mongoose/types/inferschematype" />
|
|
25
|
-
/// <reference types="mongoose/types/inferrawdoctype" />
|
|
26
1
|
import mongoose from 'mongoose';
|
|
27
2
|
import { QueryParams, QueryResults } from '../query';
|
|
28
3
|
export declare const parseMongodbQueryParams: <Model>(model: mongoose.Model<Model>, params: QueryParams) => Promise<QueryResults<Model>>;
|
package/lib/events/kafka.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ export declare class KafkaEventBus extends EventBus {
|
|
|
3
3
|
#private;
|
|
4
4
|
constructor();
|
|
5
5
|
createPublisher<Event extends Events[keyof Events]>(topic: Event['topic']): {
|
|
6
|
-
publish: (data: Event[
|
|
6
|
+
publish: (data: Event["data"]) => Promise<boolean>;
|
|
7
7
|
};
|
|
8
8
|
createSubscriber<Event extends Events[keyof Events]>(topic: Event['topic'], onMessage: (data: Event['data']) => Promise<void>, options?: Partial<SubscribeOptions>): {
|
|
9
9
|
subscribe: () => Promise<void>;
|
package/lib/events/rabbit.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ export declare class RabbitEventBus extends EventBus {
|
|
|
3
3
|
#private;
|
|
4
4
|
constructor();
|
|
5
5
|
createPublisher<Event extends Events[keyof Events]>(topic: Event['topic']): {
|
|
6
|
-
publish: (data: Event[
|
|
6
|
+
publish: (data: Event["data"]) => Promise<boolean>;
|
|
7
7
|
};
|
|
8
8
|
createSubscriber<Event extends Events[keyof Events]>(topic: Event['topic'], onMessage: (data: Event['data']) => Promise<void>, options?: Partial<SubscribeOptions>): {
|
|
9
9
|
subscribe: () => Promise<void>;
|
|
@@ -14,7 +14,10 @@ export declare class Listener {
|
|
|
14
14
|
constructor(socket: io.Server, callers: SocketCallers);
|
|
15
15
|
start(): Promise<void>;
|
|
16
16
|
created<T extends BaseEntity<any, any>>(channels: string[], data: T): Promise<void>;
|
|
17
|
-
updated<T extends BaseEntity<any, any>>(channels: string[], after
|
|
17
|
+
updated<T extends BaseEntity<any, any>>(channels: string[], { after, before }: {
|
|
18
|
+
after: T;
|
|
19
|
+
before: T;
|
|
20
|
+
}): Promise<void>;
|
|
18
21
|
deleted<T extends BaseEntity<any, any>>(channels: string[], data: T): Promise<void>;
|
|
19
22
|
set callers(callers: SocketCallers);
|
|
20
23
|
register(channel: string, onJoin?: OnJoinFn): this;
|
package/lib/listeners/emitter.js
CHANGED
|
@@ -103,7 +103,7 @@ class Listener {
|
|
|
103
103
|
async created(channels, data) {
|
|
104
104
|
await __classPrivateFieldGet(this, _Listener_instances, "m", _Listener_emit).call(this, channels, EmitTypes.created, { after: data.toJSON(), before: null });
|
|
105
105
|
}
|
|
106
|
-
async updated(channels, after, before) {
|
|
106
|
+
async updated(channels, { after, before }) {
|
|
107
107
|
await __classPrivateFieldGet(this, _Listener_instances, "m", _Listener_emit).call(this, channels, EmitTypes.updated, { after: after.toJSON(), before: before.toJSON() });
|
|
108
108
|
}
|
|
109
109
|
async deleted(channels, data) {
|
|
@@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.generateJSONSchema =
|
|
26
|
+
exports.generateJSONSchema = generateJSONSchema;
|
|
27
27
|
const ts_oas_1 = __importStar(require("ts-oas"));
|
|
28
28
|
const instance_1 = require("../instance");
|
|
29
29
|
const server_1 = require("../server");
|
|
@@ -100,7 +100,6 @@ function generateJSONSchema(patterns, paths, options) {
|
|
|
100
100
|
return acc;
|
|
101
101
|
}, {});
|
|
102
102
|
}
|
|
103
|
-
exports.generateJSONSchema = generateJSONSchema;
|
|
104
103
|
function stripEmptyObjects(obj) {
|
|
105
104
|
return Object.entries(obj).reduce((acc, [key, value]) => {
|
|
106
105
|
if (!value || typeof value === 'object' && Object.keys(value).length === 0)
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/// <reference types="node/http" />
|
|
3
|
-
/// <reference types="pino-http" />
|
|
4
1
|
import http from 'http';
|
|
5
2
|
import { OpenAPIV3_1 } from 'openapi-types';
|
|
6
3
|
import supertest from 'supertest';
|
|
@@ -20,6 +17,7 @@ export declare abstract class Server<Req = any, Res = any> {
|
|
|
20
17
|
protected server: http.Server;
|
|
21
18
|
protected staticPath: string;
|
|
22
19
|
protected settings: import("../../instance/settings").Settings;
|
|
20
|
+
protected openapiJsonUrl: string;
|
|
23
21
|
protected baseOpenapiDoc: OpenAPIV3_1.Document;
|
|
24
22
|
protected abstract onLoad(): Promise<void>;
|
|
25
23
|
protected abstract startServer(port: number): Promise<boolean>;
|
package/lib/server/impls/base.js
CHANGED
|
@@ -13,7 +13,7 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (
|
|
|
13
13
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
14
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
15
|
};
|
|
16
|
-
var _Server_instances, _Server_routesByPath, _Server_routesByKey, _Server_schemas, _Server_listener, _Server_regRoute;
|
|
16
|
+
var _Server_instances, _Server_routesByPath, _Server_routesByKey, _Server_schemas, _Server_listener, _Server_registeredTags, _Server_registerTag, _Server_regRoute;
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.Server = void 0;
|
|
19
19
|
const socket_io_1 = __importDefault(require("socket.io"));
|
|
@@ -22,6 +22,7 @@ const path_1 = __importDefault(require("path"));
|
|
|
22
22
|
const instance_1 = require("../../instance");
|
|
23
23
|
const listeners_1 = require("../../listeners");
|
|
24
24
|
const middlewares_1 = require("../middlewares");
|
|
25
|
+
const requests_1 = require("../requests");
|
|
25
26
|
const routes_1 = require("../routes");
|
|
26
27
|
class Server {
|
|
27
28
|
constructor(server) {
|
|
@@ -30,8 +31,10 @@ class Server {
|
|
|
30
31
|
_Server_routesByKey.set(this, new Map());
|
|
31
32
|
_Server_schemas.set(this, {});
|
|
32
33
|
_Server_listener.set(this, null);
|
|
34
|
+
_Server_registeredTags.set(this, {});
|
|
33
35
|
this.staticPath = path_1.default.join(process.cwd(), 'public');
|
|
34
36
|
this.settings = instance_1.Instance.get().settings;
|
|
37
|
+
this.openapiJsonUrl = `${this.settings.openapiDocsPath}/openapi.json`;
|
|
35
38
|
this.baseOpenapiDoc = {
|
|
36
39
|
openapi: '3.0.0',
|
|
37
40
|
info: { title: this.settings.appId, version: this.settings.openapiDocsVersion },
|
|
@@ -51,7 +54,8 @@ class Server {
|
|
|
51
54
|
in: 'header',
|
|
52
55
|
}
|
|
53
56
|
},
|
|
54
|
-
}
|
|
57
|
+
},
|
|
58
|
+
tags: [],
|
|
55
59
|
};
|
|
56
60
|
this.server = server;
|
|
57
61
|
}
|
|
@@ -81,15 +85,22 @@ class Server {
|
|
|
81
85
|
return (0, supertest_1.default)(this.server);
|
|
82
86
|
}
|
|
83
87
|
async start(port) {
|
|
88
|
+
this.addRoute({
|
|
89
|
+
method: 'get',
|
|
90
|
+
path: `${this.settings.openapiDocsPath}/index.html`,
|
|
91
|
+
handler: () => new requests_1.Response({
|
|
92
|
+
body: openapiHtml
|
|
93
|
+
.replaceAll('__API_TITLE__', this.settings.appId)
|
|
94
|
+
.replaceAll('__OPENAPI_JSON_URL__', this.openapiJsonUrl),
|
|
95
|
+
headers: { 'Content-Type': 'text/html' },
|
|
96
|
+
}),
|
|
97
|
+
hideSchema: true,
|
|
98
|
+
});
|
|
84
99
|
this.addRoute({
|
|
85
100
|
method: 'get',
|
|
86
101
|
path: '__health',
|
|
87
102
|
handler: async () => `${this.settings.appId} service running`,
|
|
88
|
-
|
|
89
|
-
response: {
|
|
90
|
-
200: { type: 'string' }
|
|
91
|
-
}
|
|
92
|
-
},
|
|
103
|
+
hideSchema: true,
|
|
93
104
|
});
|
|
94
105
|
const started = await this.startServer(port);
|
|
95
106
|
if (started)
|
|
@@ -98,25 +109,35 @@ class Server {
|
|
|
98
109
|
}
|
|
99
110
|
}
|
|
100
111
|
exports.Server = Server;
|
|
101
|
-
_Server_routesByPath = new WeakMap(), _Server_routesByKey = new WeakMap(), _Server_schemas = new WeakMap(), _Server_listener = new WeakMap(), _Server_instances = new WeakSet(),
|
|
112
|
+
_Server_routesByPath = new WeakMap(), _Server_routesByKey = new WeakMap(), _Server_schemas = new WeakMap(), _Server_listener = new WeakMap(), _Server_registeredTags = new WeakMap(), _Server_instances = new WeakSet(), _Server_registerTag = function _Server_registerTag(name, description) {
|
|
113
|
+
var _a;
|
|
114
|
+
if (__classPrivateFieldGet(this, _Server_registeredTags, "f")[name])
|
|
115
|
+
return;
|
|
116
|
+
__classPrivateFieldGet(this, _Server_registeredTags, "f")[name] = true;
|
|
117
|
+
(_a = this.baseOpenapiDoc).tags ?? (_a.tags = []);
|
|
118
|
+
this.baseOpenapiDoc.tags.push({ name, description });
|
|
119
|
+
}, _Server_regRoute = function _Server_regRoute(route) {
|
|
102
120
|
const middlewares = [middlewares_1.parseAuthUser, ...(route.middlewares ?? [])];
|
|
103
|
-
middlewares.forEach((m) => m.onSetup?.(route));
|
|
104
121
|
route.onSetupHandler?.(route);
|
|
122
|
+
middlewares.forEach((m) => m.onSetup?.(route));
|
|
105
123
|
route.onError?.onSetup?.(route);
|
|
106
124
|
const { method, path, handler, schema, security, onError, hideSchema = false } = route;
|
|
107
125
|
const pathKey = `(${method.toUpperCase()}) ${path}`;
|
|
108
126
|
const { key = pathKey } = route;
|
|
109
|
-
const
|
|
127
|
+
const groups = route.groups?.map((g) => typeof g === 'string' ? { name: g } : g) ?? [];
|
|
128
|
+
const groupName = groups.map((g) => g.name).join(' > ');
|
|
129
|
+
const groupDescription = groups.map((g) => g.description?.trim() ?? '').filter(Boolean).join('\n\n\n\n');
|
|
130
|
+
const scheme = Object.assign({}, schema, __classPrivateFieldGet(this, _Server_schemas, "f")[key]);
|
|
110
131
|
const fullRoute = {
|
|
111
132
|
method, middlewares, handler, key,
|
|
112
133
|
path: (0, routes_1.cleanPath)(path),
|
|
113
134
|
onError,
|
|
114
135
|
schema: {
|
|
115
136
|
...scheme,
|
|
137
|
+
...(scheme.title ? { summary: scheme.title } : {}),
|
|
116
138
|
hide: hideSchema,
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
description: route.descriptions?.join(' | '),
|
|
139
|
+
tags: groups.length ? [groupName] : undefined,
|
|
140
|
+
description: route.descriptions?.join('\n\n'),
|
|
120
141
|
security,
|
|
121
142
|
}
|
|
122
143
|
};
|
|
@@ -127,4 +148,28 @@ _Server_routesByPath = new WeakMap(), _Server_routesByKey = new WeakMap(), _Serv
|
|
|
127
148
|
__classPrivateFieldGet(this, _Server_routesByPath, "f").set(pathKey, fullRoute);
|
|
128
149
|
__classPrivateFieldGet(this, _Server_routesByKey, "f").set(key, fullRoute);
|
|
129
150
|
this.registerRoute(fullRoute);
|
|
151
|
+
__classPrivateFieldGet(this, _Server_instances, "m", _Server_registerTag).call(this, groupName, groupDescription);
|
|
130
152
|
};
|
|
153
|
+
const openapiHtml = `
|
|
154
|
+
<!doctype html>
|
|
155
|
+
<html>
|
|
156
|
+
<head>
|
|
157
|
+
<title>__API_TITLE__</title>
|
|
158
|
+
<meta charset="utf-8" />
|
|
159
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
160
|
+
<style>
|
|
161
|
+
.darklight-reference {
|
|
162
|
+
display: none;
|
|
163
|
+
}
|
|
164
|
+
</style>
|
|
165
|
+
</head>
|
|
166
|
+
<body>
|
|
167
|
+
<script id="api-reference" data-url="__OPENAPI_JSON_URL__"></script>
|
|
168
|
+
<script>
|
|
169
|
+
const configuration = { theme: 'purple' };
|
|
170
|
+
document.getElementById('api-reference').dataset.configuration = JSON.stringify(configuration);
|
|
171
|
+
</script>
|
|
172
|
+
<script src="https://cdn.jsdelivr.net/npm/@scalar/api-reference"></script>
|
|
173
|
+
</body>
|
|
174
|
+
</html>
|
|
175
|
+
`;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import express from 'express';
|
|
2
2
|
import { Defined } from '../../types';
|
|
3
|
-
import { Request, Response } from '../requests';
|
|
4
3
|
import { Route } from '../types';
|
|
5
4
|
import { FullRoute, Server } from './base';
|
|
6
5
|
export declare class ExpressServer extends Server<express.Request, express.Response> {
|
|
@@ -40,7 +40,7 @@ class ExpressServer extends base_1.Server {
|
|
|
40
40
|
const app = (0, express_1.default)();
|
|
41
41
|
super(http_1.default.createServer(app));
|
|
42
42
|
_ExpressServer_expressApp.set(this, void 0);
|
|
43
|
-
_ExpressServer_oapi.set(this, (0, openapi_1.default)(
|
|
43
|
+
_ExpressServer_oapi.set(this, (0, openapi_1.default)(this.openapiJsonUrl.replace('.json', ''), this.baseOpenapiDoc, { coerce: false }));
|
|
44
44
|
_ExpressServer_ref.set(this, (0, json_schema_resolver_1.default)({ clone: true }));
|
|
45
45
|
__classPrivateFieldSet(this, _ExpressServer_expressApp, app, "f");
|
|
46
46
|
app.disable('x-powered-by');
|
|
@@ -49,12 +49,14 @@ class ExpressServer extends base_1.Server {
|
|
|
49
49
|
app.use(express_1.default.json());
|
|
50
50
|
app.use(express_1.default.text());
|
|
51
51
|
app.use((0, cookie_parser_1.default)());
|
|
52
|
-
app.use(helmet_1.default
|
|
52
|
+
app.use((0, helmet_1.default)({
|
|
53
|
+
crossOriginResourcePolicy: { policy: 'cross-origin' },
|
|
54
|
+
contentSecurityPolicy: false
|
|
55
|
+
}));
|
|
53
56
|
app.use((0, cors_1.default)({ origin: '*' }));
|
|
54
57
|
app.use(express_1.default.urlencoded({ extended: false }));
|
|
55
58
|
app.use(express_1.default.static(this.staticPath));
|
|
56
59
|
app.use(__classPrivateFieldGet(this, _ExpressServer_oapi, "f"));
|
|
57
|
-
app.use(this.settings.openapiDocsPath, __classPrivateFieldGet(this, _ExpressServer_oapi, "f").swaggerui());
|
|
58
60
|
app.use((0, express_fileupload_1.default)({
|
|
59
61
|
limits: { fileSize: this.settings.maxFileUploadSizeInMb * 1024 * 1024 },
|
|
60
62
|
useTempFiles: false
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
/// <reference types="node/http" />
|
|
2
|
-
/// <reference types="pino-http" />
|
|
3
1
|
import { FastifyReply, FastifyRequest, preHandlerHookHandler, RouteHandlerMethod } from 'fastify';
|
|
4
2
|
import { Defined } from '../../types';
|
|
5
3
|
import { Request } from '../requests';
|
|
@@ -14,7 +12,7 @@ export declare class FastifyServer extends Server<FastifyRequest, FastifyReply>
|
|
|
14
12
|
protected parse(req: FastifyRequest, res: FastifyReply): Promise<Request<import("../types").Api<any, string, import("../types").MethodTypes, any, Record<string, boolean>, Record<string, string>, Record<string, any>, Record<string, string | string[]>, import("../types").SupportedStatusCodes>>>;
|
|
15
13
|
makeController(cb: Defined<Route['handler']>): RouteHandlerMethod;
|
|
16
14
|
makeMiddleware(cb: Defined<Route['middlewares']>[number]['cb']): preHandlerHookHandler<import("fastify").RawServerDefault, import("http").IncomingMessage, import("http").ServerResponse<import("http").IncomingMessage>, import("fastify").RouteGenericInterface, unknown, import("fastify").FastifySchema, import("fastify").FastifyTypeProviderDefault, import("fastify").FastifyBaseLogger>;
|
|
17
|
-
makeErrorMiddleware(cb: Defined<Route['onError']>['cb']): (error: import("fastify").FastifyError, request: FastifyRequest
|
|
15
|
+
makeErrorMiddleware(cb: Defined<Route['onError']>['cb']): (error: import("fastify").FastifyError, request: FastifyRequest, reply: FastifyReply) => void;
|
|
18
16
|
}
|
|
19
17
|
declare module 'fastify' {
|
|
20
18
|
interface FastifyRequest {
|
|
@@ -24,7 +24,6 @@ const multipart_1 = __importDefault(require("@fastify/multipart"));
|
|
|
24
24
|
const rate_limit_1 = __importDefault(require("@fastify/rate-limit"));
|
|
25
25
|
const static_1 = __importDefault(require("@fastify/static"));
|
|
26
26
|
const swagger_1 = __importDefault(require("@fastify/swagger"));
|
|
27
|
-
const swagger_ui_1 = __importDefault(require("@fastify/swagger-ui"));
|
|
28
27
|
const fastify_1 = __importDefault(require("fastify"));
|
|
29
28
|
const qs_1 = __importDefault(require("qs"));
|
|
30
29
|
const errors_1 = require("../../errors");
|
|
@@ -55,9 +54,11 @@ class FastifyServer extends base_1.Server {
|
|
|
55
54
|
app.register(cookie_1.default, {});
|
|
56
55
|
app.register(cors_1.default, { origin: '*' });
|
|
57
56
|
app.register(swagger_1.default, { openapi: this.baseOpenapiDoc });
|
|
58
|
-
app.
|
|
57
|
+
app.get(this.openapiJsonUrl, (_, res) => {
|
|
58
|
+
res.code(200).send(app.swagger({}));
|
|
59
|
+
});
|
|
59
60
|
app.register(formbody_1.default, { parser: (str) => qs_1.default.parse(str) });
|
|
60
|
-
app.register(helmet_1.default, { crossOriginResourcePolicy: { policy: 'cross-origin' } });
|
|
61
|
+
app.register(helmet_1.default, { crossOriginResourcePolicy: { policy: 'cross-origin' }, contentSecurityPolicy: false });
|
|
61
62
|
app.register(multipart_1.default, {
|
|
62
63
|
attachFieldsToBody: 'keyValues',
|
|
63
64
|
throwFileSizeLimit: false,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export declare const errorHandler: {
|
|
2
2
|
cb: import("../types").ErrorHandler<import("../types").Api<any, string, import("../types").MethodTypes, any, Record<string, boolean>, Record<string, string>, Record<string, any>, Record<string, string | string[]>, import("../types").SupportedStatusCodes>>;
|
|
3
|
-
onSetup?: import("../types").HandlerSetup
|
|
3
|
+
onSetup?: import("../types").HandlerSetup;
|
|
4
4
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export declare const notFoundHandler: {
|
|
2
2
|
cb: import("../types").RouteMiddlewareHandler<import("../types").Api<any, string, import("../types").MethodTypes, any, Record<string, boolean>, Record<string, string>, Record<string, any>, Record<string, string | string[]>, import("../types").SupportedStatusCodes>>;
|
|
3
|
-
onSetup?: import("../types").HandlerSetup
|
|
3
|
+
onSetup?: import("../types").HandlerSetup;
|
|
4
4
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export declare const parseAuthUser: {
|
|
2
2
|
cb: import("../types").RouteMiddlewareHandler<import("../types").Api<any, string, import("../types").MethodTypes, any, Record<string, boolean>, Record<string, string>, Record<string, any>, Record<string, string | string[]>, import("../types").SupportedStatusCodes>>;
|
|
3
|
-
onSetup?: import("../types").HandlerSetup
|
|
3
|
+
onSetup?: import("../types").HandlerSetup;
|
|
4
4
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export declare const requireAuthUser: {
|
|
2
2
|
cb: import("../types").RouteMiddlewareHandler<import("../types").Api<any, string, import("../types").MethodTypes, any, Record<string, boolean>, Record<string, string>, Record<string, any>, Record<string, string | string[]>, import("../types").SupportedStatusCodes>>;
|
|
3
|
-
onSetup?: import("../types").HandlerSetup
|
|
3
|
+
onSetup?: import("../types").HandlerSetup;
|
|
4
4
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export declare const requireRefreshUser: {
|
|
2
2
|
cb: import("../types").RouteMiddlewareHandler<import("../types").Api<any, string, import("../types").MethodTypes, any, Record<string, boolean>, Record<string, string>, Record<string, any>, Record<string, string | string[]>, import("../types").SupportedStatusCodes>>;
|
|
3
|
-
onSetup?: import("../types").HandlerSetup
|
|
3
|
+
onSetup?: import("../types").HandlerSetup;
|
|
4
4
|
};
|
package/lib/server/requests.d.ts
CHANGED
package/lib/server/types.d.ts
CHANGED
|
@@ -57,6 +57,11 @@ export type RouteMiddlewareHandler<Def extends Api = Api> = (req: Request<Def>)
|
|
|
57
57
|
export type HandlerSetup = (route: Route) => void;
|
|
58
58
|
export type RouteSchema = Omit<FastifySchema, 'tags' | 'security' | 'hide' | 'description'> & {
|
|
59
59
|
descriptions?: string[];
|
|
60
|
+
title?: string;
|
|
61
|
+
};
|
|
62
|
+
type RouteGroup = {
|
|
63
|
+
name: string;
|
|
64
|
+
description?: string;
|
|
60
65
|
};
|
|
61
66
|
export interface Route<Def extends ApiDef<AnyApi> = ApiDef<Api>> {
|
|
62
67
|
key?: Def['key'];
|
|
@@ -67,7 +72,7 @@ export interface Route<Def extends ApiDef<AnyApi> = ApiDef<Api>> {
|
|
|
67
72
|
middlewares?: ReturnType<typeof makeMiddleware>[];
|
|
68
73
|
onError?: ReturnType<typeof makeErrorMiddleware>;
|
|
69
74
|
schema?: RouteSchema;
|
|
70
|
-
groups?:
|
|
75
|
+
groups?: (RouteGroup | RouteGroup['name'])[];
|
|
71
76
|
descriptions?: string[];
|
|
72
77
|
hideSchema?: boolean;
|
|
73
78
|
security?: Record<string, string[]>[];
|
|
@@ -83,6 +88,6 @@ declare class MiddlewareHandler<Cb extends Function> {
|
|
|
83
88
|
private constructor();
|
|
84
89
|
static make<Cb extends Function>(cb: Cb, onSetup?: HandlerSetup): MiddlewareHandler<Cb>;
|
|
85
90
|
}
|
|
86
|
-
export declare const makeMiddleware: <Def extends Api
|
|
87
|
-
export declare const makeErrorMiddleware: <Def extends Api
|
|
91
|
+
export declare const makeMiddleware: <Def extends Api = Api<any, string, MethodTypes, any, Record<string, boolean>, Record<string, string>, Record<string, any>, Record<string, string | string[]>, SupportedStatusCodes>>(cb: RouteMiddlewareHandler<Def>, onSetup?: HandlerSetup | undefined) => MiddlewareHandler<RouteMiddlewareHandler<Def>>;
|
|
92
|
+
export declare const makeErrorMiddleware: <Def extends Api = Api<any, string, MethodTypes, any, Record<string, boolean>, Record<string, string>, Record<string, any>, Record<string, string | string[]>, SupportedStatusCodes>>(cb: ErrorHandler<Def>, onSetup?: HandlerSetup | undefined) => MiddlewareHandler<ErrorHandler<Def>>;
|
|
88
93
|
export {};
|
package/lib/storage/index.d.ts
CHANGED
package/lib/utils/auth.d.ts
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
export declare const signinWithGoogle: (idToken: string) => Promise<{
|
|
2
2
|
email: string;
|
|
3
|
-
email_verified:
|
|
3
|
+
email_verified: "true" | "false";
|
|
4
4
|
first_name: string;
|
|
5
5
|
last_name: string;
|
|
6
6
|
picture: string;
|
|
7
7
|
sub: string;
|
|
8
8
|
} & Record<string, any>>;
|
|
9
9
|
export declare const signinWithApple: (idToken: string) => Promise<{
|
|
10
|
-
email?: string
|
|
10
|
+
email?: string;
|
|
11
11
|
sub: string;
|
|
12
|
-
email_verified?: "
|
|
13
|
-
is_private_email?: "
|
|
12
|
+
email_verified?: "true" | "false";
|
|
13
|
+
is_private_email?: "true" | "false";
|
|
14
14
|
} & Record<string, any>>;
|
|
15
15
|
export declare const signinWithFacebook: (accessToken: string, fields?: string[]) => Promise<{
|
|
16
16
|
id: string;
|
|
17
17
|
email: string;
|
|
18
|
-
email_verified:
|
|
18
|
+
email_verified: "true" | "false";
|
|
19
19
|
name: string;
|
|
20
20
|
picture: {
|
|
21
21
|
data: {
|
package/lib/utils/media.d.ts
CHANGED
package/lib/utils/utils.js
CHANGED
|
@@ -3,7 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.Random = void 0;
|
|
7
|
+
exports.clone = clone;
|
|
7
8
|
const crypto_1 = __importDefault(require("crypto"));
|
|
8
9
|
class Random {
|
|
9
10
|
static string(length = 20) {
|
|
@@ -22,4 +23,3 @@ function clone(value) {
|
|
|
22
23
|
return value;
|
|
23
24
|
}
|
|
24
25
|
}
|
|
25
|
-
exports.clone = clone;
|
|
@@ -8,24 +8,24 @@ type Phone = {
|
|
|
8
8
|
number: string;
|
|
9
9
|
};
|
|
10
10
|
export declare const Schema: {
|
|
11
|
-
is: <T>(value: T, comparer?: (
|
|
12
|
-
in: <T_1>(values: readonly T_1[], comparer?: (
|
|
11
|
+
is: <T>(value: T, comparer?: (val: any, comp: T) => boolean, err?: string) => Validate.VCore<T>;
|
|
12
|
+
in: <T_1>(values: readonly T_1[], comparer?: (val: any, arrayItem: T_1) => boolean, err?: string) => Validate.VCore<T_1>;
|
|
13
13
|
or: <T_2 extends Validate.VCore<any>[]>(options: T_2, err?: string | undefined) => import("valleyed/lib/api/junctions").VOr<T_2>;
|
|
14
14
|
and: <I>(options: Validate.VCore<I>[], err?: string | undefined) => import("valleyed/lib/api/junctions").VAnd<I>;
|
|
15
15
|
string: (err?: string | undefined) => import("valleyed/lib/api/strings").VString;
|
|
16
|
-
discriminate: <D extends Record<string, Validate.VCore<any>>>(discriminator: (val: ExtractI<D[keyof D]>) => string, schemas: D, err?: string | undefined) => import("valleyed/lib/api/junctions").VDiscriminator<D>;
|
|
16
|
+
discriminate: <D extends Record<string, Validate.VCore<any>>>(discriminator: (val: import("valleyed/lib/api/base").ExtractI<D[keyof D]>) => string, schemas: D, err?: string | undefined) => import("valleyed/lib/api/junctions").VDiscriminator<D>;
|
|
17
17
|
number: (err?: string | undefined) => import("valleyed/lib/api/numbers").VNumber;
|
|
18
18
|
boolean: (err?: string | undefined) => import("valleyed/lib/api/booleans").VBoolean;
|
|
19
|
-
time: <T_3 extends
|
|
19
|
+
time: <T_3 extends import("valleyed/lib/api/times").Timeable = import("valleyed/lib/api/times").Timeable>(err?: string | undefined) => import("valleyed/lib/api/times").VTime<T_3>;
|
|
20
20
|
file: (err?: string | undefined) => import("valleyed/lib/api/files").VFile;
|
|
21
21
|
array: <I_1>(comparer: Validate.VCore<I_1>, err?: string | undefined) => import("valleyed/lib/api/arrays").VArray<I_1>;
|
|
22
22
|
tuple: <T_4 extends readonly Validate.VCore<any>[]>(schema: readonly [...T_4], err?: string | undefined) => import("valleyed/lib/api/tuples").VTuple<T_4>;
|
|
23
23
|
object: <T_5 extends Record<string, Validate.VCore<any>>>(schema: T_5, trim?: boolean | undefined, err?: string | undefined) => VObject<T_5>;
|
|
24
24
|
record: <VI>(vCom: Validate.VCore<VI>, err?: string | undefined) => import("valleyed/lib/api/records").VRecord<VI>;
|
|
25
25
|
map: <KI, VI_1>(kCom: Validate.VCore<KI>, vCom: Validate.VCore<VI_1>, err?: string | undefined) => import("valleyed/lib/api/records").VMap<KI, VI_1>;
|
|
26
|
-
null: (err?: string
|
|
27
|
-
undefined: (err?: string
|
|
28
|
-
instanceof: <T_6>(classDef: new () => T_6, err?: string
|
|
26
|
+
null: (err?: string) => Validate.VCore<null>;
|
|
27
|
+
undefined: (err?: string) => Validate.VCore<undefined>;
|
|
28
|
+
instanceof: <T_6>(classDef: new () => T_6, err?: string) => Validate.VCore<T_6>;
|
|
29
29
|
any: <T_7 = any>() => Validate.VCore<T_7>;
|
|
30
30
|
force: {
|
|
31
31
|
string: (err?: string | undefined) => import("valleyed/lib/api/strings").VString;
|
|
@@ -40,24 +40,24 @@ export declare const Validation: {
|
|
|
40
40
|
Validator: typeof Validate.Validator;
|
|
41
41
|
VCore: typeof Validate.VCore;
|
|
42
42
|
v: {
|
|
43
|
-
is: <T>(value: T, comparer?: (
|
|
44
|
-
in: <T_1>(values: readonly T_1[], comparer?: (
|
|
43
|
+
is: <T>(value: T, comparer?: (val: any, comp: T) => boolean, err?: string) => Validate.VCore<T>;
|
|
44
|
+
in: <T_1>(values: readonly T_1[], comparer?: (val: any, arrayItem: T_1) => boolean, err?: string) => Validate.VCore<T_1>;
|
|
45
45
|
or: <T_2 extends Validate.VCore<any>[]>(options: T_2, err?: string | undefined) => import("valleyed/lib/api/junctions").VOr<T_2>;
|
|
46
46
|
and: <I>(options: Validate.VCore<I>[], err?: string | undefined) => import("valleyed/lib/api/junctions").VAnd<I>;
|
|
47
47
|
string: (err?: string | undefined) => import("valleyed/lib/api/strings").VString;
|
|
48
|
-
discriminate: <D extends Record<string, Validate.VCore<any>>>(discriminator: (val: ExtractI<D[keyof D]>) => string, schemas: D, err?: string | undefined) => import("valleyed/lib/api/junctions").VDiscriminator<D>;
|
|
48
|
+
discriminate: <D extends Record<string, Validate.VCore<any>>>(discriminator: (val: import("valleyed/lib/api/base").ExtractI<D[keyof D]>) => string, schemas: D, err?: string | undefined) => import("valleyed/lib/api/junctions").VDiscriminator<D>;
|
|
49
49
|
number: (err?: string | undefined) => import("valleyed/lib/api/numbers").VNumber;
|
|
50
50
|
boolean: (err?: string | undefined) => import("valleyed/lib/api/booleans").VBoolean;
|
|
51
|
-
time: <T_3 extends
|
|
51
|
+
time: <T_3 extends import("valleyed/lib/api/times").Timeable = import("valleyed/lib/api/times").Timeable>(err?: string | undefined) => import("valleyed/lib/api/times").VTime<T_3>;
|
|
52
52
|
file: (err?: string | undefined) => import("valleyed/lib/api/files").VFile;
|
|
53
53
|
array: <I_1>(comparer: Validate.VCore<I_1>, err?: string | undefined) => import("valleyed/lib/api/arrays").VArray<I_1>;
|
|
54
54
|
tuple: <T_4 extends readonly Validate.VCore<any>[]>(schema: readonly [...T_4], err?: string | undefined) => import("valleyed/lib/api/tuples").VTuple<T_4>;
|
|
55
55
|
object: <T_5 extends Record<string, Validate.VCore<any>>>(schema: T_5, trim?: boolean | undefined, err?: string | undefined) => VObject<T_5>;
|
|
56
56
|
record: <VI>(vCom: Validate.VCore<VI>, err?: string | undefined) => import("valleyed/lib/api/records").VRecord<VI>;
|
|
57
57
|
map: <KI, VI_1>(kCom: Validate.VCore<KI>, vCom: Validate.VCore<VI_1>, err?: string | undefined) => import("valleyed/lib/api/records").VMap<KI, VI_1>;
|
|
58
|
-
null: (err?: string
|
|
59
|
-
undefined: (err?: string
|
|
60
|
-
instanceof: <T_6>(classDef: new () => T_6, err?: string
|
|
58
|
+
null: (err?: string) => Validate.VCore<null>;
|
|
59
|
+
undefined: (err?: string) => Validate.VCore<undefined>;
|
|
60
|
+
instanceof: <T_6>(classDef: new () => T_6, err?: string) => Validate.VCore<T_6>;
|
|
61
61
|
any: <T_7 = any>() => Validate.VCore<T_7>;
|
|
62
62
|
force: {
|
|
63
63
|
string: (err?: string | undefined) => import("valleyed/lib/api/strings").VString;
|
|
@@ -66,46 +66,46 @@ export declare const Validation: {
|
|
|
66
66
|
time: (err?: string | undefined) => import("valleyed/lib/api/times").VTime<Date>;
|
|
67
67
|
};
|
|
68
68
|
};
|
|
69
|
-
isEqualTo: <Type>(compare: Type, comparer?: (
|
|
70
|
-
isNotEqualTo: <Compare,
|
|
71
|
-
arrayContains: <
|
|
72
|
-
arrayNotContains: <
|
|
73
|
-
isString: (error?: string
|
|
74
|
-
isLengthOf: (length: number, stripHTMLTags?: boolean
|
|
75
|
-
isMinOf: (length: number, stripHTMLTags?: boolean
|
|
76
|
-
isMaxOf: (length: number, stripHTMLTags?: boolean
|
|
77
|
-
isEmail: (error?: string
|
|
78
|
-
isUrl: (error?: string
|
|
79
|
-
isNumber: (error?: string
|
|
80
|
-
isInt: (error?: string
|
|
81
|
-
isMoreThan: (compare: number, error?: string
|
|
82
|
-
isMoreThanOrEqualTo: (compare: number, error?: string
|
|
83
|
-
isLessThan: (compare: number, error?: string
|
|
84
|
-
isLessThanOrEqualTo: (compare: number, error?: string
|
|
85
|
-
isArray: (error?: string
|
|
86
|
-
hasLengthOf: <
|
|
87
|
-
hasMinOf: <
|
|
88
|
-
hasMaxOf: <
|
|
89
|
-
isArrayOf: <
|
|
90
|
-
isUndefined: (error?: string
|
|
91
|
-
isNull: (error?: string
|
|
92
|
-
isBoolean: (error?: string
|
|
93
|
-
isInstanceOf: <T>(classDef: new () => T, error?: string
|
|
69
|
+
isEqualTo: <Type>(compare: Type, comparer?: (val: any, compare: Type) => boolean, error?: string) => import("valleyed/lib/utils/rules").Rule<Type>;
|
|
70
|
+
isNotEqualTo: <Compare, Type>(compare: Compare, comparer?: (val: Type, compare: Compare) => boolean, error?: string) => import("valleyed/lib/utils/rules").Rule<Type>;
|
|
71
|
+
arrayContains: <Type>(array: Readonly<Type[]>, comparer?: (val: any, arrayItem: Type) => boolean, error?: string) => import("valleyed/lib/utils/rules").Rule<Type>;
|
|
72
|
+
arrayNotContains: <Compare, Type>(array: Readonly<Compare[]>, comparer?: (val: Type, arrayItem: Compare) => boolean, error?: string) => import("valleyed/lib/utils/rules").Rule<Type>;
|
|
73
|
+
isString: (error?: string) => import("valleyed/lib/utils/rules").Rule<any>;
|
|
74
|
+
isLengthOf: (length: number, stripHTMLTags?: boolean, error?: string) => import("valleyed/lib/utils/rules").Rule<string>;
|
|
75
|
+
isMinOf: (length: number, stripHTMLTags?: boolean, error?: string) => import("valleyed/lib/utils/rules").Rule<string>;
|
|
76
|
+
isMaxOf: (length: number, stripHTMLTags?: boolean, error?: string) => import("valleyed/lib/utils/rules").Rule<string>;
|
|
77
|
+
isEmail: (error?: string) => import("valleyed/lib/utils/rules").Rule<string>;
|
|
78
|
+
isUrl: (error?: string) => import("valleyed/lib/utils/rules").Rule<string>;
|
|
79
|
+
isNumber: (error?: string) => import("valleyed/lib/utils/rules").Rule<any>;
|
|
80
|
+
isInt: (error?: string) => import("valleyed/lib/utils/rules").Rule<any>;
|
|
81
|
+
isMoreThan: (compare: number, error?: string) => import("valleyed/lib/utils/rules").Rule<number>;
|
|
82
|
+
isMoreThanOrEqualTo: (compare: number, error?: string) => import("valleyed/lib/utils/rules").Rule<number>;
|
|
83
|
+
isLessThan: (compare: number, error?: string) => import("valleyed/lib/utils/rules").Rule<number>;
|
|
84
|
+
isLessThanOrEqualTo: (compare: number, error?: string) => import("valleyed/lib/utils/rules").Rule<number>;
|
|
85
|
+
isArray: (error?: string) => import("valleyed/lib/utils/rules").Rule<any>;
|
|
86
|
+
hasLengthOf: <Type>(length: number, error?: string) => import("valleyed/lib/utils/rules").Rule<Type[]>;
|
|
87
|
+
hasMinOf: <Type>(length: number, error?: string) => import("valleyed/lib/utils/rules").Rule<Type[]>;
|
|
88
|
+
hasMaxOf: <Type>(length: number, error?: string) => import("valleyed/lib/utils/rules").Rule<Type[]>;
|
|
89
|
+
isArrayOf: <Type>(comparer: (cur: Type, idx: number) => boolean, error?: string) => import("valleyed/lib/utils/rules").Rule<Type[]>;
|
|
90
|
+
isUndefined: (error?: string) => import("valleyed/lib/utils/rules").Rule<undefined>;
|
|
91
|
+
isNull: (error?: string) => import("valleyed/lib/utils/rules").Rule<null>;
|
|
92
|
+
isBoolean: (error?: string) => import("valleyed/lib/utils/rules").Rule<boolean>;
|
|
93
|
+
isInstanceOf: <T>(classDef: new () => T, error?: string) => import("valleyed/lib/utils/rules").Rule<T>;
|
|
94
94
|
fileMimeTypes: string[];
|
|
95
95
|
videoMimeTypes: string[];
|
|
96
96
|
audioMimeTypes: string[];
|
|
97
97
|
imageMimeTypes: string[];
|
|
98
|
-
isImage: (error?: string
|
|
99
|
-
isAudio: (error?: string
|
|
100
|
-
isVideo: (error?: string
|
|
101
|
-
isFile: (error?: string
|
|
102
|
-
isTuple: <
|
|
103
|
-
isRecord: <
|
|
104
|
-
isMap: <
|
|
105
|
-
isCustom: <
|
|
106
|
-
isTime: <
|
|
107
|
-
isLaterThan: <
|
|
108
|
-
isEarlierThan: <
|
|
98
|
+
isImage: (error?: string) => import("valleyed/lib/utils/rules").Rule<import("valleyed/lib/types").File>;
|
|
99
|
+
isAudio: (error?: string) => import("valleyed/lib/utils/rules").Rule<import("valleyed/lib/types").File>;
|
|
100
|
+
isVideo: (error?: string) => import("valleyed/lib/utils/rules").Rule<import("valleyed/lib/types").File>;
|
|
101
|
+
isFile: (error?: string) => import("valleyed/lib/utils/rules").Rule<import("valleyed/lib/types").File>;
|
|
102
|
+
isTuple: <T extends readonly ((v: any, idx: number) => boolean)[]>(comparer: Validate.GetMap<T>, error?: string) => import("valleyed/lib/utils/rules").Rule<{ [K in keyof T]: T[K] extends (v: infer V, idx: number) => boolean ? V : never; }>;
|
|
103
|
+
isRecord: <V>(com: (cur: V) => boolean, error?: string) => import("valleyed/lib/utils/rules").Rule<Record<string, V>>;
|
|
104
|
+
isMap: <K, V>(kCom: (cur: K) => boolean, vCom: (cur: V) => boolean, error?: string) => import("valleyed/lib/utils/rules").Rule<Map<K, V>>;
|
|
105
|
+
isCustom: <T>(validity: (v: T) => boolean, error?: string) => import("valleyed/lib/utils/rules").Rule<T>;
|
|
106
|
+
isTime: <T extends Validate.Timeable>(error?: string) => import("valleyed/lib/utils/rules").Rule<T>;
|
|
107
|
+
isLaterThan: <T extends Validate.Timeable>(compare: Validate.Timeable, error?: string) => import("valleyed/lib/utils/rules").Rule<T>;
|
|
108
|
+
isEarlierThan: <T extends Validate.Timeable>(compare: Validate.Timeable, error?: string) => import("valleyed/lib/utils/rules").Rule<T>;
|
|
109
109
|
ClassPropertiesWrapper: typeof Validate.ClassPropertiesWrapper;
|
|
110
110
|
Differ: typeof Validate.Differ;
|
|
111
111
|
capitalize: (text: string) => string;
|
|
@@ -115,46 +115,36 @@ export declare const Validation: {
|
|
|
115
115
|
original: string;
|
|
116
116
|
normalized: string;
|
|
117
117
|
}[];
|
|
118
|
-
formatNumber: (num: number, dp?: number
|
|
118
|
+
formatNumber: (num: number, dp?: number) => string;
|
|
119
119
|
pluralize: (count: number, singular: string, plural: string) => string;
|
|
120
120
|
getRandomValue: () => string;
|
|
121
|
-
groupBy: <
|
|
121
|
+
groupBy: <Type, Unique extends string | number>(array: Array<Type>, func: (item: Type) => Unique) => {
|
|
122
122
|
key: Unique;
|
|
123
|
-
values:
|
|
123
|
+
values: Type[];
|
|
124
124
|
}[];
|
|
125
125
|
getAlphabet: (num: number) => string;
|
|
126
|
-
addToArray: <
|
|
126
|
+
addToArray: <T>(array: T[], item: T, getKey: (a: T) => any, getComparer: (a: T) => number | string, asc?: boolean) => T[];
|
|
127
127
|
divideByZero: (num: number, den: number) => number;
|
|
128
128
|
getPercentage: (num: number, den: number) => number;
|
|
129
|
-
getRandomSample: <
|
|
130
|
-
shuffleArray: <
|
|
131
|
-
chunkArray: <
|
|
129
|
+
getRandomSample: <Type>(population: Array<Type>, n: number) => Type[];
|
|
130
|
+
shuffleArray: <Type>(array: Array<Type>) => Type[];
|
|
131
|
+
chunkArray: <T>(arr: T[], size: number) => T[][];
|
|
132
132
|
Geohash: typeof Validate.Geohash;
|
|
133
|
-
isValid: <
|
|
133
|
+
isValid: <T>(value: T, ignored?: boolean) => {
|
|
134
134
|
valid: true;
|
|
135
135
|
errors: string[];
|
|
136
|
-
value:
|
|
136
|
+
value: T;
|
|
137
137
|
ignored: boolean;
|
|
138
138
|
};
|
|
139
|
-
isInvalid: <
|
|
139
|
+
isInvalid: <T>(errors: string[], value: T) => {
|
|
140
140
|
valid: false;
|
|
141
141
|
errors: string[];
|
|
142
142
|
value: unknown;
|
|
143
143
|
ignored: boolean;
|
|
144
144
|
};
|
|
145
|
-
makeRule: <
|
|
146
|
-
makeSanitizer: <
|
|
147
|
-
check: <
|
|
148
|
-
valid: false;
|
|
149
|
-
errors: string[];
|
|
150
|
-
value: unknown;
|
|
151
|
-
ignored: boolean;
|
|
152
|
-
} | {
|
|
153
|
-
valid: true;
|
|
154
|
-
errors: string[];
|
|
155
|
-
value: T_18;
|
|
156
|
-
ignored: boolean;
|
|
157
|
-
};
|
|
145
|
+
makeRule: <T>(func: Validate.Rule<T>) => Validate.Rule<T>;
|
|
146
|
+
makeSanitizer: <T>(func: Validate.Sanitizer<T>) => (val: T) => T;
|
|
147
|
+
check: <T>(value: T, rules: Validate.Rule<T>[], options?: Partial<Validate.Options>) => ReturnType<Validate.Rule<T>>;
|
|
158
148
|
};
|
|
159
149
|
export declare function validate<T extends Record<string, VCore<any>>>(schema: T, value: unknown): ExtractI<VObject<T>>;
|
|
160
150
|
export declare function validate<T extends VCore<any>>(schema: T, value: unknown): ExtractI<T>;
|
package/lib/validations/index.js
CHANGED
|
@@ -23,7 +23,8 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.Hash = exports.
|
|
26
|
+
exports.Hash = exports.Validation = exports.Schema = void 0;
|
|
27
|
+
exports.validate = validate;
|
|
27
28
|
const bcrypt = __importStar(require("bcryptjs"));
|
|
28
29
|
const Validate = __importStar(require("valleyed"));
|
|
29
30
|
const errors_1 = require("../errors");
|
|
@@ -67,7 +68,6 @@ function validate(schema, value) {
|
|
|
67
68
|
throw new errors_1.ValidationError(Object.entries(errorsObject)
|
|
68
69
|
.map(([key, value]) => ({ field: key, messages: value })));
|
|
69
70
|
}
|
|
70
|
-
exports.validate = validate;
|
|
71
71
|
const hash = async (password) => {
|
|
72
72
|
password = password.trim();
|
|
73
73
|
if (!password)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "equipped",
|
|
3
|
-
"version": "5.0.0-alpha.
|
|
3
|
+
"version": "5.0.0-alpha.5",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -46,7 +46,6 @@
|
|
|
46
46
|
"@fastify/rate-limit": "^9.1.0",
|
|
47
47
|
"@fastify/static": "^7.0.4",
|
|
48
48
|
"@fastify/swagger": "^8.14.0",
|
|
49
|
-
"@fastify/swagger-ui": "^3.1.0",
|
|
50
49
|
"@wesleytodd/openapi": "^1.0.0",
|
|
51
50
|
"amqp-connection-manager": "^4.1.14",
|
|
52
51
|
"amqplib": "^0.10.4",
|