@kollors/deep-json-server 0.5.0 → 0.7.0
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 +229 -113
- package/README.ru.md +229 -113
- package/index.js +12 -2
- package/package.json +9 -2
- package/src/cli.js +45 -44
- package/src/config.js +141 -35
- package/src/constants.js +1 -1
- package/src/database.js +40 -20
- package/src/files.js +445 -90
- package/src/openapi/config.js +15 -1
- package/src/openapi/document.js +124 -61
- package/src/openapi/index.js +29 -18
- package/src/query/filter.js +11 -10
- package/src/query/pagination.js +3 -9
- package/src/relation-metadata.js +1 -0
- package/src/server.js +104 -92
- package/src/utils.js +30 -0
- package/types/index.d.ts +21 -2
- package/types/src/config.d.ts +73 -0
- package/types/src/constants.d.ts +1 -1
- package/types/src/database.d.ts +28 -3
- package/types/src/files.d.ts +63 -4
- package/types/src/openapi/config.d.ts +1 -1
- package/types/src/openapi/document.d.ts +6 -7
- package/types/src/openapi/index.d.ts +9 -14
- package/types/src/query/pagination.d.ts +1 -6
- package/types/src/server.d.ts +12 -28
- package/types/src/utils.d.ts +8 -0
package/types/src/server.d.ts
CHANGED
|
@@ -1,30 +1,14 @@
|
|
|
1
|
+
export type OpenapiDocument = Record<string, unknown>;
|
|
2
|
+
export type ServerFacade = {
|
|
3
|
+
fastify: () => import('fastify').FastifyInstance;
|
|
4
|
+
openapi: () => Promise<OpenapiDocument>;
|
|
5
|
+
};
|
|
1
6
|
/**
|
|
2
|
-
* Creates
|
|
3
|
-
* @param {
|
|
4
|
-
* @
|
|
7
|
+
* Creates lazy Fastify and OpenAPI accessors from one configuration.
|
|
8
|
+
* @param {import('./config.js').DeepJsonServerConfig} config Server configuration.
|
|
9
|
+
* @param {{ files?: boolean }} [features] Optional feature switches.
|
|
10
|
+
* @returns {Promise<ServerFacade>} Server facade.
|
|
5
11
|
*/
|
|
6
|
-
export declare function createServer(
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
filesMetadataPath?: string;
|
|
10
|
-
logger?: boolean | Record<string, unknown>;
|
|
11
|
-
maxFileSize?: number;
|
|
12
|
-
maxPageSize?: number;
|
|
13
|
-
schemaPath?: string;
|
|
14
|
-
}): Promise<import('fastify').FastifyInstance>;
|
|
15
|
-
/**
|
|
16
|
-
* Creates and starts a Fastify server.
|
|
17
|
-
* @param {{ databasePath: string, filesDirectoryPath?: string, filesMetadataPath?: string, host?: string, logger?: boolean | Record<string, unknown>, maxFileSize?: number, maxPageSize?: number, port?: number, schemaPath?: string }} options Server options.
|
|
18
|
-
* @returns {Promise<import('fastify').FastifyInstance>} Listening Fastify server.
|
|
19
|
-
*/
|
|
20
|
-
export declare function startServer(options: {
|
|
21
|
-
databasePath: string;
|
|
22
|
-
filesDirectoryPath?: string;
|
|
23
|
-
filesMetadataPath?: string;
|
|
24
|
-
host?: string;
|
|
25
|
-
logger?: boolean | Record<string, unknown>;
|
|
26
|
-
maxFileSize?: number;
|
|
27
|
-
maxPageSize?: number;
|
|
28
|
-
port?: number;
|
|
29
|
-
schemaPath?: string;
|
|
30
|
-
}): Promise<import('fastify').FastifyInstance>;
|
|
12
|
+
export declare function createServer(config: import('./config.js').DeepJsonServerConfig, features?: {
|
|
13
|
+
files?: boolean;
|
|
14
|
+
}): Promise<ServerFacade>;
|
package/types/src/utils.d.ts
CHANGED
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
export declare const createHttpError: (statusCode: any, message: any) => Error;
|
|
2
|
+
/** @returns {<T>(operation: () => T | Promise<T>) => Promise<T>} Serialized operation scheduler. */
|
|
3
|
+
export declare const createSerialQueue: () => <T>(operation: () => T | Promise<T>) => Promise<T>;
|
|
4
|
+
/**
|
|
5
|
+
* Creates a random ID that is not currently in use.
|
|
6
|
+
* @param {(id: string) => boolean} isUsed Checks whether an ID already exists.
|
|
7
|
+
* @returns {string} Unique ID.
|
|
8
|
+
*/
|
|
9
|
+
export declare const createUniqueId: (isUsed: (id: string) => boolean) => string;
|
|
2
10
|
export declare const getResourceNames: (data: any) => string[];
|
|
3
11
|
export declare const isObject: (value: any) => boolean;
|
|
4
12
|
export declare const isSafeKey: (key: any) => boolean;
|