@starklabs/forge 1.0.1
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/admin/index.d.ts +4 -0
- package/dist/js/admin/index.d.ts.map +1 -0
- package/dist/js/admin/index.js +5 -0
- package/dist/js/admin/index.js.map +1 -0
- package/dist/js/app.d.ts +3 -0
- package/dist/js/app.d.ts.map +1 -0
- package/dist/js/app.js +55 -0
- package/dist/js/app.js.map +1 -0
- package/dist/js/auth/bunch.auth.d.ts +8 -0
- package/dist/js/auth/bunch.auth.d.ts.map +1 -0
- package/dist/js/auth/bunch.auth.js +8 -0
- package/dist/js/auth/bunch.auth.js.map +1 -0
- package/dist/js/auth/createOTPModel.d.ts +2 -0
- package/dist/js/auth/createOTPModel.d.ts.map +1 -0
- package/dist/js/auth/createOTPModel.js +2 -0
- package/dist/js/auth/createOTPModel.js.map +1 -0
- package/dist/js/auth/forgotPassword.d.ts +10 -0
- package/dist/js/auth/forgotPassword.d.ts.map +1 -0
- package/dist/js/auth/forgotPassword.js +39 -0
- package/dist/js/auth/forgotPassword.js.map +1 -0
- package/dist/js/auth/index.d.ts +5 -0
- package/dist/js/auth/index.d.ts.map +1 -0
- package/dist/js/auth/index.js +26 -0
- package/dist/js/auth/index.js.map +1 -0
- package/dist/js/auth/login.d.ts +10 -0
- package/dist/js/auth/login.d.ts.map +1 -0
- package/dist/js/auth/login.js +32 -0
- package/dist/js/auth/login.js.map +1 -0
- package/dist/js/auth/logout.d.ts +5 -0
- package/dist/js/auth/logout.d.ts.map +1 -0
- package/dist/js/auth/logout.js +10 -0
- package/dist/js/auth/logout.js.map +1 -0
- package/dist/js/auth/resendOTP.d.ts +10 -0
- package/dist/js/auth/resendOTP.d.ts.map +1 -0
- package/dist/js/auth/resendOTP.js +62 -0
- package/dist/js/auth/resendOTP.js.map +1 -0
- package/dist/js/auth/resetPassword.d.ts +10 -0
- package/dist/js/auth/resetPassword.d.ts.map +1 -0
- package/dist/js/auth/resetPassword.js +60 -0
- package/dist/js/auth/resetPassword.js.map +1 -0
- package/dist/js/auth/sendOTP.d.ts +6 -0
- package/dist/js/auth/sendOTP.d.ts.map +1 -0
- package/dist/js/auth/sendOTP.js +28 -0
- package/dist/js/auth/sendOTP.js.map +1 -0
- package/dist/js/auth/signup.d.ts +10 -0
- package/dist/js/auth/signup.d.ts.map +1 -0
- package/dist/js/auth/signup.js +47 -0
- package/dist/js/auth/signup.js.map +1 -0
- package/dist/js/auth/twoFactorAuth.d.ts +2 -0
- package/dist/js/auth/twoFactorAuth.d.ts.map +1 -0
- package/dist/js/auth/twoFactorAuth.js +3 -0
- package/dist/js/auth/twoFactorAuth.js.map +1 -0
- package/dist/js/auth/utils/authenticateUser.d.ts +11 -0
- package/dist/js/auth/utils/authenticateUser.d.ts.map +1 -0
- package/dist/js/auth/utils/authenticateUser.js +60 -0
- package/dist/js/auth/utils/authenticateUser.js.map +1 -0
- package/dist/js/auth/utils/createOTPModel.d.ts +4 -0
- package/dist/js/auth/utils/createOTPModel.d.ts.map +1 -0
- package/dist/js/auth/utils/createOTPModel.js +28 -0
- package/dist/js/auth/utils/createOTPModel.js.map +1 -0
- package/dist/js/auth/utils/createOTPUser.d.ts +12 -0
- package/dist/js/auth/utils/createOTPUser.d.ts.map +1 -0
- package/dist/js/auth/utils/createOTPUser.js +63 -0
- package/dist/js/auth/utils/createOTPUser.js.map +1 -0
- package/dist/js/auth/utils/createUser.d.ts +11 -0
- package/dist/js/auth/utils/createUser.d.ts.map +1 -0
- package/dist/js/auth/utils/createUser.js +42 -0
- package/dist/js/auth/utils/createUser.js.map +1 -0
- package/dist/js/auth/utils/deleteOTPUser.d.ts +3 -0
- package/dist/js/auth/utils/deleteOTPUser.d.ts.map +1 -0
- package/dist/js/auth/utils/deleteOTPUser.js +3 -0
- package/dist/js/auth/utils/deleteOTPUser.js.map +1 -0
- package/dist/js/auth/utils/findUser.d.ts +2 -0
- package/dist/js/auth/utils/findUser.d.ts.map +1 -0
- package/dist/js/auth/utils/findUser.js +2 -0
- package/dist/js/auth/utils/findUser.js.map +1 -0
- package/dist/js/auth/utils/getModel.d.ts +6 -0
- package/dist/js/auth/utils/getModel.d.ts.map +1 -0
- package/dist/js/auth/utils/getModel.js +18 -0
- package/dist/js/auth/utils/getModel.js.map +1 -0
- package/dist/js/auth/utils/getOTPData.d.ts +9 -0
- package/dist/js/auth/utils/getOTPData.d.ts.map +1 -0
- package/dist/js/auth/utils/getOTPData.js +26 -0
- package/dist/js/auth/utils/getOTPData.js.map +1 -0
- package/dist/js/auth/utils/getOTPModel.d.ts +4 -0
- package/dist/js/auth/utils/getOTPModel.d.ts.map +1 -0
- package/dist/js/auth/utils/getOTPModel.js +20 -0
- package/dist/js/auth/utils/getOTPModel.js.map +1 -0
- package/dist/js/auth/utils/getOTPUser.d.ts +8 -0
- package/dist/js/auth/utils/getOTPUser.d.ts.map +1 -0
- package/dist/js/auth/utils/getOTPUser.js +21 -0
- package/dist/js/auth/utils/getOTPUser.js.map +1 -0
- package/dist/js/auth/utils/getUser.d.ts +10 -0
- package/dist/js/auth/utils/getUser.d.ts.map +1 -0
- package/dist/js/auth/utils/getUser.js +27 -0
- package/dist/js/auth/utils/getUser.js.map +1 -0
- package/dist/js/auth/utils/handleIsVerfieid.d.ts +9 -0
- package/dist/js/auth/utils/handleIsVerfieid.d.ts.map +1 -0
- package/dist/js/auth/utils/handleIsVerfieid.js +20 -0
- package/dist/js/auth/utils/handleIsVerfieid.js.map +1 -0
- package/dist/js/auth/utils/handleIsVerified.d.ts +11 -0
- package/dist/js/auth/utils/handleIsVerified.d.ts.map +1 -0
- package/dist/js/auth/utils/handleIsVerified.js +31 -0
- package/dist/js/auth/utils/handleIsVerified.js.map +1 -0
- package/dist/js/auth/utils/modeMap.d.ts +38 -0
- package/dist/js/auth/utils/modeMap.d.ts.map +1 -0
- package/dist/js/auth/utils/modeMap.js +15 -0
- package/dist/js/auth/utils/modeMap.js.map +1 -0
- package/dist/js/auth/utils/otpHTML.d.ts +2 -0
- package/dist/js/auth/utils/otpHTML.d.ts.map +1 -0
- package/dist/js/auth/utils/otpHTML.js +2 -0
- package/dist/js/auth/utils/otpHTML.js.map +1 -0
- package/dist/js/auth/utils/otpVerifiedResponse.d.ts +9 -0
- package/dist/js/auth/utils/otpVerifiedResponse.d.ts.map +1 -0
- package/dist/js/auth/utils/otpVerifiedResponse.js +22 -0
- package/dist/js/auth/utils/otpVerifiedResponse.js.map +1 -0
- package/dist/js/auth/utils/sendCookie.d.ts +14 -0
- package/dist/js/auth/utils/sendCookie.d.ts.map +1 -0
- package/dist/js/auth/utils/sendCookie.js +73 -0
- package/dist/js/auth/utils/sendCookie.js.map +1 -0
- package/dist/js/auth/utils/sendOTP.d.ts +7 -0
- package/dist/js/auth/utils/sendOTP.d.ts.map +1 -0
- package/dist/js/auth/utils/sendOTP.js +48 -0
- package/dist/js/auth/utils/sendOTP.js.map +1 -0
- package/dist/js/auth/utils/verifyCredentials.d.ts +9 -0
- package/dist/js/auth/utils/verifyCredentials.d.ts.map +1 -0
- package/dist/js/auth/utils/verifyCredentials.js +39 -0
- package/dist/js/auth/utils/verifyCredentials.js.map +1 -0
- package/dist/js/auth/verifyOTP.d.ts +10 -0
- package/dist/js/auth/verifyOTP.d.ts.map +1 -0
- package/dist/js/auth/verifyOTP.js +110 -0
- package/dist/js/auth/verifyOTP.js.map +1 -0
- package/dist/js/config/cloudinary.d.ts +5 -0
- package/dist/js/config/cloudinary.d.ts.map +1 -0
- package/dist/js/config/cloudinary.js +25 -0
- package/dist/js/config/cloudinary.js.map +1 -0
- package/dist/js/config/defaultConfig.d.ts +3 -0
- package/dist/js/config/defaultConfig.d.ts.map +1 -0
- package/dist/js/config/defaultConfig.js +12 -0
- package/dist/js/config/defaultConfig.js.map +1 -0
- package/dist/js/config/duration.d.ts +22 -0
- package/dist/js/config/duration.d.ts.map +1 -0
- package/dist/js/config/duration.js +35 -0
- package/dist/js/config/duration.js.map +1 -0
- package/dist/js/config/envs.d.ts +32 -0
- package/dist/js/config/envs.d.ts.map +1 -0
- package/dist/js/config/envs.js +10 -0
- package/dist/js/config/envs.js.map +1 -0
- package/dist/js/config/handleReqType.d.ts +7 -0
- package/dist/js/config/handleReqType.d.ts.map +1 -0
- package/dist/js/config/handleReqType.js +13 -0
- package/dist/js/config/handleReqType.js.map +1 -0
- package/dist/js/config/handlerMap.d.ts +3 -0
- package/dist/js/config/handlerMap.d.ts.map +1 -0
- package/dist/js/config/handlerMap.js +29 -0
- package/dist/js/config/handlerMap.js.map +1 -0
- package/dist/js/config/reqTypes.d.ts +2 -0
- package/dist/js/config/reqTypes.d.ts.map +1 -0
- package/dist/js/config/reqTypes.js +2 -0
- package/dist/js/config/reqTypes.js.map +1 -0
- package/dist/js/config/sendEmail.d.ts +11 -0
- package/dist/js/config/sendEmail.d.ts.map +1 -0
- package/dist/js/config/sendEmail.js +95 -0
- package/dist/js/config/sendEmail.js.map +1 -0
- package/dist/js/core/app.d.ts +3 -0
- package/dist/js/core/app.d.ts.map +1 -0
- package/dist/js/core/app.js +19 -0
- package/dist/js/core/app.js.map +1 -0
- package/dist/js/crud/bunch.crud.d.ts +11 -0
- package/dist/js/crud/bunch.crud.d.ts.map +1 -0
- package/dist/js/crud/bunch.crud.js +11 -0
- package/dist/js/crud/bunch.crud.js.map +1 -0
- package/dist/js/crud/create.d.ts +10 -0
- package/dist/js/crud/create.d.ts.map +1 -0
- package/dist/js/crud/create.js +72 -0
- package/dist/js/crud/create.js.map +1 -0
- package/dist/js/crud/createBulk.d.ts +10 -0
- package/dist/js/crud/createBulk.d.ts.map +1 -0
- package/dist/js/crud/createBulk.js +20 -0
- package/dist/js/crud/createBulk.js.map +1 -0
- package/dist/js/crud/files/file.update.d.ts +10 -0
- package/dist/js/crud/files/file.update.d.ts.map +1 -0
- package/dist/js/crud/files/file.update.js +28 -0
- package/dist/js/crud/files/file.update.js.map +1 -0
- package/dist/js/crud/handleUploads/file.add.d.ts +10 -0
- package/dist/js/crud/handleUploads/file.add.d.ts.map +1 -0
- package/dist/js/crud/handleUploads/file.add.js +61 -0
- package/dist/js/crud/handleUploads/file.add.js.map +1 -0
- package/dist/js/crud/handleUploads/file.create.d.ts +10 -0
- package/dist/js/crud/handleUploads/file.create.d.ts.map +1 -0
- package/dist/js/crud/handleUploads/file.create.js +33 -0
- package/dist/js/crud/handleUploads/file.create.js.map +1 -0
- package/dist/js/crud/handleUploads/file.delete.d.ts +10 -0
- package/dist/js/crud/handleUploads/file.delete.d.ts.map +1 -0
- package/dist/js/crud/handleUploads/file.delete.js +35 -0
- package/dist/js/crud/handleUploads/file.delete.js.map +1 -0
- package/dist/js/crud/handleUploads/file.update.d.ts +10 -0
- package/dist/js/crud/handleUploads/file.update.d.ts.map +1 -0
- package/dist/js/crud/handleUploads/file.update.js +30 -0
- package/dist/js/crud/handleUploads/file.update.js.map +1 -0
- package/dist/js/crud/index.d.ts +5 -0
- package/dist/js/crud/index.d.ts.map +1 -0
- package/dist/js/crud/index.js +36 -0
- package/dist/js/crud/index.js.map +1 -0
- package/dist/js/crud/read.d.ts +10 -0
- package/dist/js/crud/read.d.ts.map +1 -0
- package/dist/js/crud/read.js +27 -0
- package/dist/js/crud/read.js.map +1 -0
- package/dist/js/crud/readAll.d.ts +10 -0
- package/dist/js/crud/readAll.d.ts.map +1 -0
- package/dist/js/crud/readAll.js +24 -0
- package/dist/js/crud/readAll.js.map +1 -0
- package/dist/js/crud/remove.d.ts +10 -0
- package/dist/js/crud/remove.d.ts.map +1 -0
- package/dist/js/crud/remove.js +28 -0
- package/dist/js/crud/remove.js.map +1 -0
- package/dist/js/crud/removeAll.d.ts +10 -0
- package/dist/js/crud/removeAll.d.ts.map +1 -0
- package/dist/js/crud/removeAll.js +37 -0
- package/dist/js/crud/removeAll.js.map +1 -0
- package/dist/js/crud/update.d.ts +10 -0
- package/dist/js/crud/update.d.ts.map +1 -0
- package/dist/js/crud/update.js +33 -0
- package/dist/js/crud/update.js.map +1 -0
- package/dist/js/crud/utils/authroizeAccess.d.ts +10 -0
- package/dist/js/crud/utils/authroizeAccess.d.ts.map +1 -0
- package/dist/js/crud/utils/authroizeAccess.js +48 -0
- package/dist/js/crud/utils/authroizeAccess.js.map +1 -0
- package/dist/js/crud/utils/getItem.d.ts +11 -0
- package/dist/js/crud/utils/getItem.d.ts.map +1 -0
- package/dist/js/crud/utils/getItem.js +68 -0
- package/dist/js/crud/utils/getItem.js.map +1 -0
- package/dist/js/crud/utils/getParam.d.ts +8 -0
- package/dist/js/crud/utils/getParam.d.ts.map +1 -0
- package/dist/js/crud/utils/getParam.js +19 -0
- package/dist/js/crud/utils/getParam.js.map +1 -0
- package/dist/js/crud/utils/validateOwner.d.ts +7 -0
- package/dist/js/crud/utils/validateOwner.d.ts.map +1 -0
- package/dist/js/crud/utils/validateOwner.js +5 -0
- package/dist/js/crud/utils/validateOwner.js.map +1 -0
- package/dist/js/health/bunch.health.d.ts +6 -0
- package/dist/js/health/bunch.health.d.ts.map +1 -0
- package/dist/js/health/bunch.health.js +6 -0
- package/dist/js/health/bunch.health.js.map +1 -0
- package/dist/js/health/delete.health.d.ts +4 -0
- package/dist/js/health/delete.health.d.ts.map +1 -0
- package/dist/js/health/delete.health.js +5 -0
- package/dist/js/health/delete.health.js.map +1 -0
- package/dist/js/health/get.health.d.ts +4 -0
- package/dist/js/health/get.health.d.ts.map +1 -0
- package/dist/js/health/get.health.js +5 -0
- package/dist/js/health/get.health.js.map +1 -0
- package/dist/js/health/health.collection.d.ts +4 -0
- package/dist/js/health/health.collection.d.ts.map +1 -0
- package/dist/js/health/health.collection.js +39 -0
- package/dist/js/health/health.collection.js.map +1 -0
- package/dist/js/health/health.controller.d.ts +4 -0
- package/dist/js/health/health.controller.d.ts.map +1 -0
- package/dist/js/health/health.controller.js +5 -0
- package/dist/js/health/health.controller.js.map +1 -0
- package/dist/js/health/index.d.ts +5 -0
- package/dist/js/health/index.d.ts.map +1 -0
- package/dist/js/health/index.js +10 -0
- package/dist/js/health/index.js.map +1 -0
- package/dist/js/health/patch.health.d.ts +4 -0
- package/dist/js/health/patch.health.d.ts.map +1 -0
- package/dist/js/health/patch.health.js +5 -0
- package/dist/js/health/patch.health.js.map +1 -0
- package/dist/js/health/post.health.d.ts +4 -0
- package/dist/js/health/post.health.d.ts.map +1 -0
- package/dist/js/health/post.health.js +5 -0
- package/dist/js/health/post.health.js.map +1 -0
- package/dist/js/health/put.health.d.ts +4 -0
- package/dist/js/health/put.health.d.ts.map +1 -0
- package/dist/js/health/put.health.js +5 -0
- package/dist/js/health/put.health.js.map +1 -0
- package/dist/js/index.d.ts +13 -0
- package/dist/js/index.d.ts.map +1 -0
- package/dist/js/index.js +21 -0
- package/dist/js/index.js.map +1 -0
- package/dist/js/lib/Mongoose.d.ts +53 -0
- package/dist/js/lib/Mongoose.d.ts.map +1 -0
- package/dist/js/lib/Mongoose.js +2 -0
- package/dist/js/lib/Mongoose.js.map +1 -0
- package/dist/js/lib/OA.d.ts +2 -0
- package/dist/js/lib/OA.d.ts.map +1 -0
- package/dist/js/lib/OA.js +2 -0
- package/dist/js/lib/OA.js.map +1 -0
- package/dist/js/lib/OAuthProviders.d.ts +3 -0
- package/dist/js/lib/OAuthProviders.d.ts.map +1 -0
- package/dist/js/lib/OAuthProviders.js +18 -0
- package/dist/js/lib/OAuthProviders.js.map +1 -0
- package/dist/js/lib/PROVIDERS.d.ts +2 -0
- package/dist/js/lib/PROVIDERS.d.ts.map +1 -0
- package/dist/js/lib/PROVIDERS.js +2 -0
- package/dist/js/lib/PROVIDERS.js.map +1 -0
- package/dist/js/lib/db.d.ts +8 -0
- package/dist/js/lib/db.d.ts.map +1 -0
- package/dist/js/lib/db.js +28 -0
- package/dist/js/lib/db.js.map +1 -0
- package/dist/js/lib/handler.d.ts +9 -0
- package/dist/js/lib/handler.d.ts.map +1 -0
- package/dist/js/lib/handler.js +11 -0
- package/dist/js/lib/handler.js.map +1 -0
- package/dist/js/lib/handlerMap.d.ts +3 -0
- package/dist/js/lib/handlerMap.d.ts.map +1 -0
- package/dist/js/lib/handlerMap.js +18 -0
- package/dist/js/lib/handlerMap.js.map +1 -0
- package/dist/js/lib/model.factory.d.ts +8 -0
- package/dist/js/lib/model.factory.d.ts.map +1 -0
- package/dist/js/lib/model.factory.js +49 -0
- package/dist/js/lib/model.factory.js.map +1 -0
- package/dist/js/lib/model.registry.d.ts +4 -0
- package/dist/js/lib/model.registry.d.ts.map +1 -0
- package/dist/js/lib/model.registry.js +4 -0
- package/dist/js/lib/model.registry.js.map +1 -0
- package/dist/js/lib/mongoose.fields.d.ts +40 -0
- package/dist/js/lib/mongoose.fields.d.ts.map +1 -0
- package/dist/js/lib/mongoose.fields.js +187 -0
- package/dist/js/lib/mongoose.fields.js.map +1 -0
- package/dist/js/lib/roles.d.ts +3 -0
- package/dist/js/lib/roles.d.ts.map +1 -0
- package/dist/js/lib/roles.js +13 -0
- package/dist/js/lib/roles.js.map +1 -0
- package/dist/js/lib/schema.builder.d.ts +6 -0
- package/dist/js/lib/schema.builder.d.ts.map +1 -0
- package/dist/js/lib/schema.builder.js +28 -0
- package/dist/js/lib/schema.builder.js.map +1 -0
- package/dist/js/lib/zod.fields.d.ts +119 -0
- package/dist/js/lib/zod.fields.d.ts.map +1 -0
- package/dist/js/lib/zod.fields.js +133 -0
- package/dist/js/lib/zod.fields.js.map +1 -0
- package/dist/js/middleware/auth.middleware.d.ts +5 -0
- package/dist/js/middleware/auth.middleware.d.ts.map +1 -0
- package/dist/js/middleware/auth.middleware.js +86 -0
- package/dist/js/middleware/auth.middleware.js.map +1 -0
- package/dist/js/middleware/error.middleware.d.ts +5 -0
- package/dist/js/middleware/error.middleware.d.ts.map +1 -0
- package/dist/js/middleware/error.middleware.js +25 -0
- package/dist/js/middleware/error.middleware.js.map +1 -0
- package/dist/js/middleware/multer.middleware.d.ts +5 -0
- package/dist/js/middleware/multer.middleware.d.ts.map +1 -0
- package/dist/js/middleware/multer.middleware.js +97 -0
- package/dist/js/middleware/multer.middleware.js.map +1 -0
- package/dist/js/middleware/rateLimit.middleware.d.ts +2 -0
- package/dist/js/middleware/rateLimit.middleware.d.ts.map +1 -0
- package/dist/js/middleware/rateLimit.middleware.js +19 -0
- package/dist/js/middleware/rateLimit.middleware.js.map +1 -0
- package/dist/js/realtime/index.d.ts +4 -0
- package/dist/js/realtime/index.d.ts.map +1 -0
- package/dist/js/realtime/index.js +5 -0
- package/dist/js/realtime/index.js.map +1 -0
- package/dist/js/types/Collection.d.ts +41 -0
- package/dist/js/types/Collection.d.ts.map +1 -0
- package/dist/js/types/Collection.js +2 -0
- package/dist/js/types/Collection.js.map +1 -0
- package/dist/js/types/Constructor.d.ts +30 -0
- package/dist/js/types/Constructor.d.ts.map +1 -0
- package/dist/js/types/Constructor.js +2 -0
- package/dist/js/types/Constructor.js.map +1 -0
- package/dist/js/types/MongooseOTPSchemaObj.d.ts +10 -0
- package/dist/js/types/MongooseOTPSchemaObj.d.ts.map +1 -0
- package/dist/js/types/MongooseOTPSchemaObj.js +2 -0
- package/dist/js/types/MongooseOTPSchemaObj.js.map +1 -0
- package/dist/js/types/Routepath.d.ts +2 -0
- package/dist/js/types/Routepath.d.ts.map +1 -0
- package/dist/js/types/Routepath.js +2 -0
- package/dist/js/types/Routepath.js.map +1 -0
- package/dist/js/types/StoreFile.d.ts +10 -0
- package/dist/js/types/StoreFile.d.ts.map +1 -0
- package/dist/js/types/StoreFile.js +2 -0
- package/dist/js/types/StoreFile.js.map +1 -0
- package/dist/js/types/ValidationsObj.d.ts +7 -0
- package/dist/js/types/ValidationsObj.d.ts.map +1 -0
- package/dist/js/types/ValidationsObj.js +2 -0
- package/dist/js/types/ValidationsObj.js.map +1 -0
- package/dist/js/types/authHandlers.d.ts +2 -0
- package/dist/js/types/authHandlers.d.ts.map +1 -0
- package/dist/js/types/authHandlers.js +2 -0
- package/dist/js/types/authHandlers.js.map +1 -0
- package/dist/js/types/crudHandlers.d.ts +2 -0
- package/dist/js/types/crudHandlers.d.ts.map +1 -0
- package/dist/js/types/crudHandlers.js +2 -0
- package/dist/js/types/crudHandlers.js.map +1 -0
- package/dist/js/types/email.d.ts +12 -0
- package/dist/js/types/email.d.ts.map +1 -0
- package/dist/js/types/email.js +2 -0
- package/dist/js/types/email.js.map +1 -0
- package/dist/js/types/healthHandlers.d.ts +2 -0
- package/dist/js/types/healthHandlers.d.ts.map +1 -0
- package/dist/js/types/healthHandlers.js +2 -0
- package/dist/js/types/healthHandlers.js.map +1 -0
- package/dist/js/types/upload.d.ts +9 -0
- package/dist/js/types/upload.d.ts.map +1 -0
- package/dist/js/types/upload.js +2 -0
- package/dist/js/types/upload.js.map +1 -0
- package/dist/js/types/uploadFile.d.ts +10 -0
- package/dist/js/types/uploadFile.d.ts.map +1 -0
- package/dist/js/types/uploadFile.js +2 -0
- package/dist/js/types/uploadFile.js.map +1 -0
- package/dist/js/types/uploadHandlers.d.ts +2 -0
- package/dist/js/types/uploadHandlers.d.ts.map +1 -0
- package/dist/js/types/uploadHandlers.js +2 -0
- package/dist/js/types/uploadHandlers.js.map +1 -0
- package/dist/js/upload/create.d.ts +8 -0
- package/dist/js/upload/create.d.ts.map +1 -0
- package/dist/js/upload/create.js +71 -0
- package/dist/js/upload/create.js.map +1 -0
- package/dist/js/upload/delete.d.ts +8 -0
- package/dist/js/upload/delete.d.ts.map +1 -0
- package/dist/js/upload/delete.js +107 -0
- package/dist/js/upload/delete.js.map +1 -0
- package/dist/js/upload/index.d.ts +3 -0
- package/dist/js/upload/index.d.ts.map +1 -0
- package/dist/js/upload/index.js +3 -0
- package/dist/js/upload/index.js.map +1 -0
- package/dist/js/upload/providers/cloudinary.provider.d.ts +2 -0
- package/dist/js/upload/providers/cloudinary.provider.d.ts.map +1 -0
- package/dist/js/upload/providers/cloudinary.provider.js +2 -0
- package/dist/js/upload/providers/cloudinary.provider.js.map +1 -0
- package/dist/js/upload/update.d.ts +10 -0
- package/dist/js/upload/update.d.ts.map +1 -0
- package/dist/js/upload/update.js +144 -0
- package/dist/js/upload/update.js.map +1 -0
- package/dist/js/utils/AppError.d.ts +26 -0
- package/dist/js/utils/AppError.d.ts.map +1 -0
- package/dist/js/utils/AppError.js +18 -0
- package/dist/js/utils/AppError.js.map +1 -0
- package/dist/js/utils/AppLog.d.ts +10 -0
- package/dist/js/utils/AppLog.d.ts.map +1 -0
- package/dist/js/utils/AppLog.js +12 -0
- package/dist/js/utils/AppLog.js.map +1 -0
- package/dist/js/utils/Applog.d.ts +2 -0
- package/dist/js/utils/Applog.d.ts.map +1 -0
- package/dist/js/utils/Applog.js +2 -0
- package/dist/js/utils/Applog.js.map +1 -0
- package/dist/js/utils/AsyncHandler.d.ts +4 -0
- package/dist/js/utils/AsyncHandler.d.ts.map +1 -0
- package/dist/js/utils/AsyncHandler.js +5 -0
- package/dist/js/utils/AsyncHandler.js.map +1 -0
- package/dist/js/utils/extractParamsNames.d.ts +2 -0
- package/dist/js/utils/extractParamsNames.d.ts.map +1 -0
- package/dist/js/utils/extractParamsNames.js +13 -0
- package/dist/js/utils/extractParamsNames.js.map +1 -0
- package/dist/js/utils/getErrorDetail.d.ts +8 -0
- package/dist/js/utils/getErrorDetail.d.ts.map +1 -0
- package/dist/js/utils/getErrorDetail.js +9 -0
- package/dist/js/utils/getErrorDetail.js.map +1 -0
- package/dist/js/utils/getModel.d.ts +8 -0
- package/dist/js/utils/getModel.d.ts.map +1 -0
- package/dist/js/utils/getModel.js +27 -0
- package/dist/js/utils/getModel.js.map +1 -0
- package/dist/js/utils/handleJWT.d.ts +11 -0
- package/dist/js/utils/handleJWT.d.ts.map +1 -0
- package/dist/js/utils/handleJWT.js +89 -0
- package/dist/js/utils/handleJWT.js.map +1 -0
- package/dist/js/utils/libsodium.d.ts +15 -0
- package/dist/js/utils/libsodium.d.ts.map +1 -0
- package/dist/js/utils/libsodium.js +185 -0
- package/dist/js/utils/libsodium.js.map +1 -0
- package/dist/js/utils/otpPurposes.d.ts +3 -0
- package/dist/js/utils/otpPurposes.d.ts.map +1 -0
- package/dist/js/utils/otpPurposes.js +38 -0
- package/dist/js/utils/otpPurposes.js.map +1 -0
- package/dist/js/utils/response.d.ts +10 -0
- package/dist/js/utils/response.d.ts.map +1 -0
- package/dist/js/utils/response.js +9 -0
- package/dist/js/utils/response.js.map +1 -0
- package/dist/js/utils/sanitize.d.ts +3 -0
- package/dist/js/utils/sanitize.d.ts.map +1 -0
- package/dist/js/utils/sanitize.js +13 -0
- package/dist/js/utils/sanitize.js.map +1 -0
- package/dist/js/utils/validate.d.ts +4 -0
- package/dist/js/utils/validate.d.ts.map +1 -0
- package/dist/js/utils/validate.js +59 -0
- package/dist/js/utils/validate.js.map +1 -0
- package/dist/js/utils/validationKeyError.d.ts +4 -0
- package/dist/js/utils/validationKeyError.d.ts.map +1 -0
- package/dist/js/utils/validationKeyError.js +38 -0
- package/dist/js/utils/validationKeyError.js.map +1 -0
- package/dist/js/validations.d.ts +3 -0
- package/dist/js/validations.d.ts.map +1 -0
- package/dist/js/validations.js +6 -0
- package/dist/js/validations.js.map +1 -0
- package/package.json +88 -0
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { Constructor } from "../types/Constructor.ts";
|
|
2
|
+
declare let envs: {
|
|
3
|
+
apiVersion: number;
|
|
4
|
+
backendURL: string;
|
|
5
|
+
cloudinaryAPIKey?: string;
|
|
6
|
+
cloudinaryAPISecret?: string;
|
|
7
|
+
cloudinaryCloudName?: string;
|
|
8
|
+
cloudinaryFolderName?: string;
|
|
9
|
+
collections?: import("../types/Collection.js").Collection[];
|
|
10
|
+
databaseName?: string;
|
|
11
|
+
domain?: string;
|
|
12
|
+
ENV: string;
|
|
13
|
+
frontendURL?: string;
|
|
14
|
+
frontendURLs?: string[];
|
|
15
|
+
internalRoles?: string[];
|
|
16
|
+
isOffline: boolean;
|
|
17
|
+
jwtSecret?: string;
|
|
18
|
+
masterKey?: string;
|
|
19
|
+
maxReqLimit: number;
|
|
20
|
+
mongoDBURI?: string;
|
|
21
|
+
port: number;
|
|
22
|
+
rateLimitDuration: import("./duration.js").DurationType;
|
|
23
|
+
rateLimitMsg: string;
|
|
24
|
+
adminEmailSender?: string;
|
|
25
|
+
resendAPIKey?: string;
|
|
26
|
+
tokenExpiry: import("./duration.js").DurationType;
|
|
27
|
+
userModelName?: string;
|
|
28
|
+
};
|
|
29
|
+
declare const setEnvs: (values: Constructor) => void;
|
|
30
|
+
declare const getEnvs: () => Constructor;
|
|
31
|
+
export { setEnvs, getEnvs, envs };
|
|
32
|
+
//# sourceMappingURL=envs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"envs.d.ts","sourceRoot":"","sources":["../../../src/js/config/envs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAG3D,QAAA,IAAI,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;CAAuB,CAAC;AAEhC,QAAA,MAAM,OAAO,GAAI,QAAQ,WAAW,KAAG,IAEtC,CAAC;AAEF,QAAA,MAAM,OAAO,QAAO,WAEnB,CAAC;AAEF,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"envs.js","sourceRoot":"","sources":["../../../src/js/config/envs.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD,IAAI,IAAI,GAAG,EAAE,GAAG,aAAa,EAAE,CAAC;AAEhC,MAAM,OAAO,GAAG,CAAC,MAAmB,EAAQ,EAAE;IAC5C,IAAI,GAAG,MAAM,CAAC;AAChB,CAAC,CAAC;AAEF,MAAM,OAAO,GAAG,GAAgB,EAAE;IAChC,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAEF,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Express } from "express";
|
|
2
|
+
import type { ReqType } from "../types/Collection.ts";
|
|
3
|
+
import type { Route } from "../types/Collection.ts";
|
|
4
|
+
import type { MongooseSchema, ValidationsObj } from "../types/Collection.ts";
|
|
5
|
+
declare const handleReqType: (reqType: ReqType, app: Express, routeName: string, routes: Route[], modelName: string | undefined, validationsObj?: ValidationsObj, mongooseSchemaObj?: MongooseSchema) => void;
|
|
6
|
+
export default handleReqType;
|
|
7
|
+
//# sourceMappingURL=handleReqType.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handleReqType.d.ts","sourceRoot":"","sources":["../../../src/js/config/handleReqType.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAQ7E,QAAA,MAAM,aAAa,GACjB,SAAS,OAAO,EAChB,KAAK,OAAO,EACZ,WAAW,MAAM,EACjB,QAAQ,KAAK,EAAE,EACf,WAAW,MAAM,GAAG,SAAS,EAC7B,iBAAiB,cAAc,EAC/B,oBAAoB,cAAc,SAWnC,CAAC;AAEF,eAAe,aAAa,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import health from "../health/index.js";
|
|
2
|
+
import auth from "../auth/index.js";
|
|
3
|
+
import crud from "../crud/index.js";
|
|
4
|
+
const reqMap = {
|
|
5
|
+
health,
|
|
6
|
+
auth,
|
|
7
|
+
crud
|
|
8
|
+
};
|
|
9
|
+
const handleReqType = (reqType, app, routeName, routes, modelName, validationsObj, mongooseSchemaObj) => {
|
|
10
|
+
reqMap[reqType](app, routeName, routes, modelName, validationsObj, mongooseSchemaObj);
|
|
11
|
+
};
|
|
12
|
+
export default handleReqType;
|
|
13
|
+
//# sourceMappingURL=handleReqType.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handleReqType.js","sourceRoot":"","sources":["../../../src/js/config/handleReqType.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,oBAAoB,CAAC;AACxC,OAAO,IAAI,MAAM,kBAAkB,CAAC;AACpC,OAAO,IAAI,MAAM,kBAAkB,CAAA;AAMnC,MAAM,MAAM,GAAG;IACb,MAAM;IACN,IAAI;IACJ,IAAI;CACL,CAAC;AAEF,MAAM,aAAa,GAAG,CACpB,OAAgB,EAChB,GAAY,EACZ,SAAiB,EACjB,MAAe,EACf,SAA6B,EAC7B,cAA+B,EAC/B,iBAAkC,EAClC,EAAE;IAEF,MAAM,CAAC,OAAO,CAAC,CACb,GAAG,EACH,SAAS,EACT,MAAM,EACN,SAAS,EACT,cAAc,EACd,iBAAiB,CAClB,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,aAAa,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handlerMap.d.ts","sourceRoot":"","sources":["../../../src/js/config/handlerMap.ts"],"names":[],"mappings":"AAkCA,QAAA,MAAM,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAuBnC,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { healthDelete, healthGet, healthPatch, healthPost, healthPut, } from "../health/bunch.health.js";
|
|
2
|
+
import { signup, verifyOTP, login, resendOTP, forgotPassword, resetPassword, logout, } from "../auth/bunch.auth.js";
|
|
3
|
+
import { read, create, readAll, createBulk, remove, removeAll, update, updateFile, deleteFile, addFile, } from "../crud/bunch.crud.js";
|
|
4
|
+
const handlerMap = {
|
|
5
|
+
healthDelete,
|
|
6
|
+
healthGet,
|
|
7
|
+
healthPatch,
|
|
8
|
+
healthPost,
|
|
9
|
+
healthPut,
|
|
10
|
+
signup,
|
|
11
|
+
verifyOTP,
|
|
12
|
+
login,
|
|
13
|
+
resendOTP,
|
|
14
|
+
forgotPassword,
|
|
15
|
+
resetPassword,
|
|
16
|
+
logout,
|
|
17
|
+
read,
|
|
18
|
+
create,
|
|
19
|
+
readAll,
|
|
20
|
+
createBulk,
|
|
21
|
+
remove,
|
|
22
|
+
removeAll,
|
|
23
|
+
update,
|
|
24
|
+
updateFile,
|
|
25
|
+
deleteFile,
|
|
26
|
+
addFile,
|
|
27
|
+
};
|
|
28
|
+
export default handlerMap;
|
|
29
|
+
//# sourceMappingURL=handlerMap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handlerMap.js","sourceRoot":"","sources":["../../../src/js/config/handlerMap.ts"],"names":[],"mappings":"AACA,OAAO,EACL,YAAY,EACZ,SAAS,EACT,WAAW,EACX,UAAU,EACV,SAAS,GACV,MAAM,2BAA2B,CAAC;AAGnC,OAAO,EACL,MAAM,EACN,SAAS,EACT,KAAK,EACL,SAAS,EACT,cAAc,EACd,aAAa,EACb,MAAM,GACP,MAAM,uBAAuB,CAAC;AAG/B,OAAO,EACL,IAAI,EACJ,MAAM,EACN,OAAO,EACP,UAAU,EACV,MAAM,EACN,SAAS,EACT,MAAM,EACN,UAAU,EACV,UAAU,EACV,OAAO,GACR,MAAM,uBAAuB,CAAC;AAE/B,MAAM,UAAU,GAAwB;IACtC,YAAY;IACZ,SAAS;IACT,WAAW;IACX,UAAU;IACV,SAAS;IACT,MAAM;IACN,SAAS;IACT,KAAK;IACL,SAAS;IACT,cAAc;IACd,aAAa;IACb,MAAM;IACN,IAAI;IACJ,MAAM;IACN,OAAO;IACP,UAAU;IACV,MAAM;IACN,SAAS;IACT,MAAM;IACN,UAAU;IACV,UAAU;IACV,OAAO;CACR,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reqTypes.d.ts","sourceRoot":"","sources":["../../../src/js/config/reqTypes.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reqTypes.js","sourceRoot":"","sources":["../../../src/js/config/reqTypes.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Route } from "../types/Collection.js";
|
|
2
|
+
export interface Email {
|
|
3
|
+
from: string;
|
|
4
|
+
subject: string;
|
|
5
|
+
htmlBody: string;
|
|
6
|
+
to: string | string[];
|
|
7
|
+
route: Route;
|
|
8
|
+
}
|
|
9
|
+
declare const sendEmail: ({ from, subject, htmlBody, to, route, }: Email) => Promise<boolean>;
|
|
10
|
+
export default sendEmail;
|
|
11
|
+
//# sourceMappingURL=sendEmail.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sendEmail.d.ts","sourceRoot":"","sources":["../../../src/js/config/sendEmail.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAEpD,MAAM,WAAW,KAAK;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,EAAE,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACtB,KAAK,EAAE,KAAK,CAAC;CACd;AAED,QAAA,MAAM,SAAS,GAAU,yCAMtB,KAAK,KAAG,OAAO,CAAC,OAAO,CAmGzB,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { Resend } from "resend";
|
|
2
|
+
import { getEnvs } from "./envs.js";
|
|
3
|
+
import AppError from "../utils/AppError.js";
|
|
4
|
+
const sendEmail = async ({ from, subject, htmlBody, to, route, }) => {
|
|
5
|
+
if (!from)
|
|
6
|
+
throw new AppError({
|
|
7
|
+
message: "Email sender is required",
|
|
8
|
+
statusCode: 404,
|
|
9
|
+
code: "EMAIL_CONFIGURATION_INVALID",
|
|
10
|
+
hint: "This issue requires a fix from the framework developer.",
|
|
11
|
+
details: {
|
|
12
|
+
handler: route.handler,
|
|
13
|
+
method: route.method,
|
|
14
|
+
path: route.path,
|
|
15
|
+
},
|
|
16
|
+
});
|
|
17
|
+
if (!to) {
|
|
18
|
+
throw new AppError({
|
|
19
|
+
message: "Email receiver is required",
|
|
20
|
+
statusCode: 404,
|
|
21
|
+
code: "EMAIL_INVALID_RECIPIENT",
|
|
22
|
+
hint: "This issue requires a fix from the framework developer.",
|
|
23
|
+
details: {
|
|
24
|
+
handler: route.handler,
|
|
25
|
+
method: route.method,
|
|
26
|
+
path: route.path,
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
if (!subject) {
|
|
31
|
+
throw new AppError({
|
|
32
|
+
message: "Email subject is required",
|
|
33
|
+
statusCode: 404,
|
|
34
|
+
code: "EMAIL_INVALID_SUBJECT",
|
|
35
|
+
hint: "This issue requires a fix from the framework developer.",
|
|
36
|
+
details: {
|
|
37
|
+
handler: route.handler,
|
|
38
|
+
method: route.method,
|
|
39
|
+
path: route.path,
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
if (!htmlBody) {
|
|
44
|
+
throw new AppError({
|
|
45
|
+
message: "Email body is required",
|
|
46
|
+
statusCode: 404,
|
|
47
|
+
code: "EMAIL_INVALID_BODY",
|
|
48
|
+
hint: "This issue requires a fix from the framework developer.",
|
|
49
|
+
details: {
|
|
50
|
+
handler: route.handler,
|
|
51
|
+
method: route.method,
|
|
52
|
+
path: route.path,
|
|
53
|
+
},
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
const { resendAPIKey } = getEnvs();
|
|
57
|
+
if (!resendAPIKey) {
|
|
58
|
+
throw new AppError({
|
|
59
|
+
message: "resendAPIKey is required",
|
|
60
|
+
statusCode: 404,
|
|
61
|
+
code: "EMAIL_CONFIGURATION_INVALID",
|
|
62
|
+
hint: "This issue requires a fix from the framework developer.",
|
|
63
|
+
details: {
|
|
64
|
+
handler: route.handler,
|
|
65
|
+
method: route.method,
|
|
66
|
+
path: route.path,
|
|
67
|
+
},
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
const resend = new Resend(resendAPIKey);
|
|
71
|
+
const { error } = await resend.emails.send({
|
|
72
|
+
from,
|
|
73
|
+
to,
|
|
74
|
+
subject,
|
|
75
|
+
html: htmlBody,
|
|
76
|
+
});
|
|
77
|
+
if (error) {
|
|
78
|
+
console.log("Email error: ");
|
|
79
|
+
console.dir(error, { depth: null });
|
|
80
|
+
throw new AppError({
|
|
81
|
+
message: error.message,
|
|
82
|
+
statusCode: 409,
|
|
83
|
+
code: "EMAIL_CONFIGURATION_INVALID",
|
|
84
|
+
hint: "This issue requires a fix from the framework developer.",
|
|
85
|
+
details: {
|
|
86
|
+
handler: route.handler,
|
|
87
|
+
method: route.method,
|
|
88
|
+
path: route.path,
|
|
89
|
+
},
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
return true;
|
|
93
|
+
};
|
|
94
|
+
export default sendEmail;
|
|
95
|
+
//# sourceMappingURL=sendEmail.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sendEmail.js","sourceRoot":"","sources":["../../../src/js/config/sendEmail.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,QAAQ,MAAM,sBAAsB,CAAC;AAW5C,MAAM,SAAS,GAAG,KAAK,EAAE,EACvB,IAAI,EACJ,OAAO,EACP,QAAQ,EACR,EAAE,EACF,KAAK,GACC,EAAoB,EAAE;IAC5B,IAAI,CAAC,IAAI;QACP,MAAM,IAAI,QAAQ,CAAC;YACjB,OAAO,EAAE,0BAA0B;YACnC,UAAU,EAAE,GAAG;YACf,IAAI,EAAE,6BAA6B;YACnC,IAAI,EAAE,yDAAyD;YAC/D,OAAO,EAAE;gBACP,OAAO,EAAE,KAAK,CAAC,OAA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AAE,0BAA0B;YACnC,UAAU,EAAE,GAAG;YACf,IAAI,EAAE,6BAA6B;YACnC,IAAI,EAAE,yDAAyD;YAC/D,OAAO,EAAE;gBACP,OAAO,EAAE,KAAK,CAAC,OAAO;gBACtB,MAAM,EAAE,KAAK,CAAC,MAAM;gBACpB,IAAI,EAAE,KAAK,CAAC,IAAI;aACjB;SACF,CAAC,CAAC;IACL,CAAC;IAED,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC,YAAY,CAAC,CAAC;IAExC,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC;QACzC,IAAI;QACJ,EAAE;QACF,OAAO;QACP,IAAI,EAAE,QAAQ;KACf,CAAC,CAAC;IAEH,IAAI,KAAK,EAAE,CAAC;QACV,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;QAC7B,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;QACpC,MAAM,IAAI,QAAQ,CAAC;YACjB,OAAO,EAAE,KAAK,CAAC,OAAO;YACtB,UAAU,EAAE,GAAG;YACf,IAAI,EAAE,6BAA6B;YACnC,IAAI,EAAE,yDAAyD;YAC/D,OAAO,EAAE;gBACP,OAAO,EAAE,KAAK,CAAC,OAAO;gBACtB,MAAM,EAAE,KAAK,CAAC,MAAM;gBACpB,IAAI,EAAE,KAAK,CAAC,IAAI;aACjB;SACF,CAAC,CAAC;IACL,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../../../src/js/core/app.ts"],"names":[],"mappings":"AAeA,QAAA,MAAM,WAAW,QAAO,IASvB,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import express from "express";
|
|
2
|
+
const app = express();
|
|
3
|
+
import { getEnvs } from "../config/envs.js";
|
|
4
|
+
// handle collection
|
|
5
|
+
const handleCollection = (collections) => {
|
|
6
|
+
for (const req of collections) {
|
|
7
|
+
if (req.reqType === "auth") {
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
// start server
|
|
12
|
+
const startServer = () => {
|
|
13
|
+
const { port, collections } = getEnvs();
|
|
14
|
+
// call - handleCollection
|
|
15
|
+
handleCollection(collections);
|
|
16
|
+
app.listen(port, () => console.log(`Server is running at http://localhost:${port}`));
|
|
17
|
+
};
|
|
18
|
+
export default startServer;
|
|
19
|
+
//# sourceMappingURL=app.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app.js","sourceRoot":"","sources":["../../../src/js/core/app.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,SAAS,CAAC;AAC9B,MAAM,GAAG,GAAG,OAAO,EAAE,CAAC;AACtB,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAG5C,oBAAoB;AACpB,MAAM,gBAAgB,GAAG,CAAC,WAAyB,EAAQ,EAAE;IAC3D,KAAK,MAAM,GAAG,IAAI,WAAW,EAAE,CAAC;QAC9B,IAAI,GAAG,CAAC,OAAO,KAAK,MAAM,EAAC,CAAC;QAE5B,CAAC;IACH,CAAC;AACH,CAAC,CAAC;AAEF,eAAe;AACf,MAAM,WAAW,GAAG,GAAS,EAAE;IAC7B,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,GAAG,OAAO,EAAE,CAAC;IAExC,0BAA0B;IAC1B,gBAAgB,CAAC,WAAW,CAAC,CAAC;IAE9B,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,GAAG,EAAE,CACpB,OAAO,CAAC,GAAG,CAAC,yCAAyC,IAAI,EAAE,CAAC,CAC7D,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { default as read } from "./read.js";
|
|
2
|
+
export { default as readAll } from "./readAll.js";
|
|
3
|
+
export { default as createBulk } from "./createBulk.js";
|
|
4
|
+
export { default as create } from "./create.js";
|
|
5
|
+
export { default as update } from "./update.js";
|
|
6
|
+
export { default as remove } from "./remove.js";
|
|
7
|
+
export { default as removeAll } from "./removeAll.js";
|
|
8
|
+
export { default as updateFile } from "./handleUploads/file.update.js";
|
|
9
|
+
export { default as deleteFile } from "./handleUploads/file.delete.js";
|
|
10
|
+
export { default as addFile } from "./handleUploads/file.add.js";
|
|
11
|
+
//# sourceMappingURL=bunch.crud.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bunch.crud.d.ts","sourceRoot":"","sources":["../../../src/js/crud/bunch.crud.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAGtD,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,gCAAgC,CAAC;AACvE,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,gCAAgC,CAAC;AACvE,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,6BAA6B,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { default as read } from "./read.js";
|
|
2
|
+
export { default as readAll } from "./readAll.js";
|
|
3
|
+
export { default as createBulk } from "./createBulk.js";
|
|
4
|
+
export { default as create } from "./create.js";
|
|
5
|
+
export { default as update } from "./update.js";
|
|
6
|
+
export { default as remove } from "./remove.js";
|
|
7
|
+
export { default as removeAll } from "./removeAll.js";
|
|
8
|
+
export { default as updateFile } from "./handleUploads/file.update.js";
|
|
9
|
+
export { default as deleteFile } from "./handleUploads/file.delete.js";
|
|
10
|
+
export { default as addFile } from "./handleUploads/file.add.js";
|
|
11
|
+
//# sourceMappingURL=bunch.crud.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bunch.crud.js","sourceRoot":"","sources":["../../../src/js/crud/bunch.crud.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAGtD,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,gCAAgC,CAAC;AACvE,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,gCAAgC,CAAC;AACvE,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,6BAA6B,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Request, Response } from "express";
|
|
2
|
+
import type { Route, ValidationsObj } from "../types/Collection.js";
|
|
3
|
+
declare const create: ({ modelName, routeName, route, validationsObj, }: {
|
|
4
|
+
modelName: string;
|
|
5
|
+
routeName: string;
|
|
6
|
+
route: Route;
|
|
7
|
+
validationsObj: ValidationsObj;
|
|
8
|
+
}) => (req: Request, res: Response) => Promise<void>;
|
|
9
|
+
export default create;
|
|
10
|
+
//# sourceMappingURL=create.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../src/js/crud/create.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAuB,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACtE,OAAO,KAAK,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAUpE,QAAA,MAAM,MAAM,GAAI,kDAKb;IACD,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,KAAK,CAAC;IACb,cAAc,EAAE,cAAc,CAAC;CAChC,MACe,KAAK,OAAO,EAAE,KAAK,QAAQ,KAAG,OAAO,CAAC,IAAI,CA6EzD,CAAC;AAEF,eAAe,MAAM,CAAC"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import AppError from "../utils/AppError.js";
|
|
2
|
+
import validate from "../utils/validate.js";
|
|
3
|
+
import getModel from "../utils/getModel.js";
|
|
4
|
+
import { sanitizeOne } from "../utils/sanitize.js";
|
|
5
|
+
import appResponse from "../utils/response.js";
|
|
6
|
+
import { MongoServerError } from "mongodb";
|
|
7
|
+
import { handleUploadFiles } from "../upload/index.js";
|
|
8
|
+
import getValidationKey from "../utils/validationKeyError.js";
|
|
9
|
+
const create = ({ modelName, routeName, route, validationsObj, }) => {
|
|
10
|
+
return async (req, res) => {
|
|
11
|
+
const validationObj = getValidationKey(route, validationsObj);
|
|
12
|
+
const body = validate(validationObj, req.body, route);
|
|
13
|
+
const fileMetaData = await handleUploadFiles(req, route);
|
|
14
|
+
const Model = getModel({ modelName, routeName, route });
|
|
15
|
+
const owner = req.user?._id;
|
|
16
|
+
if (!owner)
|
|
17
|
+
throw new AppError({
|
|
18
|
+
message: "authRole should'nt be public",
|
|
19
|
+
statusCode: 409,
|
|
20
|
+
code: "CRUD_INVALIDT_AUTHROLE",
|
|
21
|
+
hint: "Make the authRole admin or adminOrOwner",
|
|
22
|
+
details: {
|
|
23
|
+
handler: route.handler,
|
|
24
|
+
method: route.method,
|
|
25
|
+
path: route.path,
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
let newItem = null;
|
|
29
|
+
try {
|
|
30
|
+
newItem = await Model.create({
|
|
31
|
+
owner: req.user._id,
|
|
32
|
+
...fileMetaData,
|
|
33
|
+
...body,
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
catch (err) {
|
|
37
|
+
const e = err;
|
|
38
|
+
if (e.name === "MongoServerError") {
|
|
39
|
+
const field = Object.keys(err.keyPattern)[0];
|
|
40
|
+
throw new AppError({
|
|
41
|
+
message: `Item with this '${field}' already exists`,
|
|
42
|
+
statusCode: 409,
|
|
43
|
+
code: "CRUD_ITEM_ALREADY_EXISTS",
|
|
44
|
+
hint: `'${field}' is declared as unique in collection -> mongooseSchemaObj`,
|
|
45
|
+
details: {
|
|
46
|
+
handler: route.handler,
|
|
47
|
+
method: route.method,
|
|
48
|
+
path: route.path,
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
throw new AppError({
|
|
53
|
+
message: e.message,
|
|
54
|
+
statusCode: 409,
|
|
55
|
+
code: "CRUD_ERROR",
|
|
56
|
+
hint: "This issue may requires a fix from the framework developer.",
|
|
57
|
+
details: {
|
|
58
|
+
handler: route.handler,
|
|
59
|
+
method: route.method,
|
|
60
|
+
path: route.path,
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
appResponse({
|
|
65
|
+
res,
|
|
66
|
+
data: sanitizeOne(newItem.toObject()),
|
|
67
|
+
message: "Item created successfully!",
|
|
68
|
+
});
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
export default create;
|
|
72
|
+
//# source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W,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC;YACrC,OAAO,EAAE,4BAA4B;SACtC,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,MAAM,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Request, Response } from "express";
|
|
2
|
+
import type { ValidationsObj, Route } from "../types/Collection.js";
|
|
3
|
+
declare const createBulk: ({ modelName, routeName, validationsObj, route, }: {
|
|
4
|
+
modelName: string;
|
|
5
|
+
routeName: string;
|
|
6
|
+
route: Route;
|
|
7
|
+
validationsObj: ValidationsObj;
|
|
8
|
+
}) => (req: Request, res: Response) => Promise<void>;
|
|
9
|
+
export default createBulk;
|
|
10
|
+
//# sourceMappingURL=createBulk.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createBulk.d.ts","sourceRoot":"","sources":["../../../src/js/crud/createBulk.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACjD,OAAO,KAAK,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAOpE,QAAA,MAAM,UAAU,GAAI,kDAKjB;IACD,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,KAAK,CAAC;IACb,cAAc,EAAE,cAAc,CAAC;CAChC,MACe,KAAK,OAAO,EAAE,KAAK,QAAQ,KAAG,OAAO,CAAC,IAAI,CAoBzD,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import validate from "../utils/validate.js";
|
|
2
|
+
import getModel from "../utils/getModel.js";
|
|
3
|
+
import { sanitizeMany } from "../utils/sanitize.js";
|
|
4
|
+
import appResponse from "../utils/response.js";
|
|
5
|
+
import getValidationKey from "../utils/validationKeyError.js";
|
|
6
|
+
const createBulk = ({ modelName, routeName, validationsObj, route, }) => {
|
|
7
|
+
return async (req, res) => {
|
|
8
|
+
const validationObj = getValidationKey(route, validationsObj);
|
|
9
|
+
const body = validate(validationObj, req.body, route);
|
|
10
|
+
const Model = getModel({ modelName, routeName, route });
|
|
11
|
+
const newItems = await Model.insertMany(body);
|
|
12
|
+
appResponse({
|
|
13
|
+
res,
|
|
14
|
+
data: sanitizeMany(newItems),
|
|
15
|
+
message: "Items created successfully!",
|
|
16
|
+
});
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
export default createBulk;
|
|
20
|
+
//# sourceMappingURL=createBulk.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createBulk.js","sourceRoot":"","sources":["../../../src/js/crud/createBulk.ts"],"names":[],"mappings":"AAEA,OAAO,QAAQ,MAAM,sBAAsB,CAAC;AAC5C,OAAO,QAAQ,MAAM,sBAAsB,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,WAAW,MAAM,sBAAsB,CAAC;AAC/C,OAAO,gBAAgB,MAAM,gCAAgC,CAAC;AAE9D,MAAM,UAAU,GAAG,CAAC,EAClB,SAAS,EACT,SAAS,EACT,cAAc,EACd,KAAK,GAMN,EAAE,EAAE;IACH,OAAO,KAAK,EAAE,GAAY,EAAE,GAAa,EAAiB,EAAE;QAE1D,MAAM,aAAa,GAAG,gBAAgB,CAAC,KAAK,EAAE,cAAc,CAAC,CAAC;QAG9D,MAAM,IAAI,GAAG,QAAQ,CAAC,aAAa,EAAE,GAAG,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QAGtD,MAAM,KAAK,GAAG,QAAQ,CAAC,EAAE,SAAS,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC,CAAC;QAGxD,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QAG9C,WAAW,CAAC;YACV,GAAG;YACH,IAAI,EAAE,YAAY,CAAC,QAAQ,CAAC;YAC5B,OAAO,EAAE,6BAA6B;SACvC,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Route, ValidationsObj } from "../../types/Collection.ts";
|
|
2
|
+
import type { Request, Response } from "express";
|
|
3
|
+
declare const updateFile: ({ modelName, routeName, route, validationsObj, }: {
|
|
4
|
+
modelName: string;
|
|
5
|
+
routeName: string;
|
|
6
|
+
route: Route;
|
|
7
|
+
validationsObj: ValidationsObj;
|
|
8
|
+
}) => (req: Request, res: Response) => Promise<void>;
|
|
9
|
+
export default updateFile;
|
|
10
|
+
//# sourceMappingURL=file.update.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file.update.d.ts","sourceRoot":"","sources":["../../../../src/js/crud/files/file.update.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AACvE,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AASjD,QAAA,MAAM,UAAU,GAAI,kDAKjB;IACD,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,KAAK,CAAC;IACb,cAAc,EAAE,cAAc,CAAC;CAChC,MACe,KAAK,OAAO,EAAE,KAAK,QAAQ,KAAG,OAAO,CAAC,IAAI,CAwCzD,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import getItem from "../utils/getItem.js";
|
|
2
|
+
import handleUpdateFile from "../../upload/update.js";
|
|
3
|
+
import getParam from "../utils/getParam.js";
|
|
4
|
+
import appResponse from "../../utils/response.js";
|
|
5
|
+
import getValidationKey from "../../utils/validationKeyError.js";
|
|
6
|
+
import validate from "../../utils/validate.js";
|
|
7
|
+
import mongoose from "mongoose";
|
|
8
|
+
const updateFile = ({ modelName, routeName, route, validationsObj, }) => {
|
|
9
|
+
return async (req, res) => {
|
|
10
|
+
const validationObj = getValidationKey(route, validationsObj);
|
|
11
|
+
const body = validate(validationObj, req.body);
|
|
12
|
+
const param = getParam({ req, routeName, handler: route.handler });
|
|
13
|
+
let item = await getItem({
|
|
14
|
+
modelName,
|
|
15
|
+
routeName,
|
|
16
|
+
_id: param,
|
|
17
|
+
path: route.path,
|
|
18
|
+
clean: false,
|
|
19
|
+
});
|
|
20
|
+
const { updated, _id, mongooseField } = (await handleUpdateFile(req, route, body, item)) || {};
|
|
21
|
+
const old = item[mongooseField].id(_id);
|
|
22
|
+
Object.assign(old, updated);
|
|
23
|
+
await item.save();
|
|
24
|
+
appResponse({ res, message: "File updated successfully!" });
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
export default updateFile;
|
|
28
|
+
//# sourceMappingURL=file.update.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file.update.js","sourceRoot":"","sources":["../../../../src/js/crud/files/file.update.ts"],"names":[],"mappings":"AAEA,OAAO,OAAO,MAAM,qBAAqB,CAAC;AAC1C,OAAO,gBAAgB,MAAM,wBAAwB,CAAC;AACtD,OAAO,QAAQ,MAAM,sBAAsB,CAAC;AAC5C,OAAO,WAAW,MAAM,yBAAyB,CAAC;AAClD,OAAO,gBAAgB,MAAM,mCAAmC,CAAC;AACjE,OAAO,QAAQ,MAAM,yBAAyB,CAAC;AAC/C,OAAO,QAAQ,MAAM,UAAU,CAAC;AAEhC,MAAM,UAAU,GAAG,CAAC,EAClB,SAAS,EACT,SAAS,EACT,KAAK,EACL,cAAc,GAMf,EAAE,EAAE;IACH,OAAO,KAAK,EAAE,GAAY,EAAE,GAAa,EAAiB,EAAE;QAE1D,MAAM,aAAa,GAAG,gBAAgB,CAAC,KAAK,EAAE,cAAc,CAAC,CAAC;QAK9D,MAAM,IAAI,GAAG,QAAQ,CAAC,aAAa,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC;QAI/C,MAAM,KAAK,GAAG,QAAQ,CAAC,EAAE,GAAG,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;QAInE,IAAI,IAAI,GAAG,MAAM,OAAO,CAAC;YACvB,SAAS;YACT,SAAS;YACT,GAAG,EAAE,KAAe;YACpB,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,KAAK,EAAE,KAAK;SACb,CAAC,CAAC;QAIH,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,aAAa,EAAE,GACnC,CAAC,MAAM,gBAAgB,CAAC,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC;QAGzD,MAAM,GAAG,GAAG,IAAI,CAAC,aAAuB,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;QAGlD,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;QAG5B,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC;QAGlB,WAAW,CAAC,EAAE,GAAG,EAAE,OAAO,EAAE,4BAA4B,EAAE,CAAC,CAAC;IAC9D,CAAC,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Request, Response } from "express";
|
|
2
|
+
import type { Route, ValidationsObj } from "../../types/Collection.js";
|
|
3
|
+
declare const addFile: ({ modelName, routeName, route, }: {
|
|
4
|
+
modelName: string;
|
|
5
|
+
routeName: string;
|
|
6
|
+
route: Route;
|
|
7
|
+
validationsObj: ValidationsObj;
|
|
8
|
+
}) => (req: Request, res: Response) => Promise<void>;
|
|
9
|
+
export default addFile;
|
|
10
|
+
//# sourceMappingURL=file.add.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file.add.d.ts","sourceRoot":"","sources":["../../../../src/js/crud/handleUploads/file.add.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACjD,OAAO,KAAK,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAQvE,QAAA,MAAM,OAAO,GAAI,kCAId;IACD,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,KAAK,CAAC;IACb,cAAc,EAAE,cAAc,CAAC;CAChC,MACe,KAAK,OAAO,EAAE,KAAK,QAAQ,KAAG,OAAO,CAAC,IAAI,CAkEzD,CAAC;AAEF,eAAe,OAAO,CAAC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import getItem from "../utils/getItem.js";
|
|
2
|
+
import getParam from "../utils/getParam.js";
|
|
3
|
+
import appResponse from "../../utils/response.js";
|
|
4
|
+
import { handleUploadFiles } from "../../upload/index.js";
|
|
5
|
+
import AppError from "../../utils/AppError.js";
|
|
6
|
+
import authorizeAccess from "../utils/authroizeAccess.js";
|
|
7
|
+
const addFile = ({ modelName, routeName, route, }) => {
|
|
8
|
+
return async (req, res) => {
|
|
9
|
+
if (!route?.fileArray?.length)
|
|
10
|
+
throw new AppError({
|
|
11
|
+
message: "fileArray is missing or empty",
|
|
12
|
+
statusCode: 400,
|
|
13
|
+
code: "INVALID_CONFIGURATION",
|
|
14
|
+
hint: "Checkout the collection configuration if fileArray is missing or empty",
|
|
15
|
+
details: {
|
|
16
|
+
handler: route.handler,
|
|
17
|
+
method: route.method,
|
|
18
|
+
path: route.path,
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
const param = getParam({
|
|
22
|
+
req,
|
|
23
|
+
route
|
|
24
|
+
});
|
|
25
|
+
const item = await getItem({
|
|
26
|
+
modelName,
|
|
27
|
+
routeName,
|
|
28
|
+
_id: param,
|
|
29
|
+
path: route.path,
|
|
30
|
+
clean: false,
|
|
31
|
+
route,
|
|
32
|
+
});
|
|
33
|
+
authorizeAccess({ route, routeName, item, req });
|
|
34
|
+
const fileMetaData = await handleUploadFiles(req, route);
|
|
35
|
+
if (fileMetaData) {
|
|
36
|
+
for (const [field, files] of Object.entries(fileMetaData)) {
|
|
37
|
+
const mongooseSchemaField = item[field];
|
|
38
|
+
if (!mongooseSchemaField)
|
|
39
|
+
throw new AppError({
|
|
40
|
+
message: `mongooseSchemaFieldName: '${field}' not found in mongodb document.`,
|
|
41
|
+
statusCode: 400,
|
|
42
|
+
code: "INVALID_CONFIGURATION",
|
|
43
|
+
hint: "Check if 'mongooseSchemaFieldName' is wrong. It should match the array [] name of your mongodb document.",
|
|
44
|
+
details: {
|
|
45
|
+
handler: route.handler,
|
|
46
|
+
method: route.method,
|
|
47
|
+
path: route.path,
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
item[field].push(...files);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
await item.save();
|
|
54
|
+
appResponse({
|
|
55
|
+
res,
|
|
56
|
+
message: "File added successfully!",
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
export default addFile;
|
|
61
|
+
//# sourceMappingURL=file.add.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file.add.js","sourceRoot":"","sources":["../../../../src/js/crud/handleUploads/file.add.ts"],"names":[],"mappings":"AAEA,OAAO,OAAO,MAAM,qBAAqB,CAAC;AAC1C,OAAO,QAAQ,MAAM,sBAAsB,CAAC;AAC5C,OAAO,WAAW,MAAM,yBAAyB,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,QAAQ,MAAM,yBAAyB,CAAC;AAC/C,OAAO,eAAe,MAAM,6BAA6B,CAAC;AAE1D,MAAM,OAAO,GAAG,CAAC,EACf,SAAS,EACT,SAAS,EACT,KAAK,GAMN,EAAE,EAAE;IACH,OAAO,KAAK,EAAE,GAAY,EAAE,GAAa,EAAiB,EAA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BACpB,IAAI,EAAE,KAAK,CAAC,IAAI;yBACjB;qBACF,CAAC,CAAC;gBACL,IAAI,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,CAAC;YAC7B,CAAC;QACH,CAAC;QAGD,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC;QAGlB,WAAW,CAAC;YACV,GAAG;YACH,OAAO,EAAE,0BAA0B;SACpC,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,OAAO,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Request, Response } from "express";
|
|
2
|
+
import type { Route, ValidationsObj } from "../../types/Collection.js";
|
|
3
|
+
declare const addFile: ({ modelName, routeName, route, }: {
|
|
4
|
+
modelName: string;
|
|
5
|
+
routeName: string;
|
|
6
|
+
route: Route;
|
|
7
|
+
validationsObj: ValidationsObj;
|
|
8
|
+
}) => (req: Request, res: Response) => Promise<void>;
|
|
9
|
+
export default addFile;
|
|
10
|
+
//# sourceMappingURL=file.create.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file.create.d.ts","sourceRoot":"","sources":["../../../../src/js/crud/handleUploads/file.create.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACjD,OAAO,KAAK,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAMvE,QAAA,MAAM,OAAO,GAAI,kCAId;IACD,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,KAAK,CAAC;IACb,cAAc,EAAE,cAAc,CAAC;CAChC,MACe,KAAK,OAAO,EAAE,KAAK,QAAQ,KAAG,OAAO,CAAC,IAAI,CAqCzD,CAAC;AAEF,eAAe,OAAO,CAAC"}
|