@starklabs/forge 1.3.23 → 1.3.24-beta.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/dist/js/account/index.d.ts +1 -1
- package/dist/js/account/index.d.ts.map +1 -1
- package/dist/js/account/index.js +14 -7
- package/dist/js/account/index.js.map +1 -1
- package/dist/js/account/me.delete.d.ts +2 -2
- package/dist/js/account/me.delete.d.ts.map +1 -1
- package/dist/js/account/me.delete.js +15 -6
- package/dist/js/account/me.delete.js.map +1 -1
- package/dist/js/account/me.update.d.ts +3 -3
- package/dist/js/account/me.update.d.ts.map +1 -1
- package/dist/js/account/me.update.js +20 -7
- package/dist/js/account/me.update.js.map +1 -1
- package/dist/js/app.js +21 -8
- package/dist/js/app.js.map +1 -1
- package/dist/js/auth/builtin/auth.collection.js +11 -11
- package/dist/js/auth/builtin/auth.collection.js.map +1 -1
- package/dist/js/auth/forgotPassword.d.ts +4 -4
- package/dist/js/auth/forgotPassword.d.ts.map +1 -1
- package/dist/js/auth/forgotPassword.js +12 -6
- package/dist/js/auth/forgotPassword.js.map +1 -1
- package/dist/js/auth/index.d.ts +1 -1
- package/dist/js/auth/index.d.ts.map +1 -1
- package/dist/js/auth/index.js +16 -8
- package/dist/js/auth/index.js.map +1 -1
- package/dist/js/auth/login.d.ts +4 -4
- package/dist/js/auth/login.d.ts.map +1 -1
- package/dist/js/auth/login.js +8 -4
- package/dist/js/auth/login.js.map +1 -1
- package/dist/js/auth/logout.js +6 -1
- package/dist/js/auth/logout.js.map +1 -1
- package/dist/js/auth/refresh.js +9 -0
- package/dist/js/auth/refresh.js.map +1 -1
- package/dist/js/auth/resendOTP.d.ts +4 -4
- package/dist/js/auth/resendOTP.d.ts.map +1 -1
- package/dist/js/auth/resendOTP.js +14 -4
- package/dist/js/auth/resendOTP.js.map +1 -1
- package/dist/js/auth/resetPassword.d.ts +4 -4
- package/dist/js/auth/resetPassword.d.ts.map +1 -1
- package/dist/js/auth/resetPassword.js +14 -4
- package/dist/js/auth/resetPassword.js.map +1 -1
- package/dist/js/auth/signup.d.ts +4 -4
- package/dist/js/auth/signup.d.ts.map +1 -1
- package/dist/js/auth/signup.js +10 -5
- package/dist/js/auth/signup.js.map +1 -1
- package/dist/js/auth/utils/authenticateUser.d.ts +3 -3
- package/dist/js/auth/utils/authenticateUser.d.ts.map +1 -1
- package/dist/js/auth/utils/authenticateUser.js +13 -3
- package/dist/js/auth/utils/authenticateUser.js.map +1 -1
- package/dist/js/auth/utils/createOTPModel.d.ts +1 -1
- package/dist/js/auth/utils/createOTPModel.d.ts.map +1 -1
- package/dist/js/auth/utils/createOTPModel.js +8 -3
- package/dist/js/auth/utils/createOTPModel.js.map +1 -1
- package/dist/js/auth/utils/createOTPUser.d.ts +3 -3
- package/dist/js/auth/utils/createOTPUser.d.ts.map +1 -1
- package/dist/js/auth/utils/createOTPUser.js +11 -3
- package/dist/js/auth/utils/createOTPUser.js.map +1 -1
- package/dist/js/auth/utils/createUser.d.ts +3 -3
- package/dist/js/auth/utils/createUser.d.ts.map +1 -1
- package/dist/js/auth/utils/createUser.js +12 -2
- package/dist/js/auth/utils/createUser.js.map +1 -1
- package/dist/js/auth/utils/findRefreshToken.js +5 -1
- package/dist/js/auth/utils/findRefreshToken.js.map +1 -1
- package/dist/js/auth/utils/findRefreshTokenUser.js +1 -0
- package/dist/js/auth/utils/findRefreshTokenUser.js.map +1 -1
- package/dist/js/auth/utils/getOTPUser.js +3 -0
- package/dist/js/auth/utils/getOTPUser.js.map +1 -1
- package/dist/js/auth/utils/getUser.d.ts +3 -3
- package/dist/js/auth/utils/getUser.d.ts.map +1 -1
- package/dist/js/auth/utils/getUser.js +6 -2
- package/dist/js/auth/utils/getUser.js.map +1 -1
- package/dist/js/auth/utils/handleRefreshTokenValidation.js +7 -1
- package/dist/js/auth/utils/handleRefreshTokenValidation.js.map +1 -1
- package/dist/js/auth/utils/handleRotateRefreshToken.js +7 -1
- package/dist/js/auth/utils/handleRotateRefreshToken.js.map +1 -1
- package/dist/js/auth/utils/modeMap.d.ts +12 -12
- package/dist/js/auth/utils/otpVerifiedResponse.js +1 -0
- package/dist/js/auth/utils/otpVerifiedResponse.js.map +1 -1
- package/dist/js/auth/utils/sendCookie.js +10 -0
- package/dist/js/auth/utils/sendCookie.js.map +1 -1
- package/dist/js/auth/utils/verifyCredentials.d.ts +3 -3
- package/dist/js/auth/utils/verifyCredentials.d.ts.map +1 -1
- package/dist/js/auth/utils/verifyCredentials.js +8 -6
- package/dist/js/auth/utils/verifyCredentials.js.map +1 -1
- package/dist/js/auth/verifyOTP.d.ts +4 -4
- package/dist/js/auth/verifyOTP.d.ts.map +1 -1
- package/dist/js/auth/verifyOTP.js +18 -5
- package/dist/js/auth/verifyOTP.js.map +1 -1
- package/dist/js/config/cloudinary.js +1 -0
- package/dist/js/config/cloudinary.js.map +1 -1
- package/dist/js/config/duration.js +7 -0
- package/dist/js/config/duration.js.map +1 -1
- package/dist/js/config/envs.js +23 -3
- package/dist/js/config/envs.js.map +1 -1
- package/dist/js/config/handleReqType.d.ts +1 -1
- package/dist/js/config/handleReqType.d.ts.map +1 -1
- package/dist/js/config/handleReqType.js +4 -3
- package/dist/js/config/handleReqType.js.map +1 -1
- package/dist/js/config/handlerMap.js +4 -0
- package/dist/js/config/handlerMap.js.map +1 -1
- package/dist/js/config/refreshModel.js +1 -0
- package/dist/js/config/refreshModel.js.map +1 -1
- package/dist/js/config/sendEmail.js +1 -0
- package/dist/js/config/sendEmail.js.map +1 -1
- package/dist/js/crud/bunch.crud.js +2 -0
- package/dist/js/crud/bunch.crud.js.map +1 -1
- package/dist/js/crud/create.d.ts +4 -4
- package/dist/js/crud/create.d.ts.map +1 -1
- package/dist/js/crud/create.js +23 -8
- package/dist/js/crud/create.js.map +1 -1
- package/dist/js/crud/createBulk.d.ts +4 -4
- package/dist/js/crud/createBulk.d.ts.map +1 -1
- package/dist/js/crud/createBulk.js +8 -3
- package/dist/js/crud/createBulk.js.map +1 -1
- package/dist/js/crud/email/index.d.ts +2 -0
- package/dist/js/crud/email/index.d.ts.map +1 -0
- package/dist/js/crud/email/index.js +2 -0
- package/dist/js/crud/email/index.js.map +1 -0
- package/dist/js/crud/encryption/handleDecryption.js +8 -3
- package/dist/js/crud/encryption/handleDecryption.js.map +1 -1
- package/dist/js/crud/encryption/handleEncryption.js +7 -3
- package/dist/js/crud/encryption/handleEncryption.js.map +1 -1
- package/dist/js/crud/handleUploads/file.add.d.ts +4 -4
- package/dist/js/crud/handleUploads/file.add.d.ts.map +1 -1
- package/dist/js/crud/handleUploads/file.add.js +16 -9
- package/dist/js/crud/handleUploads/file.add.js.map +1 -1
- package/dist/js/crud/handleUploads/file.delete.d.ts +4 -4
- package/dist/js/crud/handleUploads/file.delete.d.ts.map +1 -1
- package/dist/js/crud/handleUploads/file.delete.js +14 -5
- package/dist/js/crud/handleUploads/file.delete.js.map +1 -1
- package/dist/js/crud/handleUploads/file.update.d.ts +4 -4
- package/dist/js/crud/handleUploads/file.update.d.ts.map +1 -1
- package/dist/js/crud/handleUploads/file.update.js +15 -5
- package/dist/js/crud/handleUploads/file.update.js.map +1 -1
- package/dist/js/crud/index.d.ts +1 -1
- package/dist/js/crud/index.d.ts.map +1 -1
- package/dist/js/crud/index.js +18 -11
- package/dist/js/crud/index.js.map +1 -1
- package/dist/js/crud/read.d.ts +4 -4
- package/dist/js/crud/read.d.ts.map +1 -1
- package/dist/js/crud/read.js +18 -9
- package/dist/js/crud/read.js.map +1 -1
- package/dist/js/crud/readAll.d.ts +3 -3
- package/dist/js/crud/readAll.d.ts.map +1 -1
- package/dist/js/crud/readAll.js +16 -8
- package/dist/js/crud/readAll.js.map +1 -1
- package/dist/js/crud/remove.d.ts +3 -3
- package/dist/js/crud/remove.d.ts.map +1 -1
- package/dist/js/crud/remove.js +19 -8
- package/dist/js/crud/remove.js.map +1 -1
- package/dist/js/crud/removeAll.d.ts +3 -3
- package/dist/js/crud/removeAll.d.ts.map +1 -1
- package/dist/js/crud/removeAll.js +13 -5
- package/dist/js/crud/removeAll.js.map +1 -1
- package/dist/js/crud/removeMultiple.d.ts +4 -4
- package/dist/js/crud/removeMultiple.d.ts.map +1 -1
- package/dist/js/crud/removeMultiple.js +18 -7
- package/dist/js/crud/removeMultiple.js.map +1 -1
- package/dist/js/crud/security/handleDecryption.js +8 -3
- package/dist/js/crud/security/handleDecryption.js.map +1 -1
- package/dist/js/crud/security/handleEncryption.js +7 -3
- package/dist/js/crud/security/handleEncryption.js.map +1 -1
- package/dist/js/crud/security/handleHashing.js +8 -3
- package/dist/js/crud/security/handleHashing.js.map +1 -1
- package/dist/js/crud/update.d.ts +4 -4
- package/dist/js/crud/update.d.ts.map +1 -1
- package/dist/js/crud/update.js +24 -9
- package/dist/js/crud/update.js.map +1 -1
- package/dist/js/crud/utils/authorizeAccess.d.ts +2 -2
- package/dist/js/crud/utils/authorizeAccess.d.ts.map +1 -1
- package/dist/js/crud/utils/authorizeAccess.js +19 -13
- package/dist/js/crud/utils/authorizeAccess.js.map +1 -1
- package/dist/js/crud/utils/getItem.d.ts +3 -3
- package/dist/js/crud/utils/getItem.d.ts.map +1 -1
- package/dist/js/crud/utils/getItem.js +18 -9
- package/dist/js/crud/utils/getItem.js.map +1 -1
- package/dist/js/health/health.collection.js +11 -11
- package/dist/js/health/health.collection.js.map +1 -1
- package/dist/js/health/index.d.ts +1 -1
- package/dist/js/health/index.d.ts.map +1 -1
- package/dist/js/health/index.js +2 -2
- package/dist/js/health/index.js.map +1 -1
- package/dist/js/lib/OAuthProviders.js +1 -1
- package/dist/js/lib/OAuthProviders.js.map +1 -1
- package/dist/js/lib/db.js +1 -0
- package/dist/js/lib/db.js.map +1 -1
- package/dist/js/lib/model.factory.d.ts +10 -1
- package/dist/js/lib/model.factory.d.ts.map +1 -1
- package/dist/js/lib/model.factory.js +18 -4
- package/dist/js/lib/model.factory.js.map +1 -1
- package/dist/js/lib/model.registry.js +1 -0
- package/dist/js/lib/model.registry.js.map +1 -1
- package/dist/js/lib/mongoose.fields.js +20 -0
- package/dist/js/lib/mongoose.fields.js.map +1 -1
- package/dist/js/lib/schema.builder.js +3 -0
- package/dist/js/lib/schema.builder.js.map +1 -1
- package/dist/js/lib/unified.fields.d.ts +5 -0
- package/dist/js/lib/unified.fields.d.ts.map +1 -1
- package/dist/js/lib/unified.fields.js +56 -0
- package/dist/js/lib/unified.fields.js.map +1 -1
- package/dist/js/lib/unified.types.d.ts +3 -0
- package/dist/js/lib/unified.types.d.ts.map +1 -1
- package/dist/js/lib/zod.factory.d.ts +13 -0
- package/dist/js/lib/zod.factory.d.ts.map +1 -1
- package/dist/js/lib/zod.factory.js +14 -0
- package/dist/js/lib/zod.factory.js.map +1 -1
- package/dist/js/lib/zod.fields.d.ts +55 -0
- package/dist/js/lib/zod.fields.d.ts.map +1 -1
- package/dist/js/lib/zod.fields.js +56 -0
- package/dist/js/lib/zod.fields.js.map +1 -1
- package/dist/js/middleware/error.middleware.js +1 -0
- package/dist/js/middleware/error.middleware.js.map +1 -1
- package/dist/js/middleware/multer.middleware.d.ts +1 -1
- package/dist/js/middleware/multer.middleware.d.ts.map +1 -1
- package/dist/js/middleware/multer.middleware.js +22 -7
- package/dist/js/middleware/multer.middleware.js.map +1 -1
- package/dist/js/terminal/appInfo.js +11 -11
- package/dist/js/terminal/appInfo.js.map +1 -1
- package/dist/js/terminal/logger.js +1 -1
- package/dist/js/terminal/logger.js.map +1 -1
- package/dist/js/types/ActionHandler.d.ts +86 -11
- package/dist/js/types/ActionHandler.d.ts.map +1 -1
- package/dist/js/types/Collection.d.ts +104 -15
- package/dist/js/types/Collection.d.ts.map +1 -1
- package/dist/js/types/Constructor.d.ts +1 -1
- package/dist/js/types/Constructor.d.ts.map +1 -1
- package/dist/js/types/Route.d.ts +131 -14
- package/dist/js/types/Route.d.ts.map +1 -1
- package/dist/js/types/Routepath.js +15 -0
- package/dist/js/types/Routepath.js.map +1 -1
- package/dist/js/types/email.js +13 -0
- package/dist/js/types/email.js.map +1 -1
- package/dist/js/types/upload.d.ts +57 -5
- package/dist/js/types/upload.d.ts.map +1 -1
- package/dist/js/upload/create.js +9 -6
- package/dist/js/upload/create.js.map +1 -1
- package/dist/js/upload/delete.js +21 -21
- package/dist/js/upload/delete.js.map +1 -1
- package/dist/js/upload/update.js +21 -21
- package/dist/js/upload/update.js.map +1 -1
- package/dist/js/utils/getErrorDetail.d.ts +2 -2
- package/dist/js/utils/getErrorDetail.d.ts.map +1 -1
- package/dist/js/utils/getErrorDetail.js +2 -2
- package/dist/js/utils/getErrorDetail.js.map +1 -1
- package/dist/js/utils/getModel.d.ts +3 -3
- package/dist/js/utils/getModel.d.ts.map +1 -1
- package/dist/js/utils/getModel.js +6 -6
- package/dist/js/utils/getModel.js.map +1 -1
- package/dist/js/utils/libsodium.js +6 -0
- package/dist/js/utils/libsodium.js.map +1 -1
- package/dist/js/utils/otpPurposes.js +38 -0
- package/dist/js/utils/otpPurposes.js.map +1 -1
- package/dist/js/utils/sanitize.js +23 -2
- package/dist/js/utils/sanitize.js.map +1 -1
- package/dist/js/utils/saveRefreshToken.js +2 -1
- package/dist/js/utils/saveRefreshToken.js.map +1 -1
- package/dist/js/utils/validate.js +5 -3
- package/dist/js/utils/validate.js.map +1 -1
- package/dist/js/utils/validationKeyError.d.ts +1 -1
- package/dist/js/utils/validationKeyError.d.ts.map +1 -1
- package/dist/js/utils/validationKeyError.js +13 -8
- package/dist/js/utils/validationKeyError.js.map +1 -1
- package/package.json +1 -1
- package/readme.md +29 -29
|
@@ -1,25 +1,100 @@
|
|
|
1
1
|
import type { Request } from "express";
|
|
2
|
-
import type { Document } from "mongoose";
|
|
3
|
-
|
|
2
|
+
import type { Document, Model } from "mongoose";
|
|
3
|
+
/**
|
|
4
|
+
* Context payload passed to custom action hooks before or after route execution.
|
|
5
|
+
*/
|
|
6
|
+
export interface ActionContext {
|
|
7
|
+
/**
|
|
8
|
+
* Express request object.
|
|
9
|
+
*/
|
|
4
10
|
req: Request;
|
|
5
|
-
|
|
6
|
-
|
|
11
|
+
/**
|
|
12
|
+
* Currently authenticated user profile attached to the request.
|
|
13
|
+
*/
|
|
14
|
+
user?: Request["user"];
|
|
15
|
+
/**
|
|
16
|
+
* The collection's Express route name.
|
|
17
|
+
*
|
|
18
|
+
* @example "products"
|
|
19
|
+
*/
|
|
20
|
+
route: string;
|
|
21
|
+
/**
|
|
22
|
+
* Database operation being executed by the handler.
|
|
23
|
+
*/
|
|
7
24
|
operation: "read" | "readAll" | "create" | "update" | "remove" | "removeMultiple" | "removeAll";
|
|
8
|
-
|
|
9
|
-
|
|
25
|
+
/**
|
|
26
|
+
* Mongoose model name.
|
|
27
|
+
*
|
|
28
|
+
* @example "Product"
|
|
29
|
+
*/
|
|
30
|
+
model: string;
|
|
31
|
+
/**
|
|
32
|
+
* Mongoose Model instance for performing direct database queries.
|
|
33
|
+
*/
|
|
34
|
+
Model?: Model<any>;
|
|
35
|
+
/**
|
|
36
|
+
* Incoming request payload and processed metadata.
|
|
37
|
+
*/
|
|
10
38
|
data?: {
|
|
39
|
+
/**
|
|
40
|
+
* ID or reference of the resource owner.
|
|
41
|
+
*/
|
|
11
42
|
owner?: string;
|
|
43
|
+
/**
|
|
44
|
+
* Parsed request body object.
|
|
45
|
+
*/
|
|
12
46
|
body?: any;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
47
|
+
/**
|
|
48
|
+
* Metadata from uploaded files (if multipart route).
|
|
49
|
+
*/
|
|
50
|
+
files?: any;
|
|
51
|
+
/**
|
|
52
|
+
* Encrypted field values.
|
|
53
|
+
*/
|
|
54
|
+
encrypted?: any;
|
|
55
|
+
/**
|
|
56
|
+
* Decrypted field values.
|
|
57
|
+
*/
|
|
58
|
+
decrypted?: any;
|
|
59
|
+
/**
|
|
60
|
+
* Hashed field values.
|
|
61
|
+
*/
|
|
62
|
+
hashed?: any;
|
|
17
63
|
};
|
|
64
|
+
/**
|
|
65
|
+
* The database document(s) fetched or updated during the operation.
|
|
66
|
+
*/
|
|
18
67
|
item?: Document | Document[];
|
|
68
|
+
/**
|
|
69
|
+
* The final processed result payload ready to be returned in the response.
|
|
70
|
+
*/
|
|
19
71
|
result?: any;
|
|
20
72
|
}
|
|
73
|
+
/**
|
|
74
|
+
* A custom action hook executed before or after a route handler runs.
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* ```ts
|
|
78
|
+
* const sendWelcomeEmail: Action = {
|
|
79
|
+
* type: "email",
|
|
80
|
+
* handler: async ({ user, data }) => {
|
|
81
|
+
* console.log(`Sending email to ${user?.email}`);
|
|
82
|
+
* },
|
|
83
|
+
* };
|
|
84
|
+
* ```
|
|
85
|
+
*/
|
|
21
86
|
export interface Action {
|
|
87
|
+
/**
|
|
88
|
+
* Action category type.
|
|
89
|
+
*
|
|
90
|
+
* - `custom`: General custom middleware logic.
|
|
91
|
+
* - `email`: Dedicated email notification trigger.
|
|
92
|
+
*/
|
|
22
93
|
type: "custom" | "email";
|
|
23
|
-
|
|
94
|
+
/**
|
|
95
|
+
* Async handler function executed by the framework.
|
|
96
|
+
*/
|
|
97
|
+
handler: (context: ActionContext) => Promise<void> | void;
|
|
24
98
|
}
|
|
99
|
+
export type CreateContext = ActionContext;
|
|
25
100
|
//# sourceMappingURL=ActionHandler.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActionHandler.d.ts","sourceRoot":"","sources":["../../../src/js/types/ActionHandler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"ActionHandler.d.ts","sourceRoot":"","sources":["../../../src/js/types/ActionHandler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC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unified.types.js";
|
|
3
3
|
import type { ZodValidation } from "../lib/zod.fields.ts";
|
|
4
4
|
import type { Route } from "./Route.js";
|
|
5
|
+
export type { Route } from "./Route.js";
|
|
6
|
+
/**
|
|
7
|
+
* A database field.
|
|
8
|
+
* Can be a standard Mongoose field or a combined UnifiedField ({ mongoose, zod }).
|
|
9
|
+
*/
|
|
5
10
|
export type SchemaField = MongooseField | UnifiedField;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
11
|
+
/**
|
|
12
|
+
* Object defining all database fields for a model.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```ts
|
|
16
|
+
* {
|
|
17
|
+
* name: fields.requiredString,
|
|
18
|
+
* price: fields.requiredNumber
|
|
19
|
+
* }
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export type CollectionSchema = Record<string, SchemaField>;
|
|
23
|
+
/**
|
|
24
|
+
* A validation rule.
|
|
25
|
+
* Can be a standard Zod rule or a combined UnifiedField.
|
|
26
|
+
*/
|
|
10
27
|
export type ValidationField = ZodValidation | UnifiedField;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
28
|
+
/**
|
|
29
|
+
* Group of validation rules used to check incoming request data.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```ts
|
|
33
|
+
* {
|
|
34
|
+
* createProduct: {
|
|
35
|
+
* name: zodFields.requiredString,
|
|
36
|
+
* price: zodFields.requiredNumber
|
|
37
|
+
* }
|
|
38
|
+
* }
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
export type CollectionValidations = Record<string, Record<string, ValidationField> | ValidationField>;
|
|
42
|
+
/**
|
|
43
|
+
* The category of feature this collection handles.
|
|
44
|
+
*
|
|
45
|
+
* - `crud`: Standard Create, Read, Update, Delete features.
|
|
46
|
+
* - `auth`: Login, signup, and user sessions.
|
|
47
|
+
* - `account`: Profile settings for the logged-in user.
|
|
48
|
+
* - `health`: Server status and health checks.
|
|
49
|
+
*/
|
|
50
|
+
export type CollectionType = "auth" | "health" | "crud" | "account";
|
|
51
|
+
/**
|
|
52
|
+
* The main configuration object to create your backend feature.
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* ```ts
|
|
56
|
+
* const productsCollection: Collection = {
|
|
57
|
+
* type: "crud",
|
|
58
|
+
* route: "products",
|
|
59
|
+
* model: "Product",
|
|
60
|
+
* schema: {
|
|
61
|
+
* name: fields.requiredString,
|
|
62
|
+
* price: fields.requiredNumber,
|
|
63
|
+
* },
|
|
64
|
+
* routes: [
|
|
65
|
+
* {
|
|
66
|
+
* method: "get",
|
|
67
|
+
* path: "/",
|
|
68
|
+
* handler: "readAll",
|
|
69
|
+
* auth: "public",
|
|
70
|
+
* },
|
|
71
|
+
* ],
|
|
72
|
+
* };
|
|
73
|
+
* ```
|
|
74
|
+
*/
|
|
15
75
|
export interface Collection {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
76
|
+
/**
|
|
77
|
+
* The collection category.
|
|
78
|
+
*
|
|
79
|
+
* @example "crud"
|
|
80
|
+
*/
|
|
81
|
+
type: CollectionType;
|
|
82
|
+
/**
|
|
83
|
+
* The main URL path for this collection.
|
|
84
|
+
* Use lowercase and plural words.
|
|
85
|
+
*
|
|
86
|
+
* @example "products"
|
|
87
|
+
*/
|
|
88
|
+
route: string;
|
|
89
|
+
/**
|
|
90
|
+
* List of API routes (endpoints) for this collection.
|
|
91
|
+
*/
|
|
92
|
+
routes: Route[];
|
|
93
|
+
/**
|
|
94
|
+
* Name of your database model.
|
|
95
|
+
* Use singular words starting with a capital letter.
|
|
96
|
+
*
|
|
97
|
+
* @example "Product"
|
|
98
|
+
*/
|
|
99
|
+
model?: string;
|
|
100
|
+
/**
|
|
101
|
+
* Database fields structure for your Mongoose model.
|
|
102
|
+
*/
|
|
103
|
+
schema?: CollectionSchema;
|
|
104
|
+
/**
|
|
105
|
+
* Rules to validate data sent by users in requests.
|
|
106
|
+
*/
|
|
107
|
+
validations?: CollectionValidations;
|
|
22
108
|
}
|
|
23
|
-
export type
|
|
109
|
+
export type MongooseSchema = CollectionSchema;
|
|
110
|
+
export type MongooseObj = CollectionSchema;
|
|
111
|
+
export type ValidationsObj = CollectionValidations;
|
|
112
|
+
export type ReqType = CollectionType;
|
|
24
113
|
//# sourceMappingURL=Collection.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Collection.d.ts","sourceRoot":"","sources":["../../../src/js/types/Collection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAG5D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAE1D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"Collection.d.ts","sourceRoot":"","sources":["../../../src/js/types/Collection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAG5D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAE1D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAExC,YAAY,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAExC;;;GAGG;AACH,MAAM,MAAM,WAAW,GAAG,aAAa,GAAG,YAAY,CAAC;AAEvD;;;;;;;;;;GAUG;AACH,MAAM,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;AAE3D;;;GAGG;AACH,MAAM,MAAM,eAAe,GAAG,aAAa,GAAG,YAAY,CAAC;AAE3D;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,qBAAqB,GAAG,MAAM,CACxC,MAAM,EACN,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,GAAG,eAAe,CAClD,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,QAAQ,GAAG,MAAM,GAAG,SAAS,CAAC;AAEpE;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,WAAW,UAAU;IACzB;;;;OAIG;IACH,IAAI,EAAE,cAAc,CAAC;IAErB;;;;;OAKG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,MAAM,EAAE,KAAK,EAAE,CAAC;IAEhB;;;;;OAKG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,MAAM,CAAC,EAAE,gBAAgB,CAAC;IAE1B;;OAEG;IACH,WAAW,CAAC,EAAE,qBAAqB,CAAC;CACrC;AAGD,MAAM,MAAM,cAAc,GAAG,gBAAgB,CAAC;AAC9C,MAAM,MAAM,WAAW,GAAG,gBAAgB,CAAC;AAC3C,MAAM,MAAM,cAAc,GAAG,qBAAqB,CAAC;AACnD,MAAM,MAAM,OAAO,GAAG,cAAc,CAAC"}
|
|
@@ -16,7 +16,7 @@ export interface AuthConfig {
|
|
|
16
16
|
purpose: "purpose" | "write_a_custom_field_name" | (string & {});
|
|
17
17
|
};
|
|
18
18
|
schemaObj?: {
|
|
19
|
-
|
|
19
|
+
model: "User" | "WRITE_A_CUSTOM_USER_Model_Name" | (string & {});
|
|
20
20
|
schema: Record<string, UnifiedField>;
|
|
21
21
|
};
|
|
22
22
|
accessTokenName?: "access_token" | "write_a_custom_name" | (string & {});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Constructor.d.ts","sourceRoot":"","sources":["../../../src/js/types/Constructor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAA4B,MAAM,iBAAiB,CAAC;AAC5E,OAAO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C7B,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,WAAW,CAAC,EAAE,UAAU,EAAE,CAAC;IAC3B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,GAAG,EAAE,MAAM,CAAC;IACZ,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB,SAAS,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,iBAAiB,EAAE,YAAY,CAAC;IAChC,YAAY,EAAE,MAAM,CAAC;IACrB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,mBAAoB,SAAQ,WAAW;IACtD,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB"}
|
package/dist/js/types/Route.d.ts
CHANGED
|
@@ -1,33 +1,150 @@
|
|
|
1
|
-
export type RouteMethod = "get" | "post" | "patch" | "delete";
|
|
2
1
|
import type { RoutePath } from "./Routepath.js";
|
|
3
2
|
import type { authHandlers } from "./authHandlers.ts";
|
|
4
3
|
import type { crudHandlers } from "./crudHandlers.ts";
|
|
5
4
|
import type { uploadHandlers } from "./uploadHandlers.js";
|
|
6
5
|
import type { accountHandlers } from "./accountHandlers.js";
|
|
7
|
-
export type AuthRole = "admin" | "adminOrOwner" | "authenticated" | "public";
|
|
8
6
|
import type { Action } from "./ActionHandler.js";
|
|
9
7
|
import type { Upload } from "./upload.ts";
|
|
8
|
+
/**
|
|
9
|
+
* Supported HTTP request methods for endpoints.
|
|
10
|
+
*/
|
|
11
|
+
export type RouteMethod = "get" | "post" | "patch" | "delete";
|
|
12
|
+
/**
|
|
13
|
+
* Access levels required to call an endpoint.
|
|
14
|
+
*
|
|
15
|
+
* - `public`: Anyone can access (no login required).
|
|
16
|
+
* - `authenticated`: Any logged-in user can access.
|
|
17
|
+
* - `admin`: Only users with the admin role can access.
|
|
18
|
+
* - `admin-or-owner`: Admins or the owner of the resource can access.
|
|
19
|
+
*/
|
|
20
|
+
export type AuthRole = "admin" | "admin-or-owner" | "authenticated" | "public";
|
|
21
|
+
/**
|
|
22
|
+
* Authentication mode required for auth-related routes.
|
|
23
|
+
*/
|
|
10
24
|
export type AuthMode = "credentials" | "otp";
|
|
25
|
+
/**
|
|
26
|
+
* Built-in framework handlers for processing requests.
|
|
27
|
+
*/
|
|
11
28
|
export type Handler = authHandlers | crudHandlers | uploadHandlers | accountHandlers;
|
|
29
|
+
/**
|
|
30
|
+
* Configuration options for database queries on this route.
|
|
31
|
+
*/
|
|
32
|
+
export interface RouteDbConfig {
|
|
33
|
+
/**
|
|
34
|
+
* Schema field name to automatically populate via Mongoose `.populate()`.
|
|
35
|
+
* Set to `false` to disable automatic population.
|
|
36
|
+
*
|
|
37
|
+
* @example "owner"
|
|
38
|
+
*/
|
|
39
|
+
populate?: string | boolean;
|
|
40
|
+
/**
|
|
41
|
+
* List of schema fields to hide from the JSON response.
|
|
42
|
+
*
|
|
43
|
+
* @example ["__v", "password", "updatedAt"]
|
|
44
|
+
*/
|
|
45
|
+
hiddenFields?: string[];
|
|
46
|
+
/**
|
|
47
|
+
* Field name in request body that contains the list of IDs for batch operations.
|
|
48
|
+
*
|
|
49
|
+
* @example "ids"
|
|
50
|
+
*/
|
|
51
|
+
targetField?: "ids" | (string & {});
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Defines a single API route/endpoint inside a collection.
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* ```ts
|
|
58
|
+
* {
|
|
59
|
+
* method: "get",
|
|
60
|
+
* path: "/:id",
|
|
61
|
+
* handler: "read",
|
|
62
|
+
* auth: "admin-or-owner",
|
|
63
|
+
* validation: "readProduct",
|
|
64
|
+
* config: {
|
|
65
|
+
* populate: "owner",
|
|
66
|
+
* hiddenFields: ["__v"],
|
|
67
|
+
* },
|
|
68
|
+
* }
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
12
71
|
export interface Route {
|
|
72
|
+
/**
|
|
73
|
+
* HTTP method for this endpoint.
|
|
74
|
+
*
|
|
75
|
+
* @example "get"
|
|
76
|
+
*/
|
|
13
77
|
method: RouteMethod;
|
|
78
|
+
/**
|
|
79
|
+
* URL route path pattern.
|
|
80
|
+
*
|
|
81
|
+
* @example "/:id"
|
|
82
|
+
*/
|
|
14
83
|
path: RoutePath;
|
|
84
|
+
/**
|
|
85
|
+
* Name of the framework controller handler to run.
|
|
86
|
+
*
|
|
87
|
+
* @example "readAll"
|
|
88
|
+
*/
|
|
15
89
|
handler: Handler;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
90
|
+
/**
|
|
91
|
+
* Validation key defined in your collection's `validations` object.
|
|
92
|
+
* Set to `false` to disable input validation for this route.
|
|
93
|
+
*
|
|
94
|
+
* @example "createProduct"
|
|
95
|
+
*/
|
|
96
|
+
validation?: string | boolean;
|
|
97
|
+
/**
|
|
98
|
+
* User role required to access this route.
|
|
99
|
+
*
|
|
100
|
+
* @example "authenticated"
|
|
101
|
+
*/
|
|
102
|
+
auth?: AuthRole;
|
|
103
|
+
/**
|
|
104
|
+
* Resource ownership check setting.
|
|
105
|
+
*/
|
|
106
|
+
ownership?: "self" | "owner";
|
|
107
|
+
/**
|
|
108
|
+
* Database options for this route (population, field masking, etc.).
|
|
109
|
+
*/
|
|
110
|
+
config?: RouteDbConfig;
|
|
111
|
+
/**
|
|
112
|
+
* File upload settings for multipart requests.
|
|
113
|
+
*/
|
|
114
|
+
files?: Upload[];
|
|
115
|
+
/**
|
|
116
|
+
* Authentication method used for login or verification routes.
|
|
117
|
+
*/
|
|
25
118
|
mode?: AuthMode;
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
119
|
+
/**
|
|
120
|
+
* Fields to automatically encrypt before saving to the database.
|
|
121
|
+
*
|
|
122
|
+
* @example ["cardNumber", "ssn"]
|
|
123
|
+
*/
|
|
124
|
+
encryptedFields?: string[];
|
|
125
|
+
/**
|
|
126
|
+
* Encrypted fields to automatically decrypt before returning the response.
|
|
127
|
+
*
|
|
128
|
+
* @example ["cardNumber"]
|
|
129
|
+
*/
|
|
130
|
+
decryptedFields?: string[];
|
|
131
|
+
/**
|
|
132
|
+
* Fields to hash before storing (such as passwords).
|
|
133
|
+
*
|
|
134
|
+
* @example ["password"]
|
|
135
|
+
*/
|
|
136
|
+
hashedFields?: string[];
|
|
137
|
+
/**
|
|
138
|
+
* Custom middleware hooks to run before or after the main handler.
|
|
139
|
+
*/
|
|
29
140
|
actions?: {
|
|
141
|
+
/**
|
|
142
|
+
* Middleware functions to run BEFORE the handler.
|
|
143
|
+
*/
|
|
30
144
|
before?: Action[];
|
|
145
|
+
/**
|
|
146
|
+
* Middleware functions to run AFTER the handler.
|
|
147
|
+
*/
|
|
31
148
|
after?: Action[];
|
|
32
149
|
};
|
|
33
150
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Route.d.ts","sourceRoot":"","sources":["../../../src/js/types/Route.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"Route.d.ts","sourceRoot":"","sources":["../../../src/js/types/Route.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;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,EAAE,aAAa,CAAC;IAEvB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IAEjB;;OAEG;IACH,IAAI,CAAC,EAAE,QAAQ,CAAC;IAEhB;;;;OAIG;IACH,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAE3B;;;;OAIG;IACH,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAE3B;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IAExB;;OAEG;IACH,OAAO,CAAC,EAAE;QACR;;WAEG;QACH,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;QAElB;;WAEG;QACH,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;KAClB,CAAC;CACH"}
|
|
@@ -1,2 +1,17 @@
|
|
|
1
1
|
export {};
|
|
2
|
+
// Admin
|
|
3
|
+
// | "/dashboard"
|
|
4
|
+
// | "/stats"
|
|
5
|
+
// | "/analytics"
|
|
6
|
+
// | "/reports"
|
|
7
|
+
// Settings
|
|
8
|
+
// | "/settings"
|
|
9
|
+
// | "/preferences"
|
|
10
|
+
// Notifications
|
|
11
|
+
// | "/notifications"
|
|
12
|
+
// | "/notifications/read"
|
|
13
|
+
// Misc
|
|
14
|
+
// | "/health"
|
|
15
|
+
// | "/ping"
|
|
16
|
+
// | "/version";
|
|
2
17
|
//# sourceMappingURL=Routepath.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Routepath.js","sourceRoot":"","sources":["../../../src/js/types/Routepath.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"Routepath.js","sourceRoot":"","sources":["../../../src/js/types/Routepath.ts"],"names":[],"mappings":";AAkEE,QAAQ;AACR,iBAAiB;AACjB,aAAa;AACb,iBAAiB;AACjB,eAAe;AAEf,WAAW;AACX,gBAAgB;AAChB,mBAAmB;AAEnB,gBAAgB;AAChB,qBAAqB;AACrB,0BAA0B;AAE1B,OAAO;AACP,cAAc;AACd,YAAY;AACZ,gBAAgB"}
|
package/dist/js/types/email.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"email.js","sourceRoot":"","sources":["../../../src/js/types/email.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"email.js","sourceRoot":"","sources":["../../../src/js/types/email.ts"],"names":[],"mappings":";AAqEA;;;;;;;;;;;;EAYE"}
|
|
@@ -1,9 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Supported storage provider destinations for file uploads.
|
|
3
|
+
*/
|
|
4
|
+
export type UploadProvider = "cloudinary" | "aws-s3";
|
|
5
|
+
/**
|
|
6
|
+
* File category type for validation and handling.
|
|
7
|
+
*/
|
|
8
|
+
export type UploadType = "image" | "video" | "raw";
|
|
9
|
+
/**
|
|
10
|
+
* Configuration for handling file uploads on a route.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* {
|
|
15
|
+
* paramField: "avatar",
|
|
16
|
+
* schemaField: "profileImage",
|
|
17
|
+
* type: "image",
|
|
18
|
+
* provider: "cloudinary",
|
|
19
|
+
* }
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
1
22
|
export interface Upload {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
23
|
+
/**
|
|
24
|
+
* Field name expected in the incoming multipart form request payload.
|
|
25
|
+
*
|
|
26
|
+
* @example "avatar"
|
|
27
|
+
*/
|
|
28
|
+
paramField: string;
|
|
29
|
+
/**
|
|
30
|
+
* Database schema field name where file metadata will be saved.
|
|
31
|
+
*
|
|
32
|
+
* @example "profileImage"
|
|
33
|
+
*/
|
|
34
|
+
schemaField: string;
|
|
35
|
+
/**
|
|
36
|
+
* Type of file allowed for this upload.
|
|
37
|
+
*
|
|
38
|
+
* @example "image"
|
|
39
|
+
*/
|
|
40
|
+
type: UploadType;
|
|
41
|
+
/**
|
|
42
|
+
* Storage provider destination for uploading the file.
|
|
43
|
+
*
|
|
44
|
+
* @example "cloudinary"
|
|
45
|
+
*/
|
|
46
|
+
provider: UploadProvider;
|
|
47
|
+
/**
|
|
48
|
+
* Allow multiple file uploads for this field if set to `true`.
|
|
49
|
+
*
|
|
50
|
+
* @default false
|
|
51
|
+
*/
|
|
6
52
|
multiple?: boolean;
|
|
7
|
-
|
|
53
|
+
/**
|
|
54
|
+
* Optional custom validation key or identifier for file-specific rules.
|
|
55
|
+
*
|
|
56
|
+
* @example "avatarRules"
|
|
57
|
+
*/
|
|
58
|
+
validationKey?: string;
|
|
8
59
|
}
|
|
60
|
+
export type LegacyUpload = Upload;
|
|
9
61
|
//# sourceMappingURL=upload.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upload.d.ts","sourceRoot":"","sources":["../../../src/js/types/upload.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,MAAM;IACrB,
|
|
1
|
+
{"version":3,"file":"upload.d.ts","sourceRoot":"","sources":["../../../src/js/types/upload.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,YAAY,GAAG,QAAQ,CAAC;AAErD;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,OAAO,GAAG,OAAO,GAAG,KAAK,CAAC;AAEnD;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,MAAM;IACrB;;;;OAIG;IACH,UAAU,EAAE,MAAM,CAAC;IAEnB;;;;OAIG;IACH,WAAW,EAAE,MAAM,CAAC;IAEpB;;;;OAIG;IACH,IAAI,EAAE,UAAU,CAAC;IAEjB;;;;OAIG;IACH,QAAQ,EAAE,cAAc,CAAC;IAEzB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB;;;;OAIG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAGD,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC"}
|
package/dist/js/upload/create.js
CHANGED
|
@@ -36,17 +36,20 @@ const uploadFile = (file, routeObj) => {
|
|
|
36
36
|
});
|
|
37
37
|
};
|
|
38
38
|
export const handleUploadFiles = async (req, routeObj) => {
|
|
39
|
-
if
|
|
39
|
+
// if files = undefined, [], false, length = 0
|
|
40
|
+
if (!routeObj?.files?.length)
|
|
40
41
|
return;
|
|
41
|
-
|
|
42
|
-
|
|
42
|
+
// if schemaField is missing
|
|
43
|
+
for (const el of routeObj.files) {
|
|
44
|
+
if (!el.schemaField)
|
|
43
45
|
throw new AppError({
|
|
44
|
-
message: "
|
|
46
|
+
message: "schemaField is required.",
|
|
45
47
|
statusCode: 400,
|
|
46
|
-
hint: "Provide
|
|
48
|
+
hint: "Provide schemaField in collection -> routeObj -> files [{...}].",
|
|
47
49
|
details: getErrorDetail(routeObj),
|
|
48
50
|
});
|
|
49
51
|
}
|
|
52
|
+
// if files not found
|
|
50
53
|
if (!Object.keys(req.files ?? {}).length)
|
|
51
54
|
throw new AppError({
|
|
52
55
|
message: "File is required.",
|
|
@@ -60,7 +63,7 @@ export const handleUploadFiles = async (req, routeObj) => {
|
|
|
60
63
|
});
|
|
61
64
|
const files = Object.values(req.files).flat();
|
|
62
65
|
const metaData = await Promise.all(files.map((file) => uploadFile(file, routeObj)));
|
|
63
|
-
const mongooseFieldName = routeObj.
|
|
66
|
+
const mongooseFieldName = routeObj.files[0].schemaField;
|
|
64
67
|
return { [mongooseFieldName]: metaData };
|
|
65
68
|
};
|
|
66
69
|
export default handleUploadFiles;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.js","sourceRoot":"","sources":["../../../src/js/upload/create.ts"],"names":[],"mappings":"AAAA,OAAO,WAAW,MAAM,aAAa,CAAC;AACtC,OAAO,QAAQ,MAAM,sBAAsB,CAAC;AAE5C,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAGtE,OAAO,cAAc,MAAM,4BAA4B,CAAC;AACxD,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE5C,MAA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