@medyll/idae-api 0.163.0 → 0.165.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/LICENSE +21 -0
- package/dist/__tests__/helpers/testUtils.d.ts +13 -13
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/server/IdaeApi.d.ts +1 -2
- package/dist/server/middleware/authMiddleware.d.ts +1 -1
- package/dist/server/middleware/authorizationMiddleware.d.ts +1 -1
- package/dist/server/middleware/databaseMiddleware.d.ts +1 -1
- package/dist/server/middleware/tenantContextMiddleware.d.ts +1 -1
- package/dist/server/middleware/validationLayer.d.ts +1 -1
- package/package.json +20 -21
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 medyll
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -31,7 +31,7 @@ export declare function createMockResponse(): {
|
|
|
31
31
|
/**
|
|
32
32
|
* Create a mock NextFunction
|
|
33
33
|
*/
|
|
34
|
-
export declare function createMockNextFunction(): import("vitest").Mock<(err?: any) => void>;
|
|
34
|
+
export declare function createMockNextFunction(): import("vitest/index.cjs").Mock<(err?: any) => void>;
|
|
35
35
|
/**
|
|
36
36
|
* Create a complete mock middleware context
|
|
37
37
|
*/
|
|
@@ -52,7 +52,7 @@ export declare function createMockMiddlewareContext(overrides?: any): {
|
|
|
52
52
|
responseData: any;
|
|
53
53
|
headers: Map<string, string>;
|
|
54
54
|
};
|
|
55
|
-
next: import("vitest").Mock<(err?: any) => void>;
|
|
55
|
+
next: import("vitest/index.cjs").Mock<(err?: any) => void>;
|
|
56
56
|
};
|
|
57
57
|
/**
|
|
58
58
|
* Wait for async operations to complete
|
|
@@ -62,24 +62,24 @@ export declare function waitFor(condition: () => boolean, timeout?: number): Pro
|
|
|
62
62
|
* Create a mock IdaeDb collection adapter
|
|
63
63
|
*/
|
|
64
64
|
export declare function createMockCollection(defaultData?: any[]): {
|
|
65
|
-
find: import("vitest").Mock<(filter?: any) => Promise<any[]>>;
|
|
66
|
-
findById: import("vitest").Mock<(id: string) => Promise<any>>;
|
|
67
|
-
findAll: import("vitest").Mock<() => Promise<any[]>>;
|
|
68
|
-
create: import("vitest").Mock<(data: any) => Promise<any>>;
|
|
69
|
-
update: import("vitest").Mock<(id: string, data: any) => Promise<any>>;
|
|
70
|
-
deleteById: import("vitest").Mock<(id: string) => Promise<void>>;
|
|
71
|
-
deleteWhere: import("vitest").Mock<(filter: any) => Promise<number>>;
|
|
65
|
+
find: import("vitest/index.cjs").Mock<(filter?: any) => Promise<any[]>>;
|
|
66
|
+
findById: import("vitest/index.cjs").Mock<(id: string) => Promise<any>>;
|
|
67
|
+
findAll: import("vitest/index.cjs").Mock<() => Promise<any[]>>;
|
|
68
|
+
create: import("vitest/index.cjs").Mock<(data: any) => Promise<any>>;
|
|
69
|
+
update: import("vitest/index.cjs").Mock<(id: string, data: any) => Promise<any>>;
|
|
70
|
+
deleteById: import("vitest/index.cjs").Mock<(id: string) => Promise<void>>;
|
|
71
|
+
deleteWhere: import("vitest/index.cjs").Mock<(filter: any) => Promise<number>>;
|
|
72
72
|
};
|
|
73
73
|
/**
|
|
74
74
|
* Create a mock IdaeDb database adapter
|
|
75
75
|
*/
|
|
76
76
|
export declare function createMockIdaeDb(collections?: Record<string, any>): {
|
|
77
|
-
init: import("vitest").Mock<(uri: string, options: any) => Promise<{
|
|
78
|
-
db: import("vitest").Mock<(dbName: string) => Promise<{
|
|
79
|
-
collection: import("vitest").Mock<(collectionName: string) => any>;
|
|
77
|
+
init: import("vitest/index.cjs").Mock<(uri: string, options: any) => Promise<{
|
|
78
|
+
db: import("vitest/index.cjs").Mock<(dbName: string) => Promise<{
|
|
79
|
+
collection: import("vitest/index.cjs").Mock<(collectionName: string) => any>;
|
|
80
80
|
}>>;
|
|
81
81
|
}>>;
|
|
82
|
-
collection: import("vitest").Mock<(collectionName: string) => any>;
|
|
82
|
+
collection: import("vitest/index.cjs").Mock<(collectionName: string) => any>;
|
|
83
83
|
};
|
|
84
84
|
/**
|
|
85
85
|
* Create a mock HTTP fetch response
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export * from './config/routeDefinitions.js';
|
|
2
1
|
export * from './server/IdaeApi.js';
|
|
3
2
|
export * from './client/IdaeApiClientRequest.js';
|
|
4
3
|
export * from './client/IdaeApiClientConfig.js';
|
|
5
4
|
export * from './client/IdaeApiClientCollection.js';
|
|
6
5
|
export * from './client/IdaeApiClient.js';
|
|
6
|
+
export * from './config/routeDefinitions.js';
|
|
7
7
|
export * from './@types/types.js';
|
|
8
8
|
export * from './server/services/AuthService.js';
|
|
9
9
|
export * from './server/middleware/validationMiddleware.js';
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
// auto exports of entry components
|
|
2
|
-
export * from './config/routeDefinitions.js';
|
|
3
2
|
export * from './server/IdaeApi.js';
|
|
4
3
|
export * from './client/IdaeApiClientRequest.js';
|
|
5
4
|
export * from './client/IdaeApiClientConfig.js';
|
|
6
5
|
export * from './client/IdaeApiClientCollection.js';
|
|
7
6
|
export * from './client/IdaeApiClient.js';
|
|
7
|
+
export * from './config/routeDefinitions.js';
|
|
8
8
|
export * from './@types/types.js';
|
|
9
9
|
export * from './server/services/AuthService.js';
|
|
10
10
|
export * from './server/middleware/validationMiddleware.js';
|
package/dist/server/IdaeApi.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import '../../app.js';
|
|
2
2
|
import { type IdaeDbOptions } from "@medyll/idae-db";
|
|
3
|
-
import express from "express";
|
|
4
3
|
import { type CorsOptions } from "cors";
|
|
5
4
|
import { type RouteDefinition } from "../config/routeDefinitions.js";
|
|
6
5
|
import { RouteManager } from "./engine/routeManager.js";
|
|
@@ -31,7 +30,7 @@ declare class IdaeApi {
|
|
|
31
30
|
private constructor();
|
|
32
31
|
static getInstance(): IdaeApi;
|
|
33
32
|
get state(): "stopped" | "running";
|
|
34
|
-
get app():
|
|
33
|
+
get app(): Express;
|
|
35
34
|
setOptions(options: IdaeApiOptions): void;
|
|
36
35
|
private initializeAuth;
|
|
37
36
|
configureIdaeApi(): void;
|
|
@@ -53,7 +53,7 @@ declare class AuthMiddleWare {
|
|
|
53
53
|
* Middleware Express pour vérifier le JWT sur chaque requête protégée
|
|
54
54
|
* @returns {(req, res, next) => void} Middleware
|
|
55
55
|
*/
|
|
56
|
-
createMiddleware(): (req: Request, res: Response, next: NextFunction) =>
|
|
56
|
+
createMiddleware(): (req: Request, res: Response, next: NextFunction) => any;
|
|
57
57
|
/**
|
|
58
58
|
* Ajoute les routes d'authentification (login, logout, refresh-token) à l'app Express
|
|
59
59
|
* @param {Express} app - Application Express
|
|
@@ -15,4 +15,4 @@ export interface AuthorizationOptions {
|
|
|
15
15
|
* @example
|
|
16
16
|
* app.use('/admin', authorize({ requiredRoles: ['admin'] }))
|
|
17
17
|
*/
|
|
18
|
-
export declare function authorize(options: AuthorizationOptions): (req: Request, res: Response, next: NextFunction) =>
|
|
18
|
+
export declare function authorize(options: AuthorizationOptions): (req: Request, res: Response, next: NextFunction) => any;
|
|
@@ -4,4 +4,4 @@ import type { Request, Response, NextFunction } from "express";
|
|
|
4
4
|
*
|
|
5
5
|
* @type {(req: Request, res: Response, next: NextFunction) => Promise<void>}
|
|
6
6
|
*/
|
|
7
|
-
export declare const idaeDbMiddleware: (req: Request, res: Response, next: NextFunction) => Promise<
|
|
7
|
+
export declare const idaeDbMiddleware: (req: Request, res: Response, next: NextFunction) => Promise<any>;
|
|
@@ -22,4 +22,4 @@ export interface TenantContextOptions {
|
|
|
22
22
|
* @example
|
|
23
23
|
* app.use(tenantContextMiddleware({ required: true }))
|
|
24
24
|
*/
|
|
25
|
-
export declare function tenantContextMiddleware(options?: TenantContextOptions): (req: Request, res: Response, next: NextFunction) =>
|
|
25
|
+
export declare function tenantContextMiddleware(options?: TenantContextOptions): (req: Request, res: Response, next: NextFunction) => any;
|
|
@@ -5,4 +5,4 @@ export interface ValidationLayerOptions {
|
|
|
5
5
|
querySchema?: ZodSchema<any>;
|
|
6
6
|
paramsSchema?: ZodSchema<any>;
|
|
7
7
|
}
|
|
8
|
-
export declare function validationLayer(opts: ValidationLayerOptions): (req: Request, res: Response, next: NextFunction) =>
|
|
8
|
+
export declare function validationLayer(opts: ValidationLayerOptions): (req: Request, res: Response, next: NextFunction) => any;
|
package/package.json
CHANGED
|
@@ -1,25 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@medyll/idae-api",
|
|
3
3
|
"scope": "@medyll",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.165.0",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.js",
|
|
7
7
|
"description": "A flexible and extensible API framework for Node.js, designed to work with multiple database types and configurations. It features a modular architecture, dynamic database connection management, and a flexible routing system. The framework supports TypeScript for improved robustness and maintainability.",
|
|
8
|
-
"scripts": {
|
|
9
|
-
"dev": "vite dev",
|
|
10
|
-
"build": "vite build && npm run package",
|
|
11
|
-
"preview": "vite preview",
|
|
12
|
-
"package": "svelte-kit sync && svelte-package && publint",
|
|
13
|
-
"package:watch": "svelte-kit sync && svelte-package --watch",
|
|
14
|
-
"prepublishOnly": "npm run package",
|
|
15
|
-
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
|
|
16
|
-
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
|
|
17
|
-
"test": "vitest",
|
|
18
|
-
"lint": "prettier --check . && eslint .",
|
|
19
|
-
"format": "prettier --write .",
|
|
20
|
-
"package:pre": "node scripts/package-pre.js",
|
|
21
|
-
"doc": "typedoc --entryPointStrategy expand src/lib/server/middleware src/lib/server/engine src/lib/client"
|
|
22
|
-
},
|
|
23
8
|
"exports": {
|
|
24
9
|
".": {
|
|
25
10
|
"types": "./dist/index.d.ts",
|
|
@@ -50,8 +35,6 @@
|
|
|
50
35
|
"sequelize": "^6.37.7"
|
|
51
36
|
},
|
|
52
37
|
"devDependencies": {
|
|
53
|
-
"@medyll/idae-db": "*",
|
|
54
|
-
"@medyll/idae-prettier-config": "*",
|
|
55
38
|
"@sveltejs/adapter-auto": "^6.0.1",
|
|
56
39
|
"@sveltejs/kit": "^2.21.2",
|
|
57
40
|
"@sveltejs/package": "^2.3.11",
|
|
@@ -88,9 +71,25 @@
|
|
|
88
71
|
"typescript-eslint": "^8.33.1",
|
|
89
72
|
"vite": "^6.3.5",
|
|
90
73
|
"vitest": "^3.2.1",
|
|
91
|
-
"zod": "^3.22.4"
|
|
74
|
+
"zod": "^3.22.4",
|
|
75
|
+
"@medyll/idae-db": "0.133.0",
|
|
76
|
+
"@medyll/idae-prettier-config": "1.2.1"
|
|
92
77
|
},
|
|
93
78
|
"svelte": "./dist/index.js",
|
|
94
79
|
"types": "./dist/index.d.ts",
|
|
95
|
-
"type": "module"
|
|
96
|
-
|
|
80
|
+
"type": "module",
|
|
81
|
+
"scripts": {
|
|
82
|
+
"dev": "vite dev",
|
|
83
|
+
"build": "vite build && npm run package",
|
|
84
|
+
"preview": "vite preview",
|
|
85
|
+
"package": "svelte-kit sync && svelte-package && publint",
|
|
86
|
+
"package:watch": "svelte-kit sync && svelte-package --watch",
|
|
87
|
+
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
|
|
88
|
+
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
|
|
89
|
+
"test": "vitest",
|
|
90
|
+
"lint": "prettier --check . && eslint .",
|
|
91
|
+
"format": "prettier --write .",
|
|
92
|
+
"package:pre": "node scripts/package-pre.js",
|
|
93
|
+
"doc": "typedoc --entryPointStrategy expand src/lib/server/middleware src/lib/server/engine src/lib/client"
|
|
94
|
+
}
|
|
95
|
+
}
|