@starklabs/forge 1.1.2 → 1.1.3
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/app.d.ts +2 -1
- package/dist/js/app.d.ts.map +1 -1
- package/dist/js/app.js +1 -1
- package/dist/js/app.js.map +1 -1
- package/dist/js/auth/forgotPassword.d.ts +2 -2
- package/dist/js/auth/forgotPassword.d.ts.map +1 -1
- package/dist/js/auth/forgotPassword.js +6 -6
- package/dist/js/auth/forgotPassword.js.map +1 -1
- package/dist/js/auth/index.js +5 -5
- package/dist/js/auth/index.js.map +1 -1
- package/dist/js/auth/login.d.ts +2 -2
- package/dist/js/auth/login.d.ts.map +1 -1
- package/dist/js/auth/login.js +6 -6
- package/dist/js/auth/login.js.map +1 -1
- package/dist/js/auth/logout.d.ts +1 -1
- package/dist/js/auth/logout.d.ts.map +1 -1
- package/dist/js/auth/logout.js +2 -2
- package/dist/js/auth/logout.js.map +1 -1
- package/dist/js/auth/resendOTP.d.ts +2 -2
- package/dist/js/auth/resendOTP.d.ts.map +1 -1
- package/dist/js/auth/resendOTP.js +8 -8
- package/dist/js/auth/resendOTP.js.map +1 -1
- package/dist/js/auth/resetPassword.d.ts +2 -2
- package/dist/js/auth/resetPassword.d.ts.map +1 -1
- package/dist/js/auth/resetPassword.js +9 -9
- package/dist/js/auth/resetPassword.js.map +1 -1
- package/dist/js/auth/signup.d.ts +2 -2
- package/dist/js/auth/signup.d.ts.map +1 -1
- package/dist/js/auth/signup.js +8 -8
- package/dist/js/auth/signup.js.map +1 -1
- package/dist/js/auth/utils/authenticateUser.d.ts +2 -2
- package/dist/js/auth/utils/authenticateUser.d.ts.map +1 -1
- package/dist/js/auth/utils/authenticateUser.js +8 -8
- 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 +17 -8
- package/dist/js/auth/utils/createOTPModel.js.map +1 -1
- package/dist/js/auth/utils/createOTPUser.d.ts +2 -2
- package/dist/js/auth/utils/createOTPUser.d.ts.map +1 -1
- package/dist/js/auth/utils/createOTPUser.js +10 -10
- package/dist/js/auth/utils/createOTPUser.js.map +1 -1
- package/dist/js/auth/utils/createUser.d.ts +2 -2
- package/dist/js/auth/utils/createUser.d.ts.map +1 -1
- package/dist/js/auth/utils/createUser.js +7 -7
- package/dist/js/auth/utils/createUser.js.map +1 -1
- package/dist/js/auth/utils/getOTPModel.d.ts +1 -1
- package/dist/js/auth/utils/getOTPModel.d.ts.map +1 -1
- package/dist/js/auth/utils/getOTPModel.js +4 -4
- package/dist/js/auth/utils/getOTPModel.js.map +1 -1
- package/dist/js/auth/utils/getOTPUser.d.ts +2 -2
- package/dist/js/auth/utils/getOTPUser.d.ts.map +1 -1
- package/dist/js/auth/utils/getOTPUser.js +5 -5
- package/dist/js/auth/utils/getOTPUser.js.map +1 -1
- package/dist/js/auth/utils/getUser.d.ts +2 -2
- package/dist/js/auth/utils/getUser.d.ts.map +1 -1
- package/dist/js/auth/utils/getUser.js +5 -5
- package/dist/js/auth/utils/getUser.js.map +1 -1
- package/dist/js/auth/utils/handleIsVerified.d.ts +2 -2
- package/dist/js/auth/utils/handleIsVerified.d.ts.map +1 -1
- package/dist/js/auth/utils/handleIsVerified.js +3 -3
- package/dist/js/auth/utils/handleIsVerified.js.map +1 -1
- package/dist/js/auth/utils/modeMap.d.ts +8 -8
- package/dist/js/auth/utils/otpVerifiedResponse.d.ts +2 -2
- package/dist/js/auth/utils/otpVerifiedResponse.d.ts.map +1 -1
- package/dist/js/auth/utils/otpVerifiedResponse.js +4 -4
- package/dist/js/auth/utils/otpVerifiedResponse.js.map +1 -1
- package/dist/js/auth/utils/sendCookie.d.ts +4 -4
- package/dist/js/auth/utils/sendCookie.d.ts.map +1 -1
- package/dist/js/auth/utils/sendCookie.js +16 -16
- package/dist/js/auth/utils/sendCookie.js.map +1 -1
- package/dist/js/auth/utils/sendOTP.d.ts +1 -1
- package/dist/js/auth/utils/sendOTP.d.ts.map +1 -1
- package/dist/js/auth/utils/sendOTP.js +8 -8
- package/dist/js/auth/utils/sendOTP.js.map +1 -1
- package/dist/js/auth/utils/verifyCredentials.d.ts +2 -2
- package/dist/js/auth/utils/verifyCredentials.d.ts.map +1 -1
- package/dist/js/auth/utils/verifyCredentials.js +9 -9
- package/dist/js/auth/utils/verifyCredentials.js.map +1 -1
- package/dist/js/auth/verifyOTP.d.ts +2 -2
- package/dist/js/auth/verifyOTP.d.ts.map +1 -1
- package/dist/js/auth/verifyOTP.js +14 -14
- package/dist/js/auth/verifyOTP.js.map +1 -1
- package/dist/js/config/cloudinary.d.ts +1 -1
- package/dist/js/config/cloudinary.d.ts.map +1 -1
- package/dist/js/config/cloudinary.js +4 -4
- package/dist/js/config/cloudinary.js.map +1 -1
- package/dist/js/config/duration.d.ts +1 -1
- package/dist/js/config/duration.d.ts.map +1 -1
- package/dist/js/config/duration.js +4 -4
- package/dist/js/config/duration.js.map +1 -1
- package/dist/js/config/handleReqType.d.ts.map +1 -1
- package/dist/js/config/handleReqType.js +3 -1
- package/dist/js/config/handleReqType.js.map +1 -1
- package/dist/js/config/sendEmail.d.ts +2 -2
- package/dist/js/config/sendEmail.d.ts.map +1 -1
- package/dist/js/config/sendEmail.js +19 -19
- package/dist/js/config/sendEmail.js.map +1 -1
- package/dist/js/crud/create.d.ts +2 -2
- package/dist/js/crud/create.d.ts.map +1 -1
- package/dist/js/crud/create.js +11 -11
- package/dist/js/crud/create.js.map +1 -1
- package/dist/js/crud/createBulk.d.ts +2 -2
- package/dist/js/crud/createBulk.d.ts.map +1 -1
- package/dist/js/crud/createBulk.js +5 -5
- package/dist/js/crud/createBulk.js.map +1 -1
- package/dist/js/crud/handleUploads/file.add.d.ts +2 -2
- package/dist/js/crud/handleUploads/file.add.d.ts.map +1 -1
- package/dist/js/crud/handleUploads/file.add.js +12 -12
- package/dist/js/crud/handleUploads/file.add.js.map +1 -1
- package/dist/js/crud/handleUploads/file.delete.d.ts +2 -2
- package/dist/js/crud/handleUploads/file.delete.d.ts.map +1 -1
- package/dist/js/crud/handleUploads/file.delete.js +8 -8
- package/dist/js/crud/handleUploads/file.delete.js.map +1 -1
- package/dist/js/crud/handleUploads/file.update.d.ts +2 -2
- package/dist/js/crud/handleUploads/file.update.d.ts.map +1 -1
- package/dist/js/crud/handleUploads/file.update.js +8 -8
- package/dist/js/crud/handleUploads/file.update.js.map +1 -1
- package/dist/js/crud/index.d.ts.map +1 -1
- package/dist/js/crud/index.js +14 -11
- package/dist/js/crud/index.js.map +1 -1
- package/dist/js/crud/read.d.ts +2 -2
- package/dist/js/crud/read.d.ts.map +1 -1
- package/dist/js/crud/read.js +6 -6
- package/dist/js/crud/read.js.map +1 -1
- package/dist/js/crud/readAll.d.ts +2 -2
- package/dist/js/crud/readAll.d.ts.map +1 -1
- package/dist/js/crud/readAll.js +5 -5
- package/dist/js/crud/readAll.js.map +1 -1
- package/dist/js/crud/remove.d.ts +2 -2
- package/dist/js/crud/remove.d.ts.map +1 -1
- package/dist/js/crud/remove.js +6 -6
- package/dist/js/crud/remove.js.map +1 -1
- package/dist/js/crud/removeAll.d.ts +2 -2
- package/dist/js/crud/removeAll.d.ts.map +1 -1
- package/dist/js/crud/removeAll.js +5 -5
- package/dist/js/crud/removeAll.js.map +1 -1
- package/dist/js/crud/update.d.ts +2 -2
- package/dist/js/crud/update.d.ts.map +1 -1
- package/dist/js/crud/update.js +8 -8
- package/dist/js/crud/update.js.map +1 -1
- package/dist/js/crud/utils/authroizeAccess.d.ts +2 -2
- package/dist/js/crud/utils/authroizeAccess.d.ts.map +1 -1
- package/dist/js/crud/utils/authroizeAccess.js +11 -11
- package/dist/js/crud/utils/authroizeAccess.js.map +1 -1
- package/dist/js/crud/utils/getItem.d.ts +2 -2
- package/dist/js/crud/utils/getItem.d.ts.map +1 -1
- package/dist/js/crud/utils/getItem.js +9 -9
- package/dist/js/crud/utils/getItem.js.map +1 -1
- package/dist/js/crud/utils/getParam.d.ts +2 -2
- package/dist/js/crud/utils/getParam.d.ts.map +1 -1
- package/dist/js/crud/utils/getParam.js +4 -4
- package/dist/js/crud/utils/getParam.js.map +1 -1
- package/dist/js/health/health.collection.d.ts +1 -2
- package/dist/js/health/health.collection.d.ts.map +1 -1
- package/dist/js/health/health.collection.js.map +1 -1
- package/dist/js/health/index.js +2 -2
- package/dist/js/health/index.js.map +1 -1
- package/dist/js/index.d.ts +5 -3
- package/dist/js/index.d.ts.map +1 -1
- package/dist/js/index.js +5 -3
- package/dist/js/index.js.map +1 -1
- package/dist/js/lib/db.d.ts.map +1 -1
- package/dist/js/lib/db.js +10 -3
- package/dist/js/lib/db.js.map +1 -1
- package/dist/js/lib/model.factory.d.ts +1 -2
- package/dist/js/lib/model.factory.d.ts.map +1 -1
- package/dist/js/lib/model.factory.js +3 -3
- package/dist/js/lib/model.factory.js.map +1 -1
- package/dist/js/lib/mongoose.fields.d.ts.map +1 -1
- package/dist/js/lib/mongoose.fields.js +0 -1
- package/dist/js/lib/mongoose.fields.js.map +1 -1
- package/dist/js/middleware/auth.middleware.d.ts +1 -1
- package/dist/js/middleware/auth.middleware.d.ts.map +1 -1
- package/dist/js/middleware/auth.middleware.js +11 -11
- package/dist/js/middleware/auth.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 +11 -11
- package/dist/js/middleware/multer.middleware.js.map +1 -1
- package/dist/js/types/Collection.d.ts +1 -2
- package/dist/js/types/Collection.d.ts.map +1 -1
- package/dist/js/types/Routepath.d.ts +1 -1
- package/dist/js/types/Routepath.d.ts.map +1 -1
- package/dist/js/upload/create.d.ts +1 -1
- package/dist/js/upload/create.d.ts.map +1 -1
- package/dist/js/upload/create.js +18 -16
- package/dist/js/upload/create.js.map +1 -1
- package/dist/js/upload/delete.d.ts +1 -1
- package/dist/js/upload/delete.d.ts.map +1 -1
- package/dist/js/upload/delete.js +28 -28
- package/dist/js/upload/delete.js.map +1 -1
- package/dist/js/upload/update.d.ts +1 -1
- package/dist/js/upload/update.d.ts.map +1 -1
- package/dist/js/upload/update.js +37 -35
- package/dist/js/upload/update.js.map +1 -1
- package/dist/js/utils/getErrorDetail.d.ts +1 -1
- package/dist/js/utils/getErrorDetail.d.ts.map +1 -1
- package/dist/js/utils/getErrorDetail.js +4 -4
- 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 +4 -4
- package/dist/js/utils/getModel.js.map +1 -1
- package/dist/js/utils/handleJWT.d.ts +4 -4
- package/dist/js/utils/handleJWT.d.ts.map +1 -1
- package/dist/js/utils/handleJWT.js +10 -10
- package/dist/js/utils/handleJWT.js.map +1 -1
- package/dist/js/utils/libsodium.d.ts +4 -4
- package/dist/js/utils/libsodium.d.ts.map +1 -1
- package/dist/js/utils/libsodium.js +17 -17
- package/dist/js/utils/libsodium.js.map +1 -1
- package/dist/js/utils/sanitize.d.ts +2 -2
- package/dist/js/utils/sanitize.d.ts.map +1 -1
- package/dist/js/utils/sanitize.js +33 -7
- package/dist/js/utils/sanitize.js.map +1 -1
- package/dist/js/utils/validate.d.ts +1 -1
- package/dist/js/utils/validate.d.ts.map +1 -1
- package/dist/js/utils/validate.js +7 -7
- 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 +6 -6
- package/dist/js/utils/validationKeyError.js.map +1 -1
- package/package.json +3 -2
- package/readme.md +6 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"multer.middleware.js","sourceRoot":"","sources":["../../../src/js/middleware/multer.middleware.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ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AAK,kBAAkB;wBACrB,OAAO,GAAG,sBAAsB,CAAC;wBACjC,MAAM;oBAER,KAAK,mBAAmB;wBACtB,OAAO,GAAG,kBAAkB,CAAC;wBAC7B,MAAM;oBAER,KAAK,mBAAmB;wBACtB,OAAO,GAAG,2BAA2B,CAAC;wBACtC,MAAM;gBACV,CAAC;gBAED,OAAO,IAAI,CACT,IAAI,QAAQ,CAAC;oBACX,OAAO;oBACP,UAAU,EAAE,GAAG;oBACf,IAAI;oBACJ,IAAI,EACF,IAAI,KAAK,kBAAkB;wBACzB,CAAC,CAAC,qCAAqC;wBACvC,CAAC,CAAC,IAAI,KAAK,uBAAuB;4BAChC,CAAC,CAAC,sCAAsC;4BACxC,CAAC,CAAC,IAAI,KAAK,wBAAwB;gCACjC,CAAC,CAAC,8IAA8I;gCAChJ,CAAC,CAAC,yCAAyC;oBACnD,OAAO,EAAE;wBACP,OAAO,EAAE,QAAQ,CAAC,OAAO;wBACzB,MAAM,EAAE,QAAQ,CAAC,MAAM;wBACvB,IAAI,EAAE,QAAQ,CAAC,IAAI;qBACpB;iBACF,CAAC,CACH,CAAC;YACJ,CAAC;YAED,OAAO,IAAI,CACT,IAAI,QAAQ,CAAC;gBACX,OAAO,EAAE,qBAAqB;gBAC9B,UAAU,EAAE,GAAG;gBACf,IAAI,EAAE,eAAe;gBACrB,IAAI,EAAE,2DAA2D;gBACjE,OAAO,EAAE;oBACP,OAAO,EAAE,QAAQ,CAAC,OAAO;oBACzB,MAAM,EAAE,QAAQ,CAAC,MAAM;oBACvB,IAAI,EAAE,QAAQ,CAAC,IAAI;iBACpB;aACF,CAAC,CACH,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -2,12 +2,11 @@ import type { MongooseField } from "../lib/mongoose.fields.ts";
|
|
|
2
2
|
import type { Role } from "../lib/roles.ts";
|
|
3
3
|
import type { ZodValidation } from "../lib/zod.fields.ts";
|
|
4
4
|
import type { RoutePath } from "./Routepath.ts";
|
|
5
|
-
import type { healthHandlers } from "./healthHandlers.ts";
|
|
6
5
|
import type { authHandlers } from "./authHandlers.ts";
|
|
7
6
|
import type { crudHandlers } from "./crudHandlers.ts";
|
|
8
7
|
import type { uploadHandlers } from "./uploadHandlers.js";
|
|
9
8
|
import type { Upload } from "./upload.ts";
|
|
10
|
-
export type Handler =
|
|
9
|
+
export type Handler = authHandlers | crudHandlers | uploadHandlers;
|
|
11
10
|
export type AuthRole = "admin" | "adminOrOwner" | "authenticated" | "public";
|
|
12
11
|
export type RouteMethod = "get" | "post" | "patch" | "delete";
|
|
13
12
|
export type AuthMode = "credentials" | "otp";
|
|
@@ -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;AAE/D,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,KAAK,EAAE,
|
|
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;AAE/D,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAC1D,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;AACtD,OAAO,KAAK,EAAE,cAAc,EAAE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E,KAAK,EAAE,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,iBAAiB,CAAC,EAAE,cAAc,CAAC;IACnC,cAAc,CAAC,EAAE,cAAc,CAAC;CACjC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export type RoutePath = "/" | "/:id" | "/
|
|
1
|
+
export type RoutePath = "/" | "/:id" | "/update/:id" | "/delete/:id" | "/signup" | "/login" | "/logout" | "/forgot-password" | "/reset-password" | "/verify-otp" | "/resend-otp" | "/:id/addFile" | "/:id/updateFile" | "/:id/deleteFile";
|
|
2
2
|
//# sourceMappingURL=Routepath.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Routepath.d.ts","sourceRoot":"","sources":["../../../src/js/types/Routepath.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GAEjB,GAAG,GAGH,MAAM,
|
|
1
|
+
{"version":3,"file":"Routepath.d.ts","sourceRoot":"","sources":["../../../src/js/types/Routepath.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GAEjB,GAAG,GAGH,MAAM,GAON,aAAa,GACb,aAAa,GAKb,SAAS,GACT,QAAQ,GACR,SAAS,GAET,kBAAkB,GAClB,iBAAiB,GAGjB,aAAa,GACb,aAAa,GAmCb,cAAc,GACd,iBAAiB,GACjB,iBAAiB,CAAA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { StoreFile } from "../types/StoreFile.js";
|
|
2
2
|
import type { Route } from "../types/Collection.js";
|
|
3
3
|
import type { Request } from "express";
|
|
4
|
-
export declare const handleUploadFiles: (req: Request,
|
|
4
|
+
export declare const handleUploadFiles: (req: Request, routeObj: Route) => Promise<{
|
|
5
5
|
[x: string]: StoreFile[];
|
|
6
6
|
} | undefined>;
|
|
7
7
|
export default handleUploadFiles;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../src/js/upload/create.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAEvD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../src/js/upload/create.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAEvD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAkDvC,eAAO,MAAM,iBAAiB,GAAU,KAAK,OAAO,EAAE,UAAU,KAAK;;cAsCpE,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
|
package/dist/js/upload/create.js
CHANGED
|
@@ -2,11 +2,13 @@ import streamifier from "streamifier";
|
|
|
2
2
|
import AppError from "../utils/AppError.js";
|
|
3
3
|
import { cloudinary, setupCloudinary } from "../config/cloudinary.js";
|
|
4
4
|
import getErrorDetail from "../utils/getErrorDetail.js";
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
import { getEnvs } from "../config/envs.js";
|
|
6
|
+
const uploadFile = (file, routeObj) => {
|
|
7
|
+
setupCloudinary(routeObj);
|
|
8
|
+
const { cloudinaryFolderName } = getEnvs();
|
|
7
9
|
return new Promise((resolve, reject) => {
|
|
8
10
|
const stream = cloudinary.uploader.upload_stream({
|
|
9
|
-
folder: "
|
|
11
|
+
folder: cloudinaryFolderName || "starkForge",
|
|
10
12
|
}, (error, result) => {
|
|
11
13
|
if (error || !result) {
|
|
12
14
|
return reject(new AppError({
|
|
@@ -15,9 +17,9 @@ const uploadFile = (file, route) => {
|
|
|
15
17
|
code: "UPLOAD_CLOUDINARY_FAILED",
|
|
16
18
|
hint: "Verify your Cloudinary configuration, credentials, and network connectivity.",
|
|
17
19
|
details: {
|
|
18
|
-
handler:
|
|
19
|
-
method:
|
|
20
|
-
path:
|
|
20
|
+
handler: routeObj.handler,
|
|
21
|
+
method: routeObj.method,
|
|
22
|
+
path: routeObj.path,
|
|
21
23
|
},
|
|
22
24
|
}));
|
|
23
25
|
}
|
|
@@ -34,17 +36,17 @@ const uploadFile = (file, route) => {
|
|
|
34
36
|
streamifier.createReadStream(file.buffer).pipe(stream);
|
|
35
37
|
});
|
|
36
38
|
};
|
|
37
|
-
export const handleUploadFiles = async (req,
|
|
38
|
-
if (!
|
|
39
|
+
export const handleUploadFiles = async (req, routeObj) => {
|
|
40
|
+
if (!routeObj?.fileArray?.length)
|
|
39
41
|
return;
|
|
40
|
-
for (const el of
|
|
42
|
+
for (const el of routeObj.fileArray) {
|
|
41
43
|
if (!el.mongooseSchemaFieldName)
|
|
42
44
|
throw new AppError({
|
|
43
45
|
message: "mongooseSchemaFieldName is required.",
|
|
44
46
|
statusCode: 400,
|
|
45
47
|
code: "UPLOAD_MONGOOSE_FIELD_REQUIRED",
|
|
46
|
-
hint: "Provide mongooseSchemaFieldName in collection -> fileArray
|
|
47
|
-
details: getErrorDetail(
|
|
48
|
+
hint: "Provide mongooseSchemaFieldName in collection -> routeObj -> fileArray [{...}].",
|
|
49
|
+
details: getErrorDetail(routeObj),
|
|
48
50
|
});
|
|
49
51
|
}
|
|
50
52
|
if (!Object.keys(req.files ?? {}).length)
|
|
@@ -54,14 +56,14 @@ export const handleUploadFiles = async (req, route) => {
|
|
|
54
56
|
code: "UPLOAD_FILE_REQUIRED",
|
|
55
57
|
hint: "Upload at least one file using the configured upload field.",
|
|
56
58
|
details: {
|
|
57
|
-
handler:
|
|
58
|
-
method:
|
|
59
|
-
path:
|
|
59
|
+
handler: routeObj.handler,
|
|
60
|
+
method: routeObj.method,
|
|
61
|
+
path: routeObj.path,
|
|
60
62
|
},
|
|
61
63
|
});
|
|
62
64
|
const files = Object.values(req.files).flat();
|
|
63
|
-
const metaData = await Promise.all(files.map((file) => uploadFile(file,
|
|
64
|
-
const mongooseFieldName =
|
|
65
|
+
const metaData = await Promise.all(files.map((file) => uploadFile(file, routeObj)));
|
|
66
|
+
const mongooseFieldName = routeObj.fileArray[0].mongooseSchemaFieldName;
|
|
65
67
|
return { [mongooseFieldName]: metaData };
|
|
66
68
|
};
|
|
67
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;
|
|
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,MAAM,UAAU,GAAG,CACjB,IAAyB,EACzB,QAAe,EACK,EAAE;IACtB,eAAe,CAAC,QAAQ,CAAC,CAAC;IAE1B,MAAM,EAAE,oBAAoB,EAAE,GAAG,OAAO,EAAE,CAAC;IAE3C,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,MAAM,MAAM,GAAG,UAAU,CAAC,QAAQ,CAAC,aAAa,CAC9C;YACE,MAAM,EAAE,oBAAoB,IAAI,YAAY;SAC7C,EACD,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE;YAChB,IAAI,KAAK,IAAI,CAAC,MAAM,EAAE,CAAC;gBACrB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D,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,MAAM;QACtC,MAAM,IAAI,QAAQ,CAAC;YACjB,OAAO,EAAE,mBAAmB;YAC5B,UAAU,EAAE,GAAG;YACf,IAAI,EAAE,sBAAsB;YAC5B,IAAI,EAAE,6DAA6D;YACnE,OAAO,EAAE;gBACP,OAAO,EAAE,QAAQ,CAAC,OAAO;gBACzB,MAAM,EAAE,QAAQ,CAAC,MAAM;gBACvB,IAAI,EAAE,QAAQ,CAAC,IAAI;aACpB;SACF,CAAC,CAAC;IAEL,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,KAAM,CAAC,CAAC,IAAI,EAAE,CAAC;IAE/C,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,GAAG,CAChC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,UAAU,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,CAChD,CAAC;IACF,MAAM,iBAAiB,GAAG,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAE,CAAC,uBAAuB,CAAC;IAEzE,OAAO,EAAE,CAAC,iBAA2B,CAAC,EAAE,QAAQ,EAAE,CAAC;AACrD,CAAC,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Route } from "../types/Collection.ts";
|
|
2
|
-
declare const handleDeleteFile: (
|
|
2
|
+
declare const handleDeleteFile: (routeObj: Route, body: any, item: any) => Promise<{
|
|
3
3
|
deleted: boolean;
|
|
4
4
|
_id: any;
|
|
5
5
|
mongooseField: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"delete.d.ts","sourceRoot":"","sources":["../../../src/js/upload/delete.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAGpD,QAAA,MAAM,gBAAgB,GAAU,
|
|
1
|
+
{"version":3,"file":"delete.d.ts","sourceRoot":"","sources":["../../../src/js/upload/delete.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAGpD,QAAA,MAAM,gBAAgB,GAAU,UAAU,KAAK,EAAE,MAAM,GAAG,EAAE,MAAM,GAAG;;;;EAoIpE,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
|
package/dist/js/upload/delete.js
CHANGED
|
@@ -1,34 +1,34 @@
|
|
|
1
1
|
import AppError from "../utils/AppError.js";
|
|
2
2
|
import { cloudinary, setupCloudinary } from "../config/cloudinary.js";
|
|
3
3
|
import AppLog from "../utils/AppLog.js";
|
|
4
|
-
const handleDeleteFile = async (
|
|
5
|
-
setupCloudinary(
|
|
6
|
-
const fileArray =
|
|
4
|
+
const handleDeleteFile = async (routeObj, body, item) => {
|
|
5
|
+
setupCloudinary(routeObj);
|
|
6
|
+
const fileArray = routeObj.fileArray;
|
|
7
7
|
if (!Array.isArray(fileArray) || fileArray.length === 0)
|
|
8
8
|
throw new AppError({
|
|
9
9
|
message: "fileArray is required.",
|
|
10
10
|
statusCode: 400,
|
|
11
11
|
code: "UPLOAD_ARRAY_REQUIRED",
|
|
12
|
-
hint: "Provide fileArray in the collection
|
|
12
|
+
hint: "Provide fileArray in the collection routeObj configuration for delete handlers.",
|
|
13
13
|
details: {
|
|
14
|
-
handler:
|
|
15
|
-
method:
|
|
16
|
-
path:
|
|
14
|
+
handler: routeObj.handler,
|
|
15
|
+
method: routeObj.method,
|
|
16
|
+
path: routeObj.path,
|
|
17
17
|
},
|
|
18
18
|
});
|
|
19
19
|
if (fileArray.length > 1)
|
|
20
|
-
AppLog("warn", "deleteFile", `fileArray in collection has more than 1 items for handler: '${
|
|
20
|
+
AppLog("warn", "deleteFile", `fileArray in collection has more than 1 items for handler: '${routeObj.handler}', method: '${routeObj.method}' and path: '${routeObj.path}' to delete.`);
|
|
21
21
|
const mongooseField = fileArray[0]?.mongooseSchemaFieldName;
|
|
22
22
|
if (typeof mongooseField !== "string" || mongooseField.trim() === "")
|
|
23
23
|
throw new AppError({
|
|
24
24
|
message: "mongooseSchemaFieldName is required.",
|
|
25
25
|
statusCode: 400,
|
|
26
26
|
code: "UPLOAD_MONGOOSE_FIELD_REQUIRED",
|
|
27
|
-
hint: "Provide mongooseSchemaFieldName in collection -> fileArray
|
|
27
|
+
hint: "Provide mongooseSchemaFieldName in collection -> routeObj -> fileArray [{...}].",
|
|
28
28
|
details: {
|
|
29
|
-
handler:
|
|
30
|
-
method:
|
|
31
|
-
path:
|
|
29
|
+
handler: routeObj.handler,
|
|
30
|
+
method: routeObj.method,
|
|
31
|
+
path: routeObj.path,
|
|
32
32
|
},
|
|
33
33
|
});
|
|
34
34
|
const mongooseFilesArray = item[mongooseField];
|
|
@@ -39,9 +39,9 @@ const handleDeleteFile = async (route, body, item) => {
|
|
|
39
39
|
code: "SCHEMA_FIELD_REQUIRED",
|
|
40
40
|
hint: "Ensure mongooseSchemaFieldName matches an existing schema field.",
|
|
41
41
|
details: {
|
|
42
|
-
handler:
|
|
43
|
-
method:
|
|
44
|
-
path:
|
|
42
|
+
handler: routeObj.handler,
|
|
43
|
+
method: routeObj.method,
|
|
44
|
+
path: routeObj.path,
|
|
45
45
|
},
|
|
46
46
|
});
|
|
47
47
|
const validationIdentifierKey = fileArray[0]?.validationIdentifierKey;
|
|
@@ -51,11 +51,11 @@ const handleDeleteFile = async (route, body, item) => {
|
|
|
51
51
|
message: "validationIdentifierKey is required.",
|
|
52
52
|
statusCode: 400,
|
|
53
53
|
code: "VALIDATION_KEY_REQUIRED",
|
|
54
|
-
hint: "Provide validationIdentifierKey in collection -> fileArray
|
|
54
|
+
hint: "Provide validationIdentifierKey in collection -> routeObj -> fileArray [{...}].",
|
|
55
55
|
details: {
|
|
56
|
-
handler:
|
|
57
|
-
method:
|
|
58
|
-
path:
|
|
56
|
+
handler: routeObj.handler,
|
|
57
|
+
method: routeObj.method,
|
|
58
|
+
path: routeObj.path,
|
|
59
59
|
},
|
|
60
60
|
});
|
|
61
61
|
if (!body[validationIdentifierKey])
|
|
@@ -65,9 +65,9 @@ const handleDeleteFile = async (route, body, item) => {
|
|
|
65
65
|
code: "VALIDATION_REQUIRED_FIELD_MISSING",
|
|
66
66
|
hint: `Provide '${validationIdentifierKey}' in the request body.`,
|
|
67
67
|
details: {
|
|
68
|
-
handler:
|
|
69
|
-
method:
|
|
70
|
-
path:
|
|
68
|
+
handler: routeObj.handler,
|
|
69
|
+
method: routeObj.method,
|
|
70
|
+
path: routeObj.path,
|
|
71
71
|
},
|
|
72
72
|
});
|
|
73
73
|
const targetItem = mongooseFilesArray.find((el) => el._id.toString() === body[validationIdentifierKey]);
|
|
@@ -78,9 +78,9 @@ const handleDeleteFile = async (route, body, item) => {
|
|
|
78
78
|
code: "CRUD_ITEM_NOT_FOUND",
|
|
79
79
|
hint: "Verify the provided file identifier exists in the stored file array.",
|
|
80
80
|
details: {
|
|
81
|
-
handler:
|
|
82
|
-
method:
|
|
83
|
-
path:
|
|
81
|
+
handler: routeObj.handler,
|
|
82
|
+
method: routeObj.method,
|
|
83
|
+
path: routeObj.path,
|
|
84
84
|
},
|
|
85
85
|
});
|
|
86
86
|
if (typeof targetItem.storageKey !== "string" ||
|
|
@@ -91,9 +91,9 @@ const handleDeleteFile = async (route, body, item) => {
|
|
|
91
91
|
code: "UPLOAD_STORAGE_KEY_REQUIRED",
|
|
92
92
|
hint: "Ensure the stored file contains a valid storageKey before deletion.",
|
|
93
93
|
details: {
|
|
94
|
-
handler:
|
|
95
|
-
method:
|
|
96
|
-
path:
|
|
94
|
+
handler: routeObj.handler,
|
|
95
|
+
method: routeObj.method,
|
|
96
|
+
path: routeObj.path,
|
|
97
97
|
},
|
|
98
98
|
});
|
|
99
99
|
await cloudinary.uploader.destroy(targetItem.storageKey);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"delete.js","sourceRoot":"","sources":["../../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C;IAEL,MAAM,UAAU,CAAC,QAAQ,CAAC,OAAO,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;IAEzD,OAAO;QACL,OAAO,EAAE,IAAI;QACb,GAAG,EAAE,IAAI,CAAC,uBAAuB,CAAC;QAClC,aAAa;KACd,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { StoreFile } from "../types/StoreFile.js";
|
|
2
2
|
import type { Route } from "../types/Collection.ts";
|
|
3
3
|
import type { Request } from "express";
|
|
4
|
-
declare const handleUpdateFile: (req: Request,
|
|
4
|
+
declare const handleUpdateFile: (req: Request, routeObj: Route, body: any, item: any) => Promise<{
|
|
5
5
|
updated: StoreFile;
|
|
6
6
|
mongooseField: string;
|
|
7
7
|
_id: any;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../../src/js/upload/update.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../../src/js/upload/update.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAkDvC,QAAA,MAAM,gBAAgB,GACpB,KAAK,OAAO,EACZ,UAAU,KAAK,EACf,MAAM,GAAG,EACT,MAAM,GAAG;;;;cAuIV,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
|
package/dist/js/upload/update.js
CHANGED
|
@@ -2,11 +2,13 @@ import streamifier from "streamifier";
|
|
|
2
2
|
import AppError from "../utils/AppError.js";
|
|
3
3
|
import { cloudinary, setupCloudinary } from "../config/cloudinary.js";
|
|
4
4
|
import AppLog from "../utils/AppLog.js";
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
import { getEnvs } from "../config/envs.js";
|
|
6
|
+
const uploadFile = (file, routeObj) => {
|
|
7
|
+
setupCloudinary(routeObj);
|
|
8
|
+
const { cloudinaryFolderName } = getEnvs();
|
|
7
9
|
return new Promise((resolve, reject) => {
|
|
8
10
|
const stream = cloudinary.uploader.upload_stream({
|
|
9
|
-
folder: "
|
|
11
|
+
folder: cloudinaryFolderName || "starkForge",
|
|
10
12
|
}, async (error, result) => {
|
|
11
13
|
if (error || !result) {
|
|
12
14
|
return reject(new AppError({
|
|
@@ -15,9 +17,9 @@ const uploadFile = (file, route) => {
|
|
|
15
17
|
code: "UPLOAD_CLOUDINARY_FAILED",
|
|
16
18
|
hint: "Verify your Cloudinary configuration, credentials, and network connectivity.",
|
|
17
19
|
details: {
|
|
18
|
-
handler:
|
|
19
|
-
method:
|
|
20
|
-
path:
|
|
20
|
+
handler: routeObj.handler,
|
|
21
|
+
method: routeObj.method,
|
|
22
|
+
path: routeObj.path,
|
|
21
23
|
},
|
|
22
24
|
}));
|
|
23
25
|
}
|
|
@@ -34,34 +36,34 @@ const uploadFile = (file, route) => {
|
|
|
34
36
|
streamifier.createReadStream(file.buffer).pipe(stream);
|
|
35
37
|
});
|
|
36
38
|
};
|
|
37
|
-
const handleUpdateFile = async (req,
|
|
39
|
+
const handleUpdateFile = async (req, routeObj, body, item) => {
|
|
38
40
|
const reqFilesArray = Object.keys(req.files ?? {});
|
|
39
|
-
const fileArray =
|
|
41
|
+
const fileArray = routeObj.fileArray;
|
|
40
42
|
if (!Array.isArray(fileArray) || fileArray.length === 0)
|
|
41
43
|
throw new AppError({
|
|
42
44
|
message: "fileArray is required.",
|
|
43
45
|
statusCode: 400,
|
|
44
46
|
code: "UPLOAD_ARRAY_REQUIRED",
|
|
45
|
-
hint: "Provide fileArray in the collection
|
|
47
|
+
hint: "Provide fileArray in the collection routeObj configuration for update handlers.",
|
|
46
48
|
details: {
|
|
47
|
-
handler:
|
|
48
|
-
method:
|
|
49
|
-
path:
|
|
49
|
+
handler: routeObj.handler,
|
|
50
|
+
method: routeObj.method,
|
|
51
|
+
path: routeObj.path,
|
|
50
52
|
},
|
|
51
53
|
});
|
|
52
54
|
if (fileArray.length > 1)
|
|
53
|
-
AppLog("warn", "updateFile", `fileArray in collection has more than 1 items for handler: '${
|
|
55
|
+
AppLog("warn", "updateFile", `fileArray in collection has more than 1 items for handler: '${routeObj.handler}', method: '${routeObj.method}' and path: '${routeObj.path}' to update.`);
|
|
54
56
|
const mongooseField = fileArray[0]?.mongooseSchemaFieldName;
|
|
55
57
|
if (typeof mongooseField !== "string" || mongooseField.trim() === "")
|
|
56
58
|
throw new AppError({
|
|
57
59
|
message: "mongooseSchemaFieldName is required.",
|
|
58
60
|
statusCode: 400,
|
|
59
61
|
code: "UPLOAD_MONGOOSE_FIELD_REQUIRED",
|
|
60
|
-
hint: "Provide mongooseSchemaFieldName in collection -> fileArray
|
|
62
|
+
hint: "Provide mongooseSchemaFieldName in collection -> routeObj -> fileArray [{...}].",
|
|
61
63
|
details: {
|
|
62
|
-
handler:
|
|
63
|
-
method:
|
|
64
|
-
path:
|
|
64
|
+
handler: routeObj.handler,
|
|
65
|
+
method: routeObj.method,
|
|
66
|
+
path: routeObj.path,
|
|
65
67
|
},
|
|
66
68
|
});
|
|
67
69
|
if (!reqFilesArray.length)
|
|
@@ -71,13 +73,13 @@ const handleUpdateFile = async (req, route, body, item) => {
|
|
|
71
73
|
code: "UPLOAD_FILE_REQUIRED",
|
|
72
74
|
hint: "Upload a file using the configured upload field.",
|
|
73
75
|
details: {
|
|
74
|
-
handler:
|
|
75
|
-
method:
|
|
76
|
-
path:
|
|
76
|
+
handler: routeObj.handler,
|
|
77
|
+
method: routeObj.method,
|
|
78
|
+
path: routeObj.path,
|
|
77
79
|
},
|
|
78
80
|
});
|
|
79
81
|
if (reqFilesArray.length > 1)
|
|
80
|
-
AppLog("warn", "updateFile", `req.files has more than 1 fieldNames: '${reqFilesArray.join(", ")}' for handler: '${
|
|
82
|
+
AppLog("warn", "updateFile", `req.files has more than 1 fieldNames: '${reqFilesArray.join(", ")}' for handler: '${routeObj.handler}', method: '${routeObj.method}' and path: '${routeObj.path}' to update.`);
|
|
81
83
|
const mongooseFilesArray = item[mongooseField];
|
|
82
84
|
if (!mongooseFilesArray)
|
|
83
85
|
throw new AppError({
|
|
@@ -86,9 +88,9 @@ const handleUpdateFile = async (req, route, body, item) => {
|
|
|
86
88
|
code: "SCHEMA_FIELD_REQUIRED",
|
|
87
89
|
hint: "Ensure mongooseSchemaFieldName matches an existing schema field.",
|
|
88
90
|
details: {
|
|
89
|
-
handler:
|
|
90
|
-
method:
|
|
91
|
-
path:
|
|
91
|
+
handler: routeObj.handler,
|
|
92
|
+
method: routeObj.method,
|
|
93
|
+
path: routeObj.path,
|
|
92
94
|
},
|
|
93
95
|
});
|
|
94
96
|
const validationIdentifierKey = fileArray[0].validationIdentifierKey;
|
|
@@ -98,11 +100,11 @@ const handleUpdateFile = async (req, route, body, item) => {
|
|
|
98
100
|
message: "validationIdentifierKey is required.",
|
|
99
101
|
statusCode: 400,
|
|
100
102
|
code: "VALIDATION_KEY_REQUIRED",
|
|
101
|
-
hint: "Provide validationIdentifierKey in collection -> fileArray
|
|
103
|
+
hint: "Provide validationIdentifierKey in collection -> routeObj -> fileArray [{...}].",
|
|
102
104
|
details: {
|
|
103
|
-
handler:
|
|
104
|
-
method:
|
|
105
|
-
path:
|
|
105
|
+
handler: routeObj.handler,
|
|
106
|
+
method: routeObj.method,
|
|
107
|
+
path: routeObj.path,
|
|
106
108
|
},
|
|
107
109
|
});
|
|
108
110
|
if (!body[validationIdentifierKey])
|
|
@@ -112,9 +114,9 @@ const handleUpdateFile = async (req, route, body, item) => {
|
|
|
112
114
|
code: "VALIDATION_REQUIRED_FIELD_MISSING",
|
|
113
115
|
hint: `Provide '${validationIdentifierKey}' in the request body.`,
|
|
114
116
|
details: {
|
|
115
|
-
handler:
|
|
116
|
-
method:
|
|
117
|
-
path:
|
|
117
|
+
handler: routeObj.handler,
|
|
118
|
+
method: routeObj.method,
|
|
119
|
+
path: routeObj.path,
|
|
118
120
|
},
|
|
119
121
|
});
|
|
120
122
|
const oldItem = mongooseFilesArray.find((el) => el._id.toString() === body[validationIdentifierKey]);
|
|
@@ -125,13 +127,13 @@ const handleUpdateFile = async (req, route, body, item) => {
|
|
|
125
127
|
code: "CRUD_ITEM_NOT_FOUND",
|
|
126
128
|
hint: "Verify the provided file identifier exists in the stored file array.",
|
|
127
129
|
details: {
|
|
128
|
-
handler:
|
|
129
|
-
method:
|
|
130
|
-
path:
|
|
130
|
+
handler: routeObj.handler,
|
|
131
|
+
method: routeObj.method,
|
|
132
|
+
path: routeObj.path,
|
|
131
133
|
},
|
|
132
134
|
});
|
|
133
135
|
if (!Array.isArray(req.files)) {
|
|
134
|
-
const updated = await uploadFile(req.files[reqFilesArray[0]][0],
|
|
136
|
+
const updated = await uploadFile(req.files[reqFilesArray[0]][0], routeObj);
|
|
135
137
|
await cloudinary.uploader.destroy(oldItem.storageKey);
|
|
136
138
|
return {
|
|
137
139
|
updated,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update.js","sourceRoot":"","sources":["../../../src/js/upload/update.ts"],"names":[],"mappings":"AAAA,OAAO,WAAW,MAAM,aAAa,CAAC;AACtC,OAAO,QAAQ,MAAM,sBAAsB,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAItE,OAAO,MAAM,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"update.js","sourceRoot":"","sources":["../../../src/js/upload/update.ts"],"names":[],"mappings":"AAAA,OAAO,WAAW,MAAM,aAAa,CAAC;AACtC,OAAO,QA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C,KAAK,CAAC,EAAE,CAAC;QAC9B,MAAM,OAAO,GAAG,MAAM,UAAU,CAAC,GAAG,CAAC,KAAM,CAAC,aAAa,CAAC,CAAC,CAAE,CAAE,CAAC,CAAC,CAAE,EAAE,QAAQ,CAAC,CAAC;QAE/E,MAAM,UAAU,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;QAEtD,OAAO;YACL,OAAO;YACP,aAAa;YACb,GAAG,EAAE,IAAI,CAAC,uBAAuB,CAAC;SACnC,CAAC;IACJ,CAAC;AACH,CAAC,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Route } from "../types/Collection.js";
|
|
2
|
-
declare const getErrorDetail: (
|
|
2
|
+
declare const getErrorDetail: (routeObj: Route) => {
|
|
3
3
|
handler: import("../types/Collection.js").Handler;
|
|
4
4
|
method: import("../types/Collection.js").RouteMethod;
|
|
5
5
|
path: import("../types/Routepath.js").RoutePath;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getErrorDetail.d.ts","sourceRoot":"","sources":["../../../src/js/utils/getErrorDetail.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAEpD,QAAA,MAAM,cAAc,GAAI,
|
|
1
|
+
{"version":3,"file":"getErrorDetail.d.ts","sourceRoot":"","sources":["../../../src/js/utils/getErrorDetail.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAEpD,QAAA,MAAM,cAAc,GAAI,UAAU,KAAK;;;;CAMtC,CAAC;AAEF,eAAe,cAAc,CAAA"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
const getErrorDetail = (
|
|
1
|
+
const getErrorDetail = (routeObj) => {
|
|
2
2
|
return {
|
|
3
|
-
handler:
|
|
4
|
-
method:
|
|
5
|
-
path:
|
|
3
|
+
handler: routeObj.handler,
|
|
4
|
+
method: routeObj.method,
|
|
5
|
+
path: routeObj.path,
|
|
6
6
|
};
|
|
7
7
|
};
|
|
8
8
|
export default getErrorDetail;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getErrorDetail.js","sourceRoot":"","sources":["../../../src/js/utils/getErrorDetail.ts"],"names":[],"mappings":"AAEA,MAAM,cAAc,GAAG,CAAC,
|
|
1
|
+
{"version":3,"file":"getErrorDetail.js","sourceRoot":"","sources":["../../../src/js/utils/getErrorDetail.ts"],"names":[],"mappings":"AAEA,MAAM,cAAc,GAAG,CAAC,QAAe,EAAE,EAAE;IACzC,OAAO;QACL,OAAO,EAAE,QAAQ,CAAC,OAAO;QACzB,MAAM,EAAE,QAAQ,CAAC,MAAM;QACvB,IAAI,EAAE,QAAQ,CAAC,IAAI;KACpB,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,cAAc,CAAA"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { Route } from "../types/Collection.js";
|
|
2
|
-
declare const getModel: ({ modelName, routeName,
|
|
2
|
+
declare const getModel: ({ modelName, routeName, routeObj, }: {
|
|
3
3
|
modelName: string;
|
|
4
4
|
routeName: string;
|
|
5
|
-
|
|
6
|
-
}) =>
|
|
5
|
+
routeObj: Route;
|
|
6
|
+
}) => any;
|
|
7
7
|
export default getModel;
|
|
8
8
|
//# sourceMappingURL=getModel.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getModel.d.ts","sourceRoot":"","sources":["../../../src/js/utils/getModel.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAEpD,QAAA,MAAM,QAAQ,GAAI,
|
|
1
|
+
{"version":3,"file":"getModel.d.ts","sourceRoot":"","sources":["../../../src/js/utils/getModel.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAEpD,QAAA,MAAM,QAAQ,GAAI,qCAIf;IACD,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,KAAK,CAAC;CACjB,QAwBA,CAAC;AAEF,eAAe,QAAQ,CAAC"}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import registerModel from "../lib/model.registry.js";
|
|
2
2
|
import AppError from "./AppError.js";
|
|
3
3
|
import getErrorDetail from "./getErrorDetail.js";
|
|
4
|
-
const getModel = ({ modelName, routeName,
|
|
4
|
+
const getModel = ({ modelName, routeName, routeObj, }) => {
|
|
5
5
|
if (!modelName) {
|
|
6
6
|
throw new AppError({
|
|
7
|
-
message: `Model name is required for
|
|
7
|
+
message: `Model name is required for routeObj '${routeName}'`,
|
|
8
8
|
statusCode: 500,
|
|
9
9
|
code: "MODEL_NAME_REQUIRED",
|
|
10
10
|
hint: "Provide a valid modelName when configuring the collection.",
|
|
11
|
-
details: getErrorDetail(
|
|
11
|
+
details: getErrorDetail(routeObj),
|
|
12
12
|
});
|
|
13
13
|
}
|
|
14
14
|
const Model = registerModel[modelName];
|
|
@@ -18,7 +18,7 @@ const getModel = ({ modelName, routeName, route, }) => {
|
|
|
18
18
|
statusCode: 500,
|
|
19
19
|
code: "MODEL_NOT_REGISTERED",
|
|
20
20
|
hint: "Register the model before using it in a collection.",
|
|
21
|
-
details: getErrorDetail(
|
|
21
|
+
details: getErrorDetail(routeObj),
|
|
22
22
|
});
|
|
23
23
|
}
|
|
24
24
|
return Model;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getModel.js","sourceRoot":"","sources":["../../../src/js/utils/getModel.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,MAAM,0BAA0B,CAAC;AACrD,OAAO,QAAQ,MAAM,eAAe,CAAC;AACrC,OAAO,cAAc,MAAM,qBAAqB,CAAC;AAGjD,MAAM,QAAQ,GAAG,CAAC,EAChB,SAAS,EACT,SAAS,EACT,
|
|
1
|
+
{"version":3,"file":"getModel.js","sourceRoot":"","sources":["../../../src/js/utils/getModel.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,MAAM,0BAA0B,CAAC;AACrD,OAAO,QAAQ,MAAM,eAAe,CAAC;AACrC,OAAO,cAAc,MAAM,qBAAqB,CAAC;AAGjD,MAAM,QAAQ,GAAG,CAAC,EAChB,SAAS,EACT,SAAS,EACT,QAAQ,GAKT,EAAE,EAAE;IACH,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,MAAM,IAAI,QAAQ,CAAC;YACjB,OAAO,EAAE,wCAAwC,SAAS,GAAG;YAC7D,UAAU,EAAE,GAAG;YACf,IAAI,EAAE,qBAAqB;YAC3B,IAAI,EAAE,4DAA4D;YAClE,OAAO,EAAE,cAAc,CAAC,QAAQ,CAAC;SAClC,CAAC,CAAC;IACL,CAAC;IAED,MAAM,KAAK,GAAG,aAAa,CAAC,SAAS,CAAC,CAAC;IAEvC,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,MAAM,IAAI,QAAQ,CAAC;YACjB,OAAO,EAAE,UAAU,SAAS,qBAAqB;YACjD,UAAU,EAAE,GAAG;YACf,IAAI,EAAE,sBAAsB;YAC5B,IAAI,EAAE,qDAAqD;YAC3D,OAAO,EAAE,cAAc,CAAC,QAAQ,CAAC;SAClC,CAAC,CAAC;IACL,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAEF,eAAe,QAAQ,CAAC"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { type JwtPayload } from "jsonwebtoken";
|
|
2
2
|
import type { Route } from "../types/Collection.js";
|
|
3
|
-
export declare const signJWT: ({ payload,
|
|
3
|
+
export declare const signJWT: ({ payload, routeObj, }: {
|
|
4
4
|
payload: string | object | Buffer;
|
|
5
|
-
|
|
5
|
+
routeObj: Route;
|
|
6
6
|
}) => string;
|
|
7
|
-
export declare const verifyJWT: ({ token,
|
|
7
|
+
export declare const verifyJWT: ({ token, routeObj, }: {
|
|
8
8
|
token: string;
|
|
9
|
-
|
|
9
|
+
routeObj: Route;
|
|
10
10
|
}) => string | JwtPayload;
|
|
11
11
|
//# sourceMappingURL=handleJWT.d.ts.map
|