arkos 1.4.10-beta → 1.4.11-beta
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/cjs/app.js +1 -1
- package/dist/cjs/app.js.map +1 -1
- package/dist/cjs/modules/auth/auth.router.js +39 -4
- package/dist/cjs/modules/auth/auth.router.js.map +1 -1
- package/dist/cjs/modules/auth/utils/auth-openapi-generator.js +372 -0
- package/dist/cjs/modules/auth/utils/auth-openapi-generator.js.map +1 -0
- package/dist/cjs/modules/auth/utils/auth-prisma-json-schema-generator.js +102 -0
- package/dist/cjs/modules/auth/utils/auth-prisma-json-schema-generator.js.map +1 -0
- package/dist/cjs/modules/base/base.middlewares.js +1 -1
- package/dist/cjs/modules/base/base.middlewares.js.map +1 -1
- package/dist/cjs/modules/base/types/base.service.types.js.map +1 -1
- package/dist/cjs/modules/base/utils/helpers/base.router.helpers.js +46 -14
- package/dist/cjs/modules/base/utils/helpers/base.router.helpers.js.map +1 -1
- package/dist/cjs/modules/base/utils/helpers/base.service.helpers.js +17 -5
- package/dist/cjs/modules/base/utils/helpers/base.service.helpers.js.map +1 -1
- package/dist/cjs/modules/base/utils/model-openapi-generator.js +443 -0
- package/dist/cjs/modules/base/utils/model-openapi-generator.js.map +1 -0
- package/dist/cjs/modules/error-handler/error-handler.controller.js +0 -2
- package/dist/cjs/modules/error-handler/error-handler.controller.js.map +1 -1
- package/dist/cjs/modules/error-handler/utils/error-handler.helpers.js +0 -106
- package/dist/cjs/modules/error-handler/utils/error-handler.helpers.js.map +1 -1
- package/dist/cjs/modules/file-upload/file-upload.router.js +19 -0
- package/dist/cjs/modules/file-upload/file-upload.router.js.map +1 -1
- package/dist/cjs/modules/file-upload/utils/file-upload-json-schema-generator.js +351 -0
- package/dist/cjs/modules/file-upload/utils/file-upload-json-schema-generator.js.map +1 -0
- package/dist/cjs/modules/swagger/swagger.router.js +35 -16
- package/dist/cjs/modules/swagger/swagger.router.js.map +1 -1
- package/dist/cjs/modules/swagger/utils/helpers/get-swagger-default-configs.js +1 -2
- package/dist/cjs/modules/swagger/utils/helpers/get-swagger-default-configs.js.map +1 -1
- package/dist/cjs/modules/swagger/utils/helpers/openapi-schema-converter.js +68 -31
- package/dist/cjs/modules/swagger/utils/helpers/openapi-schema-converter.js.map +1 -1
- package/dist/cjs/server.js +0 -6
- package/dist/cjs/server.js.map +1 -1
- package/dist/cjs/types/arkos-config.js.map +1 -1
- package/dist/cjs/types/{arkos-config/utils.js → arkos-prisma-input.bak.js} +1 -1
- package/dist/cjs/types/arkos-prisma-input.bak.js.map +1 -0
- package/dist/cjs/types/index.js.map +1 -1
- package/dist/cjs/utils/arkos-router/arkos-router-openapi-manager.js +3 -12
- package/dist/cjs/utils/arkos-router/arkos-router-openapi-manager.js.map +1 -1
- package/dist/cjs/utils/arkos-router/index.js +47 -8
- package/dist/cjs/utils/arkos-router/index.js.map +1 -1
- package/dist/cjs/utils/arkos-router/types/openapi-config.js.map +1 -1
- package/dist/cjs/utils/arkos-router/utils/helpers/index.js +15 -2
- package/dist/cjs/utils/arkos-router/utils/helpers/index.js.map +1 -1
- package/dist/cjs/utils/cli/generate.js +4 -4
- package/dist/cjs/utils/cli/generate.js.map +1 -1
- package/dist/cjs/utils/cli/index.js +11 -11
- package/dist/cjs/utils/cli/index.js.map +1 -1
- package/dist/cjs/utils/cli/utils/cli.helpers.js +1 -1
- package/dist/cjs/utils/cli/utils/template-generator/templates/class-validator/create-dto-template.js +29 -5
- package/dist/cjs/utils/cli/utils/template-generator/templates/class-validator/create-dto-template.js.map +1 -1
- package/dist/cjs/utils/cli/utils/template-generator/templates/class-validator/update-dto-template.js +26 -5
- package/dist/cjs/utils/cli/utils/template-generator/templates/class-validator/update-dto-template.js.map +1 -1
- package/dist/cjs/utils/cli/utils/template-generator/templates/class-validator-dto-generator.js +52 -0
- package/dist/cjs/utils/cli/utils/template-generator/templates/class-validator-dto-generator.js.map +1 -1
- package/dist/cjs/utils/cli/utils/template-generator/templates/zod/create-schema-template.js +10 -1
- package/dist/cjs/utils/cli/utils/template-generator/templates/zod/create-schema-template.js.map +1 -1
- package/dist/cjs/utils/cli/utils/template-generator/templates/zod/update-schema-template.js +9 -2
- package/dist/cjs/utils/cli/utils/template-generator/templates/zod/update-schema-template.js.map +1 -1
- package/dist/cjs/utils/cli/utils/template-generator/templates/zod-schema-generator.js +26 -1
- package/dist/cjs/utils/cli/utils/template-generator/templates/zod-schema-generator.js.map +1 -1
- package/dist/cjs/utils/helpers/routers.helpers.js +2 -4
- package/dist/cjs/utils/helpers/routers.helpers.js.map +1 -1
- package/dist/cjs/utils/prisma/prisma-json-schema-generator.js +144 -257
- package/dist/cjs/utils/prisma/prisma-json-schema-generator.js.map +1 -1
- package/dist/cjs/utils/prisma/prisma-schema-parser.js +15 -2
- package/dist/cjs/utils/prisma/prisma-schema-parser.js.map +1 -1
- package/dist/cjs/utils/prisma/types.js.map +1 -1
- package/dist/esm/app.js +1 -1
- package/dist/esm/app.js.map +1 -1
- package/dist/esm/modules/auth/auth.router.js +39 -4
- package/dist/esm/modules/auth/auth.router.js.map +1 -1
- package/dist/esm/modules/auth/utils/auth-openapi-generator.js +367 -0
- package/dist/esm/modules/auth/utils/auth-openapi-generator.js.map +1 -0
- package/dist/esm/modules/auth/utils/auth-prisma-json-schema-generator.js +97 -0
- package/dist/esm/modules/auth/utils/auth-prisma-json-schema-generator.js.map +1 -0
- package/dist/esm/modules/base/base.middlewares.js +1 -1
- package/dist/esm/modules/base/base.middlewares.js.map +1 -1
- package/dist/esm/modules/base/types/base.service.types.js.map +1 -1
- package/dist/esm/modules/base/utils/helpers/base.router.helpers.js +46 -13
- package/dist/esm/modules/base/utils/helpers/base.router.helpers.js.map +1 -1
- package/dist/esm/modules/base/utils/helpers/base.service.helpers.js +17 -5
- package/dist/esm/modules/base/utils/helpers/base.service.helpers.js.map +1 -1
- package/dist/esm/modules/base/utils/model-openapi-generator.js +438 -0
- package/dist/esm/modules/base/utils/model-openapi-generator.js.map +1 -0
- package/dist/esm/modules/error-handler/error-handler.controller.js +0 -2
- package/dist/esm/modules/error-handler/error-handler.controller.js.map +1 -1
- package/dist/esm/modules/error-handler/utils/error-handler.helpers.js +0 -87
- package/dist/esm/modules/error-handler/utils/error-handler.helpers.js.map +1 -1
- package/dist/esm/modules/file-upload/file-upload.router.js +19 -0
- package/dist/esm/modules/file-upload/file-upload.router.js.map +1 -1
- package/dist/esm/modules/file-upload/utils/file-upload-json-schema-generator.js +346 -0
- package/dist/esm/modules/file-upload/utils/file-upload-json-schema-generator.js.map +1 -0
- package/dist/esm/modules/swagger/swagger.router.js +35 -16
- package/dist/esm/modules/swagger/swagger.router.js.map +1 -1
- package/dist/esm/modules/swagger/utils/helpers/get-swagger-default-configs.js +1 -2
- package/dist/esm/modules/swagger/utils/helpers/get-swagger-default-configs.js.map +1 -1
- package/dist/esm/modules/swagger/utils/helpers/openapi-schema-converter.js +68 -31
- package/dist/esm/modules/swagger/utils/helpers/openapi-schema-converter.js.map +1 -1
- package/dist/esm/server.js +0 -5
- package/dist/esm/server.js.map +1 -1
- package/dist/esm/types/arkos-config.js.map +1 -1
- package/dist/esm/types/arkos-prisma-input.bak.js +2 -0
- package/dist/esm/types/arkos-prisma-input.bak.js.map +1 -0
- package/dist/esm/types/index.js.map +1 -1
- package/dist/esm/utils/arkos-router/arkos-router-openapi-manager.js +3 -12
- package/dist/esm/utils/arkos-router/arkos-router-openapi-manager.js.map +1 -1
- package/dist/esm/utils/arkos-router/index.js +47 -8
- package/dist/esm/utils/arkos-router/index.js.map +1 -1
- package/dist/esm/utils/arkos-router/types/openapi-config.js.map +1 -1
- package/dist/esm/utils/arkos-router/utils/helpers/index.js +15 -2
- package/dist/esm/utils/arkos-router/utils/helpers/index.js.map +1 -1
- package/dist/esm/utils/cli/generate.js +4 -4
- package/dist/esm/utils/cli/generate.js.map +1 -1
- package/dist/esm/utils/cli/index.js +11 -11
- package/dist/esm/utils/cli/index.js.map +1 -1
- package/dist/esm/utils/cli/utils/cli.helpers.js +1 -1
- package/dist/esm/utils/cli/utils/template-generator/templates/class-validator/create-dto-template.js +29 -5
- package/dist/esm/utils/cli/utils/template-generator/templates/class-validator/create-dto-template.js.map +1 -1
- package/dist/esm/utils/cli/utils/template-generator/templates/class-validator/update-dto-template.js +26 -5
- package/dist/esm/utils/cli/utils/template-generator/templates/class-validator/update-dto-template.js.map +1 -1
- package/dist/esm/utils/cli/utils/template-generator/templates/class-validator-dto-generator.js +52 -0
- package/dist/esm/utils/cli/utils/template-generator/templates/class-validator-dto-generator.js.map +1 -1
- package/dist/esm/utils/cli/utils/template-generator/templates/zod/create-schema-template.js +10 -1
- package/dist/esm/utils/cli/utils/template-generator/templates/zod/create-schema-template.js.map +1 -1
- package/dist/esm/utils/cli/utils/template-generator/templates/zod/update-schema-template.js +9 -2
- package/dist/esm/utils/cli/utils/template-generator/templates/zod/update-schema-template.js.map +1 -1
- package/dist/esm/utils/cli/utils/template-generator/templates/zod-schema-generator.js +26 -1
- package/dist/esm/utils/cli/utils/template-generator/templates/zod-schema-generator.js.map +1 -1
- package/dist/esm/utils/helpers/routers.helpers.js +2 -4
- package/dist/esm/utils/helpers/routers.helpers.js.map +1 -1
- package/dist/esm/utils/prisma/prisma-json-schema-generator.js +144 -257
- package/dist/esm/utils/prisma/prisma-json-schema-generator.js.map +1 -1
- package/dist/esm/utils/prisma/prisma-schema-parser.js +15 -2
- package/dist/esm/utils/prisma/prisma-schema-parser.js.map +1 -1
- package/dist/esm/utils/prisma/types.js.map +1 -1
- package/dist/types/modules/auth/utils/auth-openapi-generator.d.ts +9 -0
- package/dist/types/modules/auth/utils/auth-prisma-json-schema-generator.d.ts +13 -0
- package/dist/types/modules/base/base.middlewares.d.ts +3 -0
- package/dist/types/modules/base/types/base.service.types.d.ts +0 -3
- package/dist/types/modules/base/utils/helpers/base.router.helpers.d.ts +0 -1
- package/dist/types/modules/base/utils/helpers/base.service.helpers.d.ts +1 -1
- package/dist/types/modules/base/utils/model-openapi-generator.d.ts +12 -0
- package/dist/types/modules/error-handler/utils/error-handler.helpers.d.ts +0 -19
- package/dist/types/modules/file-upload/utils/file-upload-json-schema-generator.d.ts +12 -0
- package/dist/types/modules/swagger/utils/helpers/get-swagger-default-configs.d.ts +1 -2
- package/dist/types/modules/swagger/utils/helpers/openapi-schema-converter.d.ts +27 -3
- package/dist/types/server.d.ts +0 -6
- package/dist/types/types/arkos-config.d.ts +1 -1
- package/dist/types/types/arkos-prisma-input.bak.d.ts +237 -0
- package/dist/types/types/index.d.ts +0 -48
- package/dist/types/utils/arkos-router/types/openapi-config.d.ts +3 -2
- package/dist/types/utils/helpers/routers.helpers.d.ts +1 -1
- package/dist/types/utils/prisma/prisma-json-schema-generator.d.ts +12 -42
- package/dist/types/utils/prisma/prisma-schema-parser.d.ts +2 -0
- package/dist/types/utils/prisma/types.d.ts +2 -1
- package/package.json +3 -1
- package/dist/cjs/components/arkos-policy/index.js +0 -38
- package/dist/cjs/components/arkos-policy/index.js.map +0 -1
- package/dist/cjs/components/arkos-policy/types.js +0 -3
- package/dist/cjs/components/arkos-policy/types.js.map +0 -1
- package/dist/cjs/exports/config.js +0 -6
- package/dist/cjs/exports/config.js.map +0 -1
- package/dist/cjs/modules/base/utils/helpers/base.controller.helpers.js +0 -80
- package/dist/cjs/modules/base/utils/helpers/base.controller.helpers.js.map +0 -1
- package/dist/cjs/modules/swagger/utils/built-in-route-path-object-manager.js +0 -7
- package/dist/cjs/modules/swagger/utils/built-in-route-path-object-manager.js.map +0 -1
- package/dist/cjs/modules/swagger/utils/get-open-api-login-html.js +0 -276
- package/dist/cjs/modules/swagger/utils/get-open-api-login-html.js.map +0 -1
- package/dist/cjs/modules/swagger/utils/helpers/get-authentication-json-schema-paths.js +0 -482
- package/dist/cjs/modules/swagger/utils/helpers/get-authentication-json-schema-paths.js.map +0 -1
- package/dist/cjs/modules/swagger/utils/helpers/get-file-upload-json-schema-paths.js +0 -505
- package/dist/cjs/modules/swagger/utils/helpers/get-file-upload-json-schema-paths.js.map +0 -1
- package/dist/cjs/modules/swagger/utils/helpers/get-system-json-schema-paths.js +0 -37
- package/dist/cjs/modules/swagger/utils/helpers/get-system-json-schema-paths.js.map +0 -1
- package/dist/cjs/modules/swagger/utils/helpers/json-schema-generators/generate-class-validator-json-schemas.js +0 -50
- package/dist/cjs/modules/swagger/utils/helpers/json-schema-generators/generate-class-validator-json-schemas.js.map +0 -1
- package/dist/cjs/modules/swagger/utils/helpers/json-schema-generators/generate-prisma-json-schemas.js +0 -32
- package/dist/cjs/modules/swagger/utils/helpers/json-schema-generators/generate-prisma-json-schemas.js.map +0 -1
- package/dist/cjs/modules/swagger/utils/helpers/json-schema-generators/generate-system-json-schemas.js +0 -49
- package/dist/cjs/modules/swagger/utils/helpers/json-schema-generators/generate-system-json-schemas.js.map +0 -1
- package/dist/cjs/modules/swagger/utils/helpers/json-schema-generators/generate-zod-json-schemas.js +0 -34
- package/dist/cjs/modules/swagger/utils/helpers/json-schema-generators/generate-zod-json-schemas.js.map +0 -1
- package/dist/cjs/modules/swagger/utils/helpers/json-schema-generators/prisma-models/generate-prisma-model-main-routes-paths.js +0 -508
- package/dist/cjs/modules/swagger/utils/helpers/json-schema-generators/prisma-models/generate-prisma-model-main-routes-paths.js.map +0 -1
- package/dist/cjs/modules/swagger/utils/helpers/json-schema-generators/prisma-models/generate-prisma-model-parent-routes-paths.js +0 -573
- package/dist/cjs/modules/swagger/utils/helpers/json-schema-generators/prisma-models/generate-prisma-model-parent-routes-paths.js.map +0 -1
- package/dist/cjs/modules/swagger/utils/helpers/missing-json-schemas-generator.js +0 -261
- package/dist/cjs/modules/swagger/utils/helpers/missing-json-schemas-generator.js.map +0 -1
- package/dist/cjs/modules/swagger/utils/helpers/swagger.router.helpers.js +0 -114
- package/dist/cjs/modules/swagger/utils/helpers/swagger.router.helpers.js.map +0 -1
- package/dist/cjs/paths.js +0 -9
- package/dist/cjs/paths.js.map +0 -1
- package/dist/cjs/types/arkos-config/utils.js.map +0 -1
- package/dist/cjs/types/arkos.js +0 -3
- package/dist/cjs/types/arkos.js.map +0 -1
- package/dist/cjs/utils/arkos-router/utils/helpers/apply-arkos-router-proxy.js +0 -152
- package/dist/cjs/utils/arkos-router/utils/helpers/apply-arkos-router-proxy.js.map +0 -1
- package/dist/cjs/utils/cli/utils/template-generator/templates/policy-template.js +0 -53
- package/dist/cjs/utils/cli/utils/template-generator/templates/policy-template.js.map +0 -1
- package/dist/cjs/utils/helpers/exit-error.js +0 -12
- package/dist/cjs/utils/helpers/exit-error.js.map +0 -1
- package/dist/cjs/utils/initialize-app.js +0 -56
- package/dist/cjs/utils/initialize-app.js.map +0 -1
- package/dist/cjs/utils/setup-app.js +0 -119
- package/dist/cjs/utils/setup-app.js.map +0 -1
- package/dist/esm/components/arkos-policy/index.js +0 -32
- package/dist/esm/components/arkos-policy/index.js.map +0 -1
- package/dist/esm/components/arkos-policy/types.js +0 -2
- package/dist/esm/components/arkos-policy/types.js.map +0 -1
- package/dist/esm/exports/config.js +0 -3
- package/dist/esm/exports/config.js.map +0 -1
- package/dist/esm/modules/base/utils/helpers/base.controller.helpers.js +0 -76
- package/dist/esm/modules/base/utils/helpers/base.controller.helpers.js.map +0 -1
- package/dist/esm/modules/swagger/utils/built-in-route-path-object-manager.js +0 -5
- package/dist/esm/modules/swagger/utils/built-in-route-path-object-manager.js.map +0 -1
- package/dist/esm/modules/swagger/utils/get-open-api-login-html.js +0 -273
- package/dist/esm/modules/swagger/utils/get-open-api-login-html.js.map +0 -1
- package/dist/esm/modules/swagger/utils/helpers/get-authentication-json-schema-paths.js +0 -477
- package/dist/esm/modules/swagger/utils/helpers/get-authentication-json-schema-paths.js.map +0 -1
- package/dist/esm/modules/swagger/utils/helpers/get-file-upload-json-schema-paths.js +0 -499
- package/dist/esm/modules/swagger/utils/helpers/get-file-upload-json-schema-paths.js.map +0 -1
- package/dist/esm/modules/swagger/utils/helpers/get-system-json-schema-paths.js +0 -34
- package/dist/esm/modules/swagger/utils/helpers/get-system-json-schema-paths.js.map +0 -1
- package/dist/esm/modules/swagger/utils/helpers/json-schema-generators/generate-class-validator-json-schemas.js +0 -44
- package/dist/esm/modules/swagger/utils/helpers/json-schema-generators/generate-class-validator-json-schemas.js.map +0 -1
- package/dist/esm/modules/swagger/utils/helpers/json-schema-generators/generate-prisma-json-schemas.js +0 -26
- package/dist/esm/modules/swagger/utils/helpers/json-schema-generators/generate-prisma-json-schemas.js.map +0 -1
- package/dist/esm/modules/swagger/utils/helpers/json-schema-generators/generate-system-json-schemas.js +0 -46
- package/dist/esm/modules/swagger/utils/helpers/json-schema-generators/generate-system-json-schemas.js.map +0 -1
- package/dist/esm/modules/swagger/utils/helpers/json-schema-generators/generate-zod-json-schemas.js +0 -28
- package/dist/esm/modules/swagger/utils/helpers/json-schema-generators/generate-zod-json-schemas.js.map +0 -1
- package/dist/esm/modules/swagger/utils/helpers/json-schema-generators/prisma-models/generate-prisma-model-main-routes-paths.js +0 -502
- package/dist/esm/modules/swagger/utils/helpers/json-schema-generators/prisma-models/generate-prisma-model-main-routes-paths.js.map +0 -1
- package/dist/esm/modules/swagger/utils/helpers/json-schema-generators/prisma-models/generate-prisma-model-parent-routes-paths.js +0 -567
- package/dist/esm/modules/swagger/utils/helpers/json-schema-generators/prisma-models/generate-prisma-model-parent-routes-paths.js.map +0 -1
- package/dist/esm/modules/swagger/utils/helpers/missing-json-schemas-generator.js +0 -256
- package/dist/esm/modules/swagger/utils/helpers/missing-json-schemas-generator.js.map +0 -1
- package/dist/esm/modules/swagger/utils/helpers/swagger.router.helpers.js +0 -103
- package/dist/esm/modules/swagger/utils/helpers/swagger.router.helpers.js.map +0 -1
- package/dist/esm/paths.js +0 -3
- package/dist/esm/paths.js.map +0 -1
- package/dist/esm/types/arkos-config/utils.js +0 -2
- package/dist/esm/types/arkos-config/utils.js.map +0 -1
- package/dist/esm/types/arkos.js +0 -2
- package/dist/esm/types/arkos.js.map +0 -1
- package/dist/esm/utils/arkos-router/utils/helpers/apply-arkos-router-proxy.js +0 -146
- package/dist/esm/utils/arkos-router/utils/helpers/apply-arkos-router-proxy.js.map +0 -1
- package/dist/esm/utils/cli/utils/template-generator/templates/policy-template.js +0 -47
- package/dist/esm/utils/cli/utils/template-generator/templates/policy-template.js.map +0 -1
- package/dist/esm/utils/helpers/exit-error.js +0 -6
- package/dist/esm/utils/helpers/exit-error.js.map +0 -1
- package/dist/esm/utils/initialize-app.js +0 -50
- package/dist/esm/utils/initialize-app.js.map +0 -1
- package/dist/esm/utils/setup-app.js +0 -113
- package/dist/esm/utils/setup-app.js.map +0 -1
- package/dist/types/components/arkos-policy/index.d.ts +0 -31
- package/dist/types/components/arkos-policy/types.d.ts +0 -21
- package/dist/types/exports/config.d.ts +0 -2
- package/dist/types/modules/base/utils/helpers/base.controller.helpers.d.ts +0 -4
- package/dist/types/modules/swagger/utils/built-in-route-path-object-manager.d.ts +0 -4
- package/dist/types/modules/swagger/utils/get-open-api-login-html.d.ts +0 -1
- package/dist/types/modules/swagger/utils/helpers/get-authentication-json-schema-paths.d.ts +0 -4
- package/dist/types/modules/swagger/utils/helpers/get-file-upload-json-schema-paths.d.ts +0 -3
- package/dist/types/modules/swagger/utils/helpers/get-system-json-schema-paths.d.ts +0 -2
- package/dist/types/modules/swagger/utils/helpers/json-schema-generators/generate-class-validator-json-schemas.d.ts +0 -1
- package/dist/types/modules/swagger/utils/helpers/json-schema-generators/generate-prisma-json-schemas.d.ts +0 -2
- package/dist/types/modules/swagger/utils/helpers/json-schema-generators/generate-system-json-schemas.d.ts +0 -4
- package/dist/types/modules/swagger/utils/helpers/json-schema-generators/generate-zod-json-schemas.d.ts +0 -1
- package/dist/types/modules/swagger/utils/helpers/json-schema-generators/prisma-models/generate-prisma-model-main-routes-paths.d.ts +0 -3
- package/dist/types/modules/swagger/utils/helpers/json-schema-generators/prisma-models/generate-prisma-model-parent-routes-paths.d.ts +0 -3
- package/dist/types/modules/swagger/utils/helpers/missing-json-schemas-generator.d.ts +0 -77
- package/dist/types/modules/swagger/utils/helpers/swagger.router.helpers.d.ts +0 -20
- package/dist/types/paths.d.ts +0 -1
- package/dist/types/types/arkos-config/utils.d.ts +0 -35
- package/dist/types/types/arkos.d.ts +0 -31
- package/dist/types/utils/arkos-router/utils/helpers/apply-arkos-router-proxy.d.ts +0 -7
- package/dist/types/utils/cli/utils/template-generator/templates/policy-template.d.ts +0 -2
- package/dist/types/utils/helpers/exit-error.d.ts +0 -1
- package/dist/types/utils/initialize-app.d.ts +0 -2
- package/dist/types/utils/setup-app.d.ts +0 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model-openapi-generator.js","sourceRoot":"","sources":["../../../../../src/modules/base/utils/model-openapi-generator.ts"],"names":[],"mappings":";;;;;AACA,oDAGiC;AACjC,kDAA+D;AAG/D,sFAAsF;AACtF,sEAAiE;AACjE,sHAA2F;AAC3F,0DAAkC;AAElC,MAAM,qBAAqB;IACjB,QAAQ,CAAC,SAAiB;QAChC,OAAO,2BAAkB,CAAC,MAAM,CAAC,IAAI,CACnC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAA,iBAAS,EAAC,CAAC,CAAC,IAAI,CAAC,KAAK,IAAA,iBAAS,EAAC,SAAS,CAAC,CACjD,CAAC;IACL,CAAC;IAEO,qBAAqB;QAC3B,IAAI,CAAC,IAAA,8CAAuB,GAAE;YAAE,OAAO,EAAE,CAAC;QAC1C,OAAO;YACL,KAAK,EAAE,EAAE,WAAW,EAAE,yBAAyB,EAAE;YACjD,KAAK,EAAE,EAAE,WAAW,EAAE,0BAA0B,EAAE;SACnD,CAAC;IACJ,CAAC;IAEO,yBAAyB,CAC/B,kBAAuD,EACvD,MAAc;QAEd,IAAI,CAAC,kBAAkB;YAAE,OAAO,EAAE,CAAC;QACnC,MAAM,OAAO,GAAG,kBAAyB,CAAC;QAC1C,IAAI,MAAM,GAAG,OAAO,CAAC,YAAY,IAAI,EAAE,CAAC;QACxC,IAAI,OAAO,CAAC,MAAM;YAAE,MAAM,GAAG,EAAE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E,CAAC;AAE1D,kBAAe,qBAAqB,CAAC","sourcesContent":["import { ArkosRouteConfig } from \"../../../exports\";\nimport {\n PrismaQueryOptions,\n prismaSchemaParser,\n} from \"../../../exports/prisma\";\nimport { kebabCase, pascalCase } from \"../../../exports/utils\";\nimport { RouterEndpoint } from \"../../../types/router-config\";\nimport { ExtendedOperationObject } from \"../../../utils/arkos-router/types/openapi-config\";\nimport { isAuthenticationEnabled } from \"../../../utils/helpers/arkos-config.helpers\";\nimport { capitalize } from \"../../../utils/helpers/text.helpers\";\nimport prismaJsonSchemaGenerator from \"../../../utils/prisma/prisma-json-schema-generator\";\nimport pluralize from \"pluralize\";\n\nclass ModelOpenAPIGenerator {\n private getModel(modelName: string) {\n return prismaSchemaParser.models.find(\n (m) => kebabCase(m.name) === kebabCase(modelName)\n )!;\n }\n\n private getAuthErrorResponses(): Record<string, any> {\n if (!isAuthenticationEnabled()) return {};\n return {\n \"401\": { description: \"Authentication required\" },\n \"403\": { description: \"Insufficient permissions\" },\n };\n }\n\n private resolvePrismaQueryOptions(\n prismaQueryOptions: PrismaQueryOptions<any> | undefined,\n action: string\n ): Record<string, any> {\n if (!prismaQueryOptions) return {};\n const options = prismaQueryOptions as any;\n let merged = options.queryOptions || {};\n if (options.global) merged = { ...merged, ...options.global };\n\n const actionMap: Record<string, string[]> = {\n find: [\"findOne\", \"findMany\"],\n create: [\"createOne\", \"createMany\"],\n update: [\"updateOne\", \"updateMany\"],\n delete: [\"deleteOne\", \"deleteMany\"],\n save: [\"createOne\", \"createMany\", \"updateOne\", \"updateMany\"],\n saveOne: [\"createOne\", \"updateOne\"],\n saveMany: [\"createMany\", \"updateMany\"],\n };\n\n for (const [key, actions] of Object.entries(actionMap)) {\n if (actions.includes(action) && options[key])\n merged = { ...merged, ...options[key] };\n }\n\n if (options[action]) merged = { ...merged, ...options[action] };\n return merged;\n }\n\n getOpenApiConfig(\n endpointRouterConfig: Omit<ArkosRouteConfig, \"path\"> = {},\n endpoint: RouterEndpoint,\n modelNameInKebab: string,\n prismaQueryOptions?: PrismaQueryOptions<any>\n ): Partial<ExtendedOperationObject> {\n const existingOpenApi = endpointRouterConfig?.experimental?.openapi || {};\n const hasBodyValidation =\n typeof endpointRouterConfig?.validation !== \"boolean\" &&\n !!endpointRouterConfig?.validation?.body;\n const hasQueryValidation =\n typeof endpointRouterConfig?.validation !== \"boolean\" &&\n !!endpointRouterConfig?.validation?.query;\n const hasParamsValidation =\n typeof endpointRouterConfig?.validation !== \"boolean\" &&\n !!endpointRouterConfig?.validation?.params;\n\n const model = this.getModel(modelNameInKebab);\n const pascalModelName = pascalCase(modelNameInKebab);\n const humanReadableName = modelNameInKebab.replaceAll(\"-\", \" \");\n const humanReadableNamePlural = pluralize.plural(humanReadableName);\n const authErrors = this.getAuthErrorResponses();\n\n switch (endpoint) {\n case \"createOne\":\n return {\n ...existingOpenApi,\n tags: [\n capitalize(humanReadableNamePlural),\n ...(existingOpenApi?.tags || []),\n ].filter((tag) => tag !== \"Defaults\"),\n summary:\n existingOpenApi?.summary || `Create a new ${humanReadableName}`,\n description:\n existingOpenApi?.description ||\n `Creates a new ${humanReadableName} record in the system`,\n operationId:\n existingOpenApi?.operationId || `create${pascalModelName}`,\n security: existingOpenApi?.security || [{ BearerAuth: [] }],\n ...(!hasBodyValidation && {\n requestBody: existingOpenApi?.requestBody || {\n description: `${humanReadableName} data to create`,\n required: true,\n content: {\n \"application/json\": {\n schema: prismaJsonSchemaGenerator.generateCreateSchema(model),\n },\n },\n },\n }),\n responses: {\n ...(existingOpenApi?.responses || {}),\n \"201\": existingOpenApi?.responses?.[\"201\"] || {\n description: `${humanReadableName} created successfully`,\n content: {\n \"application/json\": {\n schema: prismaJsonSchemaGenerator.generateResponseSchema(\n model,\n this.resolvePrismaQueryOptions(\n prismaQueryOptions,\n \"createOne\"\n )\n ),\n },\n },\n },\n \"400\": existingOpenApi?.responses?.[\"400\"] || {\n description: \"Invalid input data provided\",\n },\n ...authErrors,\n },\n };\n\n case \"findMany\":\n return {\n ...existingOpenApi,\n tags: [\n capitalize(humanReadableNamePlural),\n ...(existingOpenApi?.tags || []),\n ].filter((tag) => tag !== \"Defaults\"),\n summary: existingOpenApi?.summary || `Get ${humanReadableNamePlural}`,\n description:\n existingOpenApi?.description ||\n `Retrieves a paginated list of ${humanReadableNamePlural} with optional filtering and sorting`,\n operationId:\n existingOpenApi?.operationId ||\n `find${pluralize.plural(pascalModelName)}`,\n security: existingOpenApi?.security || [{ BearerAuth: [] }],\n parameters: [\n ...(existingOpenApi?.parameters || []),\n ...(!hasQueryValidation\n ? prismaJsonSchemaGenerator.generateQueryFilterParameters(model)\n : []\n ).filter(\n (p) =>\n !(existingOpenApi?.parameters || []).find(\n (ep: any) => ep.name === p.name && ep.in === p.in\n )\n ),\n ],\n responses: {\n ...(existingOpenApi?.responses || {}),\n \"200\": existingOpenApi?.responses?.[\"200\"] || {\n description: `List of ${humanReadableNamePlural} retrieved successfully`,\n content: {\n \"application/json\": {\n schema: {\n type: \"object\",\n properties: {\n total: {\n type: \"integer\",\n description:\n \"Total number of records matching the criteria\",\n },\n results: {\n type: \"integer\",\n description:\n \"Number of records returned in current page\",\n },\n data: {\n type: \"array\",\n items: prismaJsonSchemaGenerator.generateResponseSchema(\n model,\n this.resolvePrismaQueryOptions(\n prismaQueryOptions,\n \"findMany\"\n )\n ),\n },\n },\n },\n },\n },\n },\n ...authErrors,\n },\n };\n\n case \"createMany\":\n return {\n ...existingOpenApi,\n tags: [\n capitalize(humanReadableNamePlural),\n ...(existingOpenApi?.tags || []),\n ].filter((tag) => tag !== \"Defaults\"),\n summary:\n existingOpenApi?.summary ||\n `Create multiple ${humanReadableNamePlural}`,\n description:\n existingOpenApi?.description ||\n `Creates multiple ${humanReadableNamePlural} records in a single batch operation`,\n operationId:\n existingOpenApi?.operationId || `createMany${pascalModelName}`,\n security: existingOpenApi?.security || [{ BearerAuth: [] }],\n ...(!hasBodyValidation && {\n requestBody: existingOpenApi?.requestBody || {\n description: `Array of ${humanReadableName} data to create`,\n required: true,\n content: {\n \"application/json\": {\n schema: {\n type: \"array\",\n items:\n prismaJsonSchemaGenerator.generateCreateSchema(model),\n },\n },\n },\n },\n }),\n responses: {\n ...(existingOpenApi?.responses || {}),\n \"201\": existingOpenApi?.responses?.[\"201\"] || {\n description: `${humanReadableNamePlural} created successfully`,\n content: {\n \"application/json\": {\n schema: {\n type: \"object\",\n properties: {\n count: {\n type: \"integer\",\n description: \"Number of records created\",\n },\n },\n },\n },\n },\n },\n \"400\": existingOpenApi?.responses?.[\"400\"] || {\n description: \"Invalid input data provided\",\n },\n ...authErrors,\n },\n };\n\n case \"updateMany\":\n return {\n ...existingOpenApi,\n tags: [\n capitalize(humanReadableNamePlural),\n ...(existingOpenApi?.tags || []),\n ].filter((tag) => tag !== \"Defaults\"),\n summary:\n existingOpenApi?.summary ||\n `Update multiple ${humanReadableNamePlural}`,\n description:\n existingOpenApi?.description ||\n `Updates multiple ${humanReadableNamePlural} records that match the specified filter criteria`,\n operationId:\n existingOpenApi?.operationId || `updateMany${pascalModelName}`,\n parameters: [\n ...(existingOpenApi?.parameters || []),\n ...(!hasQueryValidation\n ? prismaJsonSchemaGenerator.generateQueryFilterParameters(model, {\n modelFieldsOnly: true,\n })\n : []\n ).filter(\n (p) =>\n !(existingOpenApi?.parameters || []).find(\n (ep: any) => ep.name === p.name && ep.in === p.in\n )\n ),\n ],\n security: existingOpenApi?.security || [{ BearerAuth: [] }],\n ...(!hasBodyValidation && {\n requestBody: existingOpenApi?.requestBody || {\n description: `Partial ${humanReadableName} data to update`,\n required: true,\n content: {\n \"application/json\": {\n schema: prismaJsonSchemaGenerator.generateUpdateSchema(model),\n },\n },\n },\n }),\n responses: {\n ...(existingOpenApi?.responses || {}),\n \"200\": existingOpenApi?.responses?.[\"200\"] || {\n description: `${humanReadableNamePlural} updated successfully`,\n content: {\n \"application/json\": {\n schema: {\n type: \"object\",\n properties: {\n count: {\n type: \"integer\",\n description: \"Number of records updated\",\n },\n },\n },\n },\n },\n },\n \"400\": existingOpenApi?.responses?.[\"400\"] || {\n description: \"Invalid input data or missing filter criteria\",\n },\n ...authErrors,\n },\n };\n\n case \"deleteMany\":\n return {\n ...existingOpenApi,\n tags: [\n capitalize(humanReadableNamePlural),\n ...(existingOpenApi?.tags || []),\n ].filter((tag) => tag !== \"Defaults\"),\n summary:\n existingOpenApi?.summary ||\n `Delete multiple ${humanReadableNamePlural}`,\n description:\n existingOpenApi?.description ||\n `Deletes multiple ${humanReadableNamePlural} records that match the specified filter criteria`,\n operationId:\n existingOpenApi?.operationId || `deleteMany${pascalModelName}`,\n parameters: [\n ...(existingOpenApi?.parameters || []),\n ...(!hasQueryValidation\n ? prismaJsonSchemaGenerator.generateQueryFilterParameters(model, {\n modelFieldsOnly: true,\n })\n : []\n ).filter(\n (p) =>\n !(existingOpenApi?.parameters || []).find(\n (ep: any) => ep.name === p.name && ep.in === p.in\n )\n ),\n ],\n security: existingOpenApi?.security || [{ BearerAuth: [] }],\n responses: {\n ...(existingOpenApi?.responses || {}),\n \"200\": existingOpenApi?.responses?.[\"200\"] || {\n description: `${humanReadableNamePlural} deleted successfully`,\n content: {\n \"application/json\": {\n schema: {\n type: \"object\",\n properties: {\n count: {\n type: \"integer\",\n description: \"Number of records deleted\",\n },\n },\n },\n },\n },\n },\n \"400\": existingOpenApi?.responses?.[\"400\"] || {\n description: \"Missing filter criteria\",\n },\n ...authErrors,\n },\n };\n\n case \"findOne\":\n return {\n ...existingOpenApi,\n tags: [\n capitalize(humanReadableNamePlural),\n ...(existingOpenApi?.tags || []),\n ].filter((tag) => tag !== \"Defaults\"),\n summary: existingOpenApi?.summary || `Get ${humanReadableName} by ID`,\n description:\n existingOpenApi?.description ||\n `Retrieves a single ${humanReadableName} record by its unique identifier`,\n operationId:\n existingOpenApi?.operationId || `find${pascalModelName}ById`,\n security: existingOpenApi?.security || [{ BearerAuth: [] }],\n parameters: [\n ...(existingOpenApi?.parameters || []),\n ...(!hasParamsValidation\n ? ([\n {\n name: \"id\",\n in: \"path\",\n description: `Unique identifier of the ${humanReadableName}`,\n required: true,\n schema: { type: \"string\" },\n },\n ] as any[])\n : []\n ).filter(\n (p) =>\n !(existingOpenApi?.parameters || []).find(\n (ep: any) => ep.name === p.name && ep.in === p.in\n )\n ),\n ],\n responses: {\n ...(existingOpenApi?.responses || {}),\n \"200\": existingOpenApi?.responses?.[\"200\"] || {\n description: `${humanReadableName} retrieved successfully`,\n content: {\n \"application/json\": {\n schema: prismaJsonSchemaGenerator.generateResponseSchema(\n model,\n this.resolvePrismaQueryOptions(\n prismaQueryOptions,\n \"findOne\"\n )\n ),\n },\n },\n },\n ...authErrors,\n \"404\": existingOpenApi?.responses?.[\"404\"] || {\n description: `${humanReadableName} not found`,\n },\n },\n };\n\n case \"updateOne\":\n return {\n ...existingOpenApi,\n tags: [\n capitalize(humanReadableNamePlural),\n ...(existingOpenApi?.tags || []),\n ].filter((tag) => tag !== \"Defaults\"),\n summary:\n existingOpenApi?.summary || `Update ${humanReadableName} by ID`,\n description:\n existingOpenApi?.description ||\n `Updates a single ${humanReadableName} record by its unique identifier`,\n operationId:\n existingOpenApi?.operationId || `update${pascalModelName}`,\n security: existingOpenApi?.security || [{ BearerAuth: [] }],\n parameters: [\n ...(existingOpenApi?.parameters || []),\n ...(!hasParamsValidation\n ? ([\n {\n name: \"id\",\n in: \"path\",\n description: `Unique identifier of the ${humanReadableName}`,\n required: true,\n schema: { type: \"string\" },\n },\n ] as any[])\n : []\n ).filter(\n (p) =>\n !(existingOpenApi?.parameters || []).find(\n (ep: any) => ep.name === p.name && ep.in === p.in\n )\n ),\n ],\n ...(!hasBodyValidation && {\n requestBody: existingOpenApi?.requestBody || {\n description: `Partial ${humanReadableName} data to update`,\n required: true,\n content: {\n \"application/json\": {\n schema: prismaJsonSchemaGenerator.generateUpdateSchema(model),\n },\n },\n },\n }),\n responses: {\n ...(existingOpenApi?.responses || {}),\n \"200\": existingOpenApi?.responses?.[\"200\"] || {\n description: `${humanReadableName} updated successfully`,\n content: {\n \"application/json\": {\n schema: prismaJsonSchemaGenerator.generateResponseSchema(\n model,\n this.resolvePrismaQueryOptions(\n prismaQueryOptions,\n \"updateOne\"\n )\n ),\n },\n },\n },\n \"400\": existingOpenApi?.responses?.[\"400\"] || {\n description: \"Invalid input data provided\",\n },\n ...authErrors,\n \"404\": existingOpenApi?.responses?.[\"404\"] || {\n description: `${humanReadableName} not found`,\n },\n },\n };\n\n case \"deleteOne\":\n return {\n ...existingOpenApi,\n tags: [\n capitalize(humanReadableNamePlural),\n ...(existingOpenApi?.tags || []),\n ].filter((tag) => tag !== \"Defaults\"),\n summary:\n existingOpenApi?.summary || `Delete ${humanReadableName} by ID`,\n description:\n existingOpenApi?.description ||\n `Permanently deletes a single ${humanReadableName} record by its unique identifier`,\n operationId:\n existingOpenApi?.operationId || `delete${pascalModelName}`,\n security: existingOpenApi?.security || [{ BearerAuth: [] }],\n parameters: [\n ...(existingOpenApi?.parameters || []),\n ...(!hasParamsValidation\n ? ([\n {\n name: \"id\",\n in: \"path\",\n description: `Unique identifier of the ${humanReadableName}`,\n required: true,\n schema: { type: \"string\" },\n },\n ] as any[])\n : []\n ).filter(\n (p) =>\n !(existingOpenApi?.parameters || []).find(\n (ep: any) => ep.name === p.name && ep.in === p.in\n )\n ),\n ],\n responses: {\n ...(existingOpenApi?.responses || {}),\n \"204\": existingOpenApi?.responses?.[\"204\"] || {\n description: `${humanReadableName} deleted successfully`,\n },\n ...authErrors,\n \"404\": existingOpenApi?.responses?.[\"404\"] || {\n description: `${humanReadableName} not found`,\n },\n },\n };\n\n default:\n return {};\n }\n }\n}\n\nconst modelOpenAPIGenerator = new ModelOpenAPIGenerator();\n\nexport default modelOpenAPIGenerator;\n"]}
|
|
@@ -83,8 +83,6 @@ function errorHandler(err, req, res, _) {
|
|
|
83
83
|
error = errorControllerHelper.handleMigrationScriptFailedError(err);
|
|
84
84
|
if (err.code === "P3003")
|
|
85
85
|
error = errorControllerHelper.handleVersionMismatchError(err);
|
|
86
|
-
if (err.name === "NetworkError")
|
|
87
|
-
error = errorControllerHelper.handleNetworkError(err);
|
|
88
86
|
if (process.env.ARKOS_BUILD !== "true")
|
|
89
87
|
return sendDevelopmentError({
|
|
90
88
|
...error,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error-handler.controller.js","sourceRoot":"","sources":["../../../../src/modules/error-handler/error-handler.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoBA,+BAyEC;AA3FD,qFAAuE;AACvE,yCAAsC;AAiBtC,SAAwB,YAAY,CAClC,GAAa,EACb,GAAY,EACZ,GAAa,EACb,CAAe;IAEf,OAAO,CAAC,KAAK,CAAC,yBAAyB,EAAE,GAAG,CAAC,CAAC;IAE9C,GAAG,CAAC,UAAU,GAAG,GAAG,CAAC,UAAU,IAAI,GAAG,CAAC;IACvC,GAAG,CAAC,MAAM,GAAG,GAAG,CAAC,MAAM,IAAI,OAAO,CAAC;IAEnC,IAAI,KAAK,GAAQ;QACf,GAAG,GAAG;QACN,OAAO,EAAE,GAAG,CAAC,OAAO;QACpB,KAAK,EAAE,GAAG,EAAE,KAAK,IAAI,SAAS;KAC/B,CAAC;IAEF,IAAI,OAAO,CAAC,GAAG,CAAC,WAAW,KAAK,MAAM;QAAE,OAAO,KAAK,EAAE,KAAK,CAAC;IAE5D,IAAI,GAAG,CAAC,IAAI,KAAK,mBAAmB;QAClC,KAAK,GAAG,qBAAqB,CAAC,cAAc,EAAE,CAAC;IACjD,IAAI,GAAG,CAAC,IAAI,KAAK,mBAAmB;QAClC,KAAK,GAAG,qBAAqB,CAAC,gBAAgB,EAAE,CAAC;IAEnD,IAAI,GAAG,CAAC,IAAI,KAAK,6BAA6B;QAC5C,KAAK,GAAG,qBAAqB,CAAC,iCAAiC,CAAC,GAAG,CAAC,CAAC;IACvE,IAAI,GAAG,CAAC,IAAI,KAAK,iCAAiC;QAChD,KAAK,GAAG,qBAAqB,CAAC,qC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AG,CAAC,WAAW,KAAK,MAAM,EAAE,CAAC;QACvC,OAAO,CAAC,IAAI,EAAE,CAAC;IACjB,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,KAAK,CAAC,2DAA2D,CAAC,CAAC;QAE3E,eAAM,CAAC,KAAK,CAAC,GAAG,EAAE;YAChB,OAAO,CAAC,KAAK,CAAC,uBAAuB,CAAC,CAAC;YACvC,OAAO,CAAC,IAAI,EAAE,CAAC;QACjB,CAAC,CAAC,CAAC;IACL,CAAC;AACH,CAAC,CAAC,CAAC","sourcesContent":["import { NextFunction, Request, Response } from \"express\";\nimport AppError from \"./utils/app-error\";\nimport * as errorControllerHelper from \"./utils/error-handler.helpers\";\nimport { server } from \"../../server\";\n\n/**\n * Error handling middleware for Express.\n *\n * This middleware function handles all errors in the Express application.\n * It checks for the environment (development or production) and sends appropriate error responses\n * based on whether the environment is production or not. It also maps specific errors such as\n * JWT errors, Prisma client errors, and database-related errors to specific helper functions for handling.\n *\n * @param {AppError} err - The error object thrown by the application.\n * @param {Request} req - The Express request object.\n * @param {Response} res - The Express response object.\n * @param {NextFunction} _ - The next middleware function in the chain.\n *\n * @returns {void} - Sends the response with the error details to the client.\n */\nexport default function errorHandler(\n err: AppError,\n req: Request,\n res: Response,\n _: NextFunction\n): void {\n console.error(\"[\\x1b[31mError\\x1b[0m]:\", err);\n\n err.statusCode = err.statusCode || 500;\n err.status = err.status || \"error\";\n\n let error: any = {\n ...err,\n message: err.message,\n stack: err?.stack || undefined,\n };\n\n if (process.env.ARKOS_BUILD === \"true\") delete error?.stack;\n\n if (err.name === \"JsonWebTokenError\")\n error = errorControllerHelper.handleJWTError();\n if (err.name === \"TokenExpiredError\")\n error = errorControllerHelper.handleJWTExpired();\n\n if (err.name === \"PrismaClientValidationError\")\n error = errorControllerHelper.handlePrismaClientValidationError(err);\n if (err.name === \"PrismaClientInitializationError\")\n error = errorControllerHelper.handlePrismaClientInitializationError(err);\n if (err.code === \"P1000\")\n error = errorControllerHelper.handleAuthenticationError(err);\n if (err.code === \"P1001\")\n error = errorControllerHelper.handleServerNotReachableError(err);\n if (err.code === \"P1002\")\n error = errorControllerHelper.handleConnectionTimeoutError(err);\n if (err.code === \"P1003\")\n error = errorControllerHelper.handleDatabaseNotFoundError(err);\n if (err.code === \"P2000\")\n error = errorControllerHelper.handleFieldValueTooLargeError(err);\n if (err.code === \"P2001\")\n error = errorControllerHelper.handleRecordNotFoundError(err);\n if (err.code === \"P2002\")\n error = errorControllerHelper.handleUniqueConstraintError(err);\n if (err.code === \"P2003\")\n error = errorControllerHelper.handleForeignKeyConstraintError(err);\n if (err.code === \"P2004\")\n error = errorControllerHelper.handleConstraintFailedError(err);\n if (err.code === \"P2025\")\n error = errorControllerHelper.handleNonExistingRecord(err);\n if (err.code === \"P3000\")\n error = errorControllerHelper.handleSchemaCreationFailedError(err);\n if (err.code === \"P3001\")\n error = errorControllerHelper.handleMigrationAlreadyAppliedError(err);\n if (err.code === \"P3002\")\n error = errorControllerHelper.handleMigrationScriptFailedError(err);\n if (err.code === \"P3003\")\n error = errorControllerHelper.handleVersionMismatchError(err);\n\n if (err.name === \"NetworkError\")\n error = errorControllerHelper.handleNetworkError(err);\n\n if (process.env.ARKOS_BUILD !== \"true\")\n return sendDevelopmentError(\n {\n ...error,\n message: error.message,\n stack: err.stack,\n originalError: err,\n },\n req,\n res\n );\n\n sendProductionError(error, req, res);\n}\n\n/**\n * Sends a detailed error response in development mode.\n *\n * In development, the error response includes full error details, including\n * the stack trace and the complete error message.\n *\n * @param {AppError} err - The error object.\n * @param {Request} req - The Express request object.\n * @param {Response} res - The Express response object.\n *\n * @returns {void} - Sends the response with the error details to the client.\n */\nfunction sendDevelopmentError(err: any, req: Request, res: Response): void {\n if (req.originalUrl.startsWith(\"/api\"))\n res.status(err.statusCode).json({\n ...err,\n message:\n err.message?.split?.(\"\\n\")[err.message?.split?.(\"\\n\").length - 1],\n stack: err?.originalError?.stack?.split?.(\"\\n\"),\n });\n else\n res.status(err.statusCode).json({\n title: \"Internal server error\",\n message: err.message,\n });\n}\n\n/**\n * Sends a generic error response in production mode.\n *\n * In production, sensitive error details (such as stack traces) are not exposed\n * to the client. Only operational errors are shown with a generic message.\n *\n * @param {AppError} err - The error object.\n * @param {Request} req - The Express request object.\n * @param {Response} res - The Express response object.\n *\n * @returns {void} - Sends the response with the error details to the client.\n */\nfunction sendProductionError(err: AppError, req: Request, res: Response): void {\n if (req.originalUrl.startsWith(\"/api\")) {\n if (err.isOperational)\n res.status(err.statusCode).json({\n status: err.status,\n message: err.message,\n meta: err.meta || {},\n code: err.code || \"Unknown\",\n });\n else\n res.status(500).json({\n status: \"error\",\n message: \"Internal server error, please try again later.\",\n code: \"Unknown\",\n meta: {},\n });\n\n return;\n }\n\n if (err.isOperational) {\n res.status(err.statusCode).json({\n title: \"Internal server error\",\n message: err.message,\n code: \"Unknown\",\n });\n return;\n }\n\n res.status(err.statusCode).json({\n title: \"Internal server error\",\n message: \"Internal server error, please try again later.\",\n });\n}\n\n/**\n * Gracefully handles process termination by listening for SIGTERM signal.\n *\n * - In production and staging environments, it will log a shutdown message\n * and attempt to close the server gracefully.\n * - In development or non-production environments, it will immediately exit the process.\n *\n * @returns {void}\n */\nprocess.on(\"SIGTERM\", () => {\n if (process.env.ARKOS_BUILD !== \"true\") {\n process.exit();\n } else {\n console.error(\"SIGTERM RECEIVED in Production. Shutting down gracefully!\");\n\n server.close(() => {\n console.error(\"Process terminated!!!\");\n process.exit();\n });\n }\n});\n"]}
|
|
1
|
+
{"version":3,"file":"error-handler.controller.js","sourceRoot":"","sources":["../../../../src/modules/error-handler/error-handler.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoBA,+BAsEC;AAxFD,qFAAuE;AACvE,yCAAsC;AAiBtC,SAAwB,YAAY,CAClC,GAAa,EACb,GAAY,EACZ,GAAa,EACb,CAAe;IAEf,OAAO,CAAC,KAAK,CAAC,yBAAyB,EAAE,GAAG,CAAC,CA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CAAC,CAAC,IAAI,CAAC;gBACnB,MAAM,EAAE,OAAO;gBACf,OAAO,EAAE,gDAAgD;gBACzD,IAAI,EAAE,SAAS;gBACf,IAAI,EAAE,EAAE;aACT,CAAC,CAAC;QAEL,OAAO;IACT,CAAC;IAED,IAAI,GAAG,CAAC,aAAa,EAAE,CAAC;QACtB,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC;YAC9B,KAAK,EAAE,uBAAuB;YAC9B,OAAO,EAAE,GAAG,CAAC,OAAO;YACpB,IAAI,EAAE,SAAS;SAChB,CAAC,CAAC;QACH,OAAO;IACT,CAAC;IAED,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC;QAC9B,KAAK,EAAE,uBAAuB;QAC9B,OAAO,EAAE,gDAAgD;KAC1D,CAAC,CAAC;AACL,CAAC;AAWD,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,GAAG,EAAE;IACzB,IAAI,OAAO,CAAC,GAAG,CAAC,WAAW,KAAK,MAAM,EAAE,CAAC;QACvC,OAAO,CAAC,IAAI,EAAE,CAAC;IACjB,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,KAAK,CAAC,2DAA2D,CAAC,CAAC;QAE3E,eAAM,CAAC,KAAK,CAAC,GAAG,EAAE;YAChB,OAAO,CAAC,KAAK,CAAC,uBAAuB,CAAC,CAAC;YACvC,OAAO,CAAC,IAAI,EAAE,CAAC;QACjB,CAAC,CAAC,CAAC;IACL,CAAC;AACH,CAAC,CAAC,CAAC","sourcesContent":["import { NextFunction, Request, Response } from \"express\";\nimport AppError from \"./utils/app-error\";\nimport * as errorControllerHelper from \"./utils/error-handler.helpers\";\nimport { server } from \"../../server\";\n\n/**\n * Error handling middleware for Express.\n *\n * This middleware function handles all errors in the Express application.\n * It checks for the environment (development or production) and sends appropriate error responses\n * based on whether the environment is production or not. It also maps specific errors such as\n * JWT errors, Prisma client errors, and database-related errors to specific helper functions for handling.\n *\n * @param {AppError} err - The error object thrown by the application.\n * @param {Request} req - The Express request object.\n * @param {Response} res - The Express response object.\n * @param {NextFunction} _ - The next middleware function in the chain.\n *\n * @returns {void} - Sends the response with the error details to the client.\n */\nexport default function errorHandler(\n err: AppError,\n req: Request,\n res: Response,\n _: NextFunction\n): void {\n console.error(\"[\\x1b[31mError\\x1b[0m]:\", err);\n\n err.statusCode = err.statusCode || 500;\n err.status = err.status || \"error\";\n\n let error: any = {\n ...err,\n message: err.message,\n stack: err?.stack || undefined,\n };\n\n if (process.env.ARKOS_BUILD === \"true\") delete error?.stack;\n\n if (err.name === \"JsonWebTokenError\")\n error = errorControllerHelper.handleJWTError();\n if (err.name === \"TokenExpiredError\")\n error = errorControllerHelper.handleJWTExpired();\n\n if (err.name === \"PrismaClientValidationError\")\n error = errorControllerHelper.handlePrismaClientValidationError(err);\n if (err.name === \"PrismaClientInitializationError\")\n error = errorControllerHelper.handlePrismaClientInitializationError(err);\n if (err.code === \"P1000\")\n error = errorControllerHelper.handleAuthenticationError(err);\n if (err.code === \"P1001\")\n error = errorControllerHelper.handleServerNotReachableError(err);\n if (err.code === \"P1002\")\n error = errorControllerHelper.handleConnectionTimeoutError(err);\n if (err.code === \"P1003\")\n error = errorControllerHelper.handleDatabaseNotFoundError(err);\n if (err.code === \"P2000\")\n error = errorControllerHelper.handleFieldValueTooLargeError(err);\n if (err.code === \"P2001\")\n error = errorControllerHelper.handleRecordNotFoundError(err);\n if (err.code === \"P2002\")\n error = errorControllerHelper.handleUniqueConstraintError(err);\n if (err.code === \"P2003\")\n error = errorControllerHelper.handleForeignKeyConstraintError(err);\n if (err.code === \"P2004\")\n error = errorControllerHelper.handleConstraintFailedError(err);\n if (err.code === \"P2025\")\n error = errorControllerHelper.handleNonExistingRecord(err);\n if (err.code === \"P3000\")\n error = errorControllerHelper.handleSchemaCreationFailedError(err);\n if (err.code === \"P3001\")\n error = errorControllerHelper.handleMigrationAlreadyAppliedError(err);\n if (err.code === \"P3002\")\n error = errorControllerHelper.handleMigrationScriptFailedError(err);\n if (err.code === \"P3003\")\n error = errorControllerHelper.handleVersionMismatchError(err);\n\n if (process.env.ARKOS_BUILD !== \"true\")\n return sendDevelopmentError(\n {\n ...error,\n message: error.message,\n stack: err.stack,\n originalError: err,\n },\n req,\n res\n );\n\n sendProductionError(error, req, res);\n}\n\n/**\n * Sends a detailed error response in development mode.\n *\n * In development, the error response includes full error details, including\n * the stack trace and the complete error message.\n *\n * @param {AppError} err - The error object.\n * @param {Request} req - The Express request object.\n * @param {Response} res - The Express response object.\n *\n * @returns {void} - Sends the response with the error details to the client.\n */\nfunction sendDevelopmentError(err: any, req: Request, res: Response): void {\n if (req.originalUrl.startsWith(\"/api\"))\n res.status(err.statusCode).json({\n ...err,\n message:\n err.message?.split?.(\"\\n\")[err.message?.split?.(\"\\n\").length - 1],\n stack: err?.originalError?.stack?.split?.(\"\\n\"),\n });\n else\n res.status(err.statusCode).json({\n title: \"Internal server error\",\n message: err.message,\n });\n}\n\n/**\n * Sends a generic error response in production mode.\n *\n * In production, sensitive error details (such as stack traces) are not exposed\n * to the client. Only operational errors are shown with a generic message.\n *\n * @param {AppError} err - The error object.\n * @param {Request} req - The Express request object.\n * @param {Response} res - The Express response object.\n *\n * @returns {void} - Sends the response with the error details to the client.\n */\nfunction sendProductionError(err: AppError, req: Request, res: Response): void {\n if (req.originalUrl.startsWith(\"/api\")) {\n if (err.isOperational)\n res.status(err.statusCode).json({\n status: err.status,\n message: err.message,\n meta: err.meta || {},\n code: err.code || \"Unknown\",\n });\n else\n res.status(500).json({\n status: \"error\",\n message: \"Internal server error, please try again later.\",\n code: \"Unknown\",\n meta: {},\n });\n\n return;\n }\n\n if (err.isOperational) {\n res.status(err.statusCode).json({\n title: \"Internal server error\",\n message: err.message,\n code: \"Unknown\",\n });\n return;\n }\n\n res.status(err.statusCode).json({\n title: \"Internal server error\",\n message: \"Internal server error, please try again later.\",\n });\n}\n\n/**\n * Gracefully handles process termination by listening for SIGTERM signal.\n *\n * - In production and staging environments, it will log a shutdown message\n * and attempt to close the server gracefully.\n * - In development or non-production environments, it will immediately exit the process.\n *\n * @returns {void}\n */\nprocess.on(\"SIGTERM\", () => {\n if (process.env.ARKOS_BUILD !== \"true\") {\n process.exit();\n } else {\n console.error(\"SIGTERM RECEIVED in Production. Shutting down gracefully!\");\n\n server.close(() => {\n console.error(\"Process terminated!!!\");\n process.exit();\n });\n }\n});\n"]}
|
|
@@ -10,34 +10,15 @@ exports.handleAuthenticationError = handleAuthenticationError;
|
|
|
10
10
|
exports.handleServerNotReachableError = handleServerNotReachableError;
|
|
11
11
|
exports.handleConnectionTimeoutError = handleConnectionTimeoutError;
|
|
12
12
|
exports.handleDatabaseNotFoundError = handleDatabaseNotFoundError;
|
|
13
|
-
exports.handleEnvironmentVariableError = handleEnvironmentVariableError;
|
|
14
13
|
exports.handleFieldValueTooLargeError = handleFieldValueTooLargeError;
|
|
15
14
|
exports.handleRecordNotFoundError = handleRecordNotFoundError;
|
|
16
15
|
exports.handleUniqueConstraintError = handleUniqueConstraintError;
|
|
17
16
|
exports.handleForeignKeyConstraintError = handleForeignKeyConstraintError;
|
|
18
17
|
exports.handleConstraintFailedError = handleConstraintFailedError;
|
|
19
|
-
exports.handleInvalidFieldValueError = handleInvalidFieldValueError;
|
|
20
|
-
exports.handleInvalidFieldProvidedError = handleInvalidFieldProvidedError;
|
|
21
|
-
exports.handleDataValidationError = handleDataValidationError;
|
|
22
|
-
exports.handleQueryParsingError = handleQueryParsingError;
|
|
23
|
-
exports.handleInvalidQueryFormatError = handleInvalidQueryFormatError;
|
|
24
|
-
exports.handleRawQueryExecutionError = handleRawQueryExecutionError;
|
|
25
|
-
exports.handleNullConstraintViolationError = handleNullConstraintViolationError;
|
|
26
18
|
exports.handleSchemaCreationFailedError = handleSchemaCreationFailedError;
|
|
27
19
|
exports.handleMigrationAlreadyAppliedError = handleMigrationAlreadyAppliedError;
|
|
28
20
|
exports.handleMigrationScriptFailedError = handleMigrationScriptFailedError;
|
|
29
21
|
exports.handleVersionMismatchError = handleVersionMismatchError;
|
|
30
|
-
exports.handleMigrationFileReadError = handleMigrationFileReadError;
|
|
31
|
-
exports.handleSchemaDriftError = handleSchemaDriftError;
|
|
32
|
-
exports.handleSchemaSyntaxError = handleSchemaSyntaxError;
|
|
33
|
-
exports.handleClientTypeError = handleClientTypeError;
|
|
34
|
-
exports.handleDynamicQueryError = handleDynamicQueryError;
|
|
35
|
-
exports.handleRelationLoadingError = handleRelationLoadingError;
|
|
36
|
-
exports.handleBinaryError = handleBinaryError;
|
|
37
|
-
exports.handleNetworkError = handleNetworkError;
|
|
38
|
-
exports.handleUnhandledPromiseError = handleUnhandledPromiseError;
|
|
39
|
-
exports.handleDataTypeError = handleDataTypeError;
|
|
40
|
-
exports.handleEmptyResultError = handleEmptyResultError;
|
|
41
22
|
exports.handleNonExistingRecord = handleNonExistingRecord;
|
|
42
23
|
exports.handlePrismaClientInitializationError = handlePrismaClientInitializationError;
|
|
43
24
|
const app_error_1 = __importDefault(require("./app-error.js"));
|
|
@@ -67,11 +48,6 @@ function handleDatabaseNotFoundError(_) {
|
|
|
67
48
|
const message = "The specified database does not exist on the server.";
|
|
68
49
|
return new app_error_1.default(message, 404);
|
|
69
50
|
}
|
|
70
|
-
function handleEnvironmentVariableError(err) {
|
|
71
|
-
const missingVars = err?.missing || "unknown environment variables";
|
|
72
|
-
const message = `Missing or invalid environment variables: ${missingVars}. Please check your configuration.`;
|
|
73
|
-
return new app_error_1.default(message, 500);
|
|
74
|
-
}
|
|
75
51
|
function handleFieldValueTooLargeError(err) {
|
|
76
52
|
const message = `The value for the field "${err?.meta?.field_name}" is too large. Please provide a smaller value.`;
|
|
77
53
|
return new app_error_1.default(message, 400);
|
|
@@ -94,39 +70,6 @@ function handleConstraintFailedError(err) {
|
|
|
94
70
|
const message = `A database constraint "${constraint}" failed. Please review your input data.`;
|
|
95
71
|
return new app_error_1.default(message, 400);
|
|
96
72
|
}
|
|
97
|
-
function handleInvalidFieldValueError(err) {
|
|
98
|
-
const fieldName = err?.meta?.field_name || "unknown field";
|
|
99
|
-
const message = `Invalid value provided for the field "${fieldName}". Please provide a valid value.`;
|
|
100
|
-
return new app_error_1.default(message, 400);
|
|
101
|
-
}
|
|
102
|
-
function handleInvalidFieldProvidedError(err) {
|
|
103
|
-
const fieldName = err?.meta?.field_name || "unknown field";
|
|
104
|
-
const message = `The field "${fieldName}" has been provided with an invalid value. Check the data and try again.`;
|
|
105
|
-
return new app_error_1.default(message, 400);
|
|
106
|
-
}
|
|
107
|
-
function handleDataValidationError(_) {
|
|
108
|
-
const message = "Data validation error occurred. Please ensure all fields meet the required criteria.";
|
|
109
|
-
return new app_error_1.default(message, 400);
|
|
110
|
-
}
|
|
111
|
-
function handleQueryParsingError(err) {
|
|
112
|
-
const query = err?.meta?.query || "unknown query";
|
|
113
|
-
const message = `Failed to parse the query: "${query}". Check the syntax and structure.`;
|
|
114
|
-
return new app_error_1.default(message, 400);
|
|
115
|
-
}
|
|
116
|
-
function handleInvalidQueryFormatError(err) {
|
|
117
|
-
const query = err?.meta?.query || "unknown query";
|
|
118
|
-
const message = `The query format is invalid: "${query}". Ensure the query adheres to the expected format.`;
|
|
119
|
-
return new app_error_1.default(message, 400);
|
|
120
|
-
}
|
|
121
|
-
function handleRawQueryExecutionError(_) {
|
|
122
|
-
const message = "An error occurred during the execution of a raw query. Verify the query and try again.";
|
|
123
|
-
return new app_error_1.default(message, 500);
|
|
124
|
-
}
|
|
125
|
-
function handleNullConstraintViolationError(err) {
|
|
126
|
-
const fieldName = err?.meta?.field_name || "unknown field";
|
|
127
|
-
const message = `The field "${fieldName}" cannot be null. Please provide a value.`;
|
|
128
|
-
return new app_error_1.default(message, 400);
|
|
129
|
-
}
|
|
130
73
|
function handleSchemaCreationFailedError(_) {
|
|
131
74
|
const message = "Failed to create the database schema. Verify the schema definition and try again.";
|
|
132
75
|
return new app_error_1.default(message, 500);
|
|
@@ -145,55 +88,6 @@ function handleVersionMismatchError(_) {
|
|
|
145
88
|
const message = `Version mismatch: The database schema and migration versions are inconsistent. Please check and resolve this issue.`;
|
|
146
89
|
return new app_error_1.default(message, 400);
|
|
147
90
|
}
|
|
148
|
-
function handleMigrationFileReadError(err) {
|
|
149
|
-
const migrationFile = err?.meta?.migration_file || "unknown file";
|
|
150
|
-
const message = `Failed to read the migration file "${migrationFile}". Ensure the file exists and is accessible.`;
|
|
151
|
-
return new app_error_1.default(message, 500);
|
|
152
|
-
}
|
|
153
|
-
function handleSchemaDriftError(_) {
|
|
154
|
-
const message = `Schema drift detected: The database schema differs from the expected state. Run migrations or sync schema to resolve.`;
|
|
155
|
-
return new app_error_1.default(message, 400);
|
|
156
|
-
}
|
|
157
|
-
function handleSchemaSyntaxError(_) {
|
|
158
|
-
const message = `Syntax error in the schema file. Please check for typos or invalid syntax in your schema definition.`;
|
|
159
|
-
return new app_error_1.default(message, 500);
|
|
160
|
-
}
|
|
161
|
-
function handleClientTypeError(_) {
|
|
162
|
-
const message = `Type error, Ensure proper usage of methods and correct data types.`;
|
|
163
|
-
return new app_error_1.default(message, 400);
|
|
164
|
-
}
|
|
165
|
-
function handleDynamicQueryError(_) {
|
|
166
|
-
const message = `Error constructing or executing a dynamic query. Verify query structure and parameters.`;
|
|
167
|
-
return new app_error_1.default(message, 400);
|
|
168
|
-
}
|
|
169
|
-
function handleRelationLoadingError(err) {
|
|
170
|
-
const relation = err?.meta?.relation || "unknown relation";
|
|
171
|
-
const message = `Error loading relation "${relation}". Ensure it is correctly defined and included in the query.`;
|
|
172
|
-
return new app_error_1.default(message, 400);
|
|
173
|
-
}
|
|
174
|
-
function handleBinaryError(err) {
|
|
175
|
-
const binaryName = err?.meta?.binary || "unknown binary";
|
|
176
|
-
const message = `Error with Prisma binary "${binaryName}". Ensure the binary is properly installed and compatible.`;
|
|
177
|
-
return new app_error_1.default(message, 500);
|
|
178
|
-
}
|
|
179
|
-
function handleNetworkError(_) {
|
|
180
|
-
const message = `Network error: Unable to connect to the database or internet. Please check your network connection.`;
|
|
181
|
-
return new app_error_1.default(message, 500);
|
|
182
|
-
}
|
|
183
|
-
function handleUnhandledPromiseError(_) {
|
|
184
|
-
const message = `Unhandled promise rejection detected. Please check asynchronous code for proper error handling.`;
|
|
185
|
-
return new app_error_1.default(message, 500);
|
|
186
|
-
}
|
|
187
|
-
function handleDataTypeError(err) {
|
|
188
|
-
const field = err?.meta?.field || "unknown field";
|
|
189
|
-
const expectedType = err?.meta?.expected_type || "unknown type";
|
|
190
|
-
const message = `Invalid data type for field "${field}". Expected type: ${expectedType}.`;
|
|
191
|
-
return new app_error_1.default(message, 400);
|
|
192
|
-
}
|
|
193
|
-
function handleEmptyResultError(_) {
|
|
194
|
-
const message = `Empty result: No data was found for the given query. Ensure the query criteria are correct.`;
|
|
195
|
-
return new app_error_1.default(message, 404);
|
|
196
|
-
}
|
|
197
91
|
function handleNonExistingRecord(err) {
|
|
198
92
|
const message = err?.meta?.cause ||
|
|
199
93
|
`Operation could not be completed as the required record was not found`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error-handler.helpers.js","sourceRoot":"","sources":["../../../../../src/modules/error-handler/utils/error-handler.helpers.ts"],"names":[],"mappings":";;;;;AASA,wCAEC;AAED,4CAEC;AAED,8EAIC;AAED,8DAIC;AAED,sEAIC;AAED,oEAIC;AAED,kEAGC;AAED,wEAIC;AAED,sEAGC;AAED,8DAIC;AAED,kEAIC;AAED,0EAIC;AAED,kEAIC;AAED,oEAIC;AAED,0EAIC;AAED,8DAIC;AAED,0DAIC;AAED,sEAIC;AAED,oEAIC;AAED,gFAIC;AAED,0EAIC;AAED,gFAIC;AAED,4EAIC;AAED,gEAGC;AAED,oEAIC;AAED,wDAGC;AAED,0DAGC;AAED,sDAGC;AAED,0DAGC;AAED,gEAIC;AAED,8CAIC;AAED,gDAGC;AAED,kEAGC;AAED,kDAKC;AAED,wDAGC;AAED,0DAQC;AAED,sFAOC;AA/ND,4DAAmC;AASnC,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,aAAa,IAAI,cAAc,CAAC;IAChE,MAAM,OAAO,GAAG,gCAAgC,KAAK,qBAAqB,YAAY,GAAG,CAAC;IAC1F,OAAO,IAAI,mBAAQ,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;AACpC,CAAC;AAED,SAAgB,sBAAsB,CAAC,CAAW;IAChD,MAAM,OAAO,GAAG,6FAA6F,CAAC;IAC9G,OAAO,IAAI,mBAAQ,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;AACpC,CAAC;AAED,SAAgB,uBAAuB,CAAC,GAGvC;IACC,MAAM,OAAO,GACX,GAAG,EAAE,IAAI,EAAE,KAAK;QAChB,uEAAuE,CAAC;IAC1E,OAAO,IAAI,mBAAQ,CAAC,OAAO,EAAE,GAAG,EAAE,GAAG,CAAC,IAAI,IAAI,EAAE,EAAE,gBAAgB,CAAC,CAAC;AACtE,CAAC;AAED,SAAgB,qCAAqC,CAAC,CAAM;IAC1D,OAAO,IAAI,mBAAQ,CACjB,iCAAiC,EACjC,GAAG,EACH,EAAE,EACF,sBAAsB,CACvB,CAAC;AACJ,CAAC","sourcesContent":["import AppError from \"./app-error\";\n\nexport interface PrismaError {\n code?: string;\n message: string;\n meta?: Record<string, any>;\n name?: string;\n}\n\nexport function handleJWTError() {\n return new AppError(\"Invalid token. Please log in again!\", 401);\n}\n\nexport function handleJWTExpired() {\n return new AppError(\"Your token has expired, Please log again!\", 401);\n}\n\nexport function handlePrismaClientValidationError(err: AppError) {\n const message =\n err?.message?.split(\"\\n\")[err?.message?.split(\"\\n\").length - 1];\n return new AppError(message, 400);\n}\n\nexport function handleAuthenticationError(_: AppError) {\n const message =\n \"Authentication failed against the database server. Please check your credentials.\";\n return new AppError(message, 401);\n}\n\nexport function handleServerNotReachableError(_: AppError) {\n const message =\n \"The database server is not reachable. Verify your connection string or ensure the server is online.\";\n return new AppError(message, 503);\n}\n\nexport function handleConnectionTimeoutError(_: AppError) {\n const message =\n \"Connection to the database timed out. Please check server performance or network connectivity.\";\n return new AppError(message, 504);\n}\n\nexport function handleDatabaseNotFoundError(_: AppError) {\n const message = \"The specified database does not exist on the server.\";\n return new AppError(message, 404);\n}\n\nexport function handleEnvironmentVariableError(err: AppError) {\n const missingVars = err?.missing || \"unknown environment variables\";\n const message = `Missing or invalid environment variables: ${missingVars}. Please check your configuration.`;\n return new AppError(message, 500);\n}\n\nexport function handleFieldValueTooLargeError(err: AppError) {\n const message = `The value for the field \"${err?.meta?.field_name}\" is too large. Please provide a smaller value.`;\n return new AppError(message, 400);\n}\n\nexport function handleRecordNotFoundError(_: AppError) {\n const message =\n \"No record found for the given query. Ensure the query parameters are correct.\";\n return new AppError(message, 404);\n}\n\nexport function handleUniqueConstraintError(err: AppError) {\n const field = err?.meta?.target || \"unknown field\";\n const message = `Duplicate value detected for the unique field(s): ${field}. Please use a different value.`;\n return new AppError(message, 409);\n}\n\nexport function handleForeignKeyConstraintError(_: AppError) {\n const message =\n \"Foreign key constraint violation. Ensure that the referenced record exists.\";\n return new AppError(message, 400);\n}\n\nexport function handleConstraintFailedError(err: AppError) {\n const constraint = err?.meta?.constraint || \"unknown constraint\";\n const message = `A database constraint \"${constraint}\" failed. Please review your input data.`;\n return new AppError(message, 400);\n}\n\nexport function handleInvalidFieldValueError(err: AppError) {\n const fieldName = err?.meta?.field_name || \"unknown field\";\n const message = `Invalid value provided for the field \"${fieldName}\". Please provide a valid value.`;\n return new AppError(message, 400);\n}\n\nexport function handleInvalidFieldProvidedError(err: AppError) {\n const fieldName = err?.meta?.field_name || \"unknown field\";\n const message = `The field \"${fieldName}\" has been provided with an invalid value. Check the data and try again.`;\n return new AppError(message, 400);\n}\n\nexport function handleDataValidationError(_: AppError) {\n const message =\n \"Data validation error occurred. Please ensure all fields meet the required criteria.\";\n return new AppError(message, 400);\n}\n\nexport function handleQueryParsingError(err: AppError) {\n const query = err?.meta?.query || \"unknown query\";\n const message = `Failed to parse the query: \"${query}\". Check the syntax and structure.`;\n return new AppError(message, 400);\n}\n\nexport function handleInvalidQueryFormatError(err: AppError) {\n const query = err?.meta?.query || \"unknown query\";\n const message = `The query format is invalid: \"${query}\". Ensure the query adheres to the expected format.`;\n return new AppError(message, 400);\n}\n\nexport function handleRawQueryExecutionError(_: AppError) {\n const message =\n \"An error occurred during the execution of a raw query. Verify the query and try again.\";\n return new AppError(message, 500);\n}\n\nexport function handleNullConstraintViolationError(err: AppError) {\n const fieldName = err?.meta?.field_name || \"unknown field\";\n const message = `The field \"${fieldName}\" cannot be null. Please provide a value.`;\n return new AppError(message, 400);\n}\n\nexport function handleSchemaCreationFailedError(_: AppError) {\n const message =\n \"Failed to create the database schema. Verify the schema definition and try again.\";\n return new AppError(message, 500);\n}\n\nexport function handleMigrationAlreadyAppliedError(err: AppError) {\n const migrationName = err?.meta?.migration || \"unknown migration\";\n const message = `The migration \"${migrationName}\" has already been applied to the database.`;\n return new AppError(message, 409);\n}\n\nexport function handleMigrationScriptFailedError(err: AppError) {\n const migrationName = err?.meta?.migration || \"unknown migration\";\n const message = `The migration script \"${migrationName}\" failed. Review the script and resolve any issues.`;\n return new AppError(message, 500);\n}\n\nexport function handleVersionMismatchError(_: AppError) {\n const message = `Version mismatch: The database schema and migration versions are inconsistent. Please check and resolve this issue.`;\n return new AppError(message, 400);\n}\n\nexport function handleMigrationFileReadError(err: AppError) {\n const migrationFile = err?.meta?.migration_file || \"unknown file\";\n const message = `Failed to read the migration file \"${migrationFile}\". Ensure the file exists and is accessible.`;\n return new AppError(message, 500);\n}\n\nexport function handleSchemaDriftError(_: AppError) {\n const message = `Schema drift detected: The database schema differs from the expected state. Run migrations or sync schema to resolve.`;\n return new AppError(message, 400);\n}\n\nexport function handleSchemaSyntaxError(_: AppError) {\n const message = `Syntax error in the schema file. Please check for typos or invalid syntax in your schema definition.`;\n return new AppError(message, 500);\n}\n\nexport function handleClientTypeError(_: AppError) {\n const message = `Type error, Ensure proper usage of methods and correct data types.`;\n return new AppError(message, 400);\n}\n\nexport function handleDynamicQueryError(_: AppError) {\n const message = `Error constructing or executing a dynamic query. Verify query structure and parameters.`;\n return new AppError(message, 400);\n}\n\nexport function handleRelationLoadingError(err: AppError) {\n const relation = err?.meta?.relation || \"unknown relation\";\n const message = `Error loading relation \"${relation}\". Ensure it is correctly defined and included in the query.`;\n return new AppError(message, 400);\n}\n\nexport function handleBinaryError(err: AppError) {\n const binaryName = err?.meta?.binary || \"unknown binary\";\n const message = `Error with Prisma binary \"${binaryName}\". Ensure the binary is properly installed and compatible.`;\n return new AppError(message, 500);\n}\n\nexport function handleNetworkError(_: AppError) {\n const message = `Network error: Unable to connect to the database or internet. Please check your network connection.`;\n return new AppError(message, 500);\n}\n\nexport function handleUnhandledPromiseError(_: AppError) {\n const message = `Unhandled promise rejection detected. Please check asynchronous code for proper error handling.`;\n return new AppError(message, 500);\n}\n\nexport function handleDataTypeError(err: AppError) {\n const field = err?.meta?.field || \"unknown field\";\n const expectedType = err?.meta?.expected_type || \"unknown type\";\n const message = `Invalid data type for field \"${field}\". Expected type: ${expectedType}.`;\n return new AppError(message, 400);\n}\n\nexport function handleEmptyResultError(_: AppError) {\n const message = `Empty result: No data was found for the given query. Ensure the query criteria are correct.`;\n return new AppError(message, 404);\n}\n\nexport function handleNonExistingRecord(err: {\n meta?: Record<string, any>;\n [x: string]: any;\n}) {\n const message =\n err?.meta?.cause ||\n `Operation could not be completed as the required record was not found`;\n return new AppError(message, 404, err.meta || {}, \"RecordNotFound\");\n}\n\nexport function handlePrismaClientInitializationError(_: any) {\n return new AppError(\n \"Service temporarily unavailable\",\n 503,\n {},\n \"DatabaseNotAvailable\"\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"error-handler.helpers.js","sourceRoot":"","sources":["../../../../../src/modules/error-handler/utils/error-handler.helpers.ts"],"names":[],"mappings":";;;;;AASA,wCAEC;AAED,4CAEC;AAED,8EAIC;AAED,8DAIC;AAED,sEAIC;AAED,oEAIC;AAED,kEAGC;AAED,sEAGC;AAED,8DAIC;AAED,kEAIC;AAED,0EAIC;AAED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AAED,SAAgB,gCAAgC,CAAC,GAAa;IAC5D,MAAM,aAAa,GAAG,GAAG,EAAE,IAAI,EAAE,SAAS,IAAI,mBAAmB,CAAC;IAClE,MAAM,OAAO,GAAG,yBAAyB,aAAa,qDAAqD,CAAC;IAC5G,OAAO,IAAI,mBAAQ,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;AACpC,CAAC;AAED,SAAgB,0BAA0B,CAAC,CAAW;IACpD,MAAM,OAAO,GAAG,qHAAqH,CAAC;IACtI,OAAO,IAAI,mBAAQ,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;AACpC,CAAC;AAED,SAAgB,uBAAuB,CAAC,GAGvC;IACC,MAAM,OAAO,GACX,GAAG,EAAE,IAAI,EAAE,KAAK;QAChB,uEAAuE,CAAC;IAC1E,OAAO,IAAI,mBAAQ,CAAC,OAAO,EAAE,GAAG,EAAE,GAAG,CAAC,IAAI,IAAI,EAAE,EAAE,gBAAgB,CAAC,CAAC;AACtE,CAAC;AAED,SAAgB,qCAAqC,CAAC,CAAM;IAC1D,OAAO,IAAI,mBAAQ,CACjB,iCAAiC,EACjC,GAAG,EACH,EAAE,EACF,sBAAsB,CACvB,CAAC;AACJ,CAAC","sourcesContent":["import AppError from \"./app-error\";\n\nexport interface PrismaError {\n code?: string;\n message: string;\n meta?: Record<string, any>;\n name?: string;\n}\n\nexport function handleJWTError() {\n return new AppError(\"Invalid token. Please log in again!\", 401);\n}\n\nexport function handleJWTExpired() {\n return new AppError(\"Your token has expired, Please log again!\", 401);\n}\n\nexport function handlePrismaClientValidationError(err: AppError) {\n const message =\n err?.message?.split(\"\\n\")[err?.message?.split(\"\\n\").length - 1];\n return new AppError(message, 400);\n}\n\nexport function handleAuthenticationError(_: AppError) {\n const message =\n \"Authentication failed against the database server. Please check your credentials.\";\n return new AppError(message, 401);\n}\n\nexport function handleServerNotReachableError(_: AppError) {\n const message =\n \"The database server is not reachable. Verify your connection string or ensure the server is online.\";\n return new AppError(message, 503);\n}\n\nexport function handleConnectionTimeoutError(_: AppError) {\n const message =\n \"Connection to the database timed out. Please check server performance or network connectivity.\";\n return new AppError(message, 504);\n}\n\nexport function handleDatabaseNotFoundError(_: AppError) {\n const message = \"The specified database does not exist on the server.\";\n return new AppError(message, 404);\n}\n\nexport function handleFieldValueTooLargeError(err: AppError) {\n const message = `The value for the field \"${err?.meta?.field_name}\" is too large. Please provide a smaller value.`;\n return new AppError(message, 400);\n}\n\nexport function handleRecordNotFoundError(_: AppError) {\n const message =\n \"No record found for the given query. Ensure the query parameters are correct.\";\n return new AppError(message, 404);\n}\n\nexport function handleUniqueConstraintError(err: AppError) {\n const field = err?.meta?.target || \"unknown field\";\n const message = `Duplicate value detected for the unique field(s): ${field}. Please use a different value.`;\n return new AppError(message, 409);\n}\n\nexport function handleForeignKeyConstraintError(_: AppError) {\n const message =\n \"Foreign key constraint violation. Ensure that the referenced record exists.\";\n return new AppError(message, 400);\n}\n\nexport function handleConstraintFailedError(err: AppError) {\n const constraint = err?.meta?.constraint || \"unknown constraint\";\n const message = `A database constraint \"${constraint}\" failed. Please review your input data.`;\n return new AppError(message, 400);\n}\n\nexport function handleSchemaCreationFailedError(_: AppError) {\n const message =\n \"Failed to create the database schema. Verify the schema definition and try again.\";\n return new AppError(message, 500);\n}\n\nexport function handleMigrationAlreadyAppliedError(err: AppError) {\n const migrationName = err?.meta?.migration || \"unknown migration\";\n const message = `The migration \"${migrationName}\" has already been applied to the database.`;\n return new AppError(message, 409);\n}\n\nexport function handleMigrationScriptFailedError(err: AppError) {\n const migrationName = err?.meta?.migration || \"unknown migration\";\n const message = `The migration script \"${migrationName}\" failed. Review the script and resolve any issues.`;\n return new AppError(message, 500);\n}\n\nexport function handleVersionMismatchError(_: AppError) {\n const message = `Version mismatch: The database schema and migration versions are inconsistent. Please check and resolve this issue.`;\n return new AppError(message, 400);\n}\n\nexport function handleNonExistingRecord(err: {\n meta?: Record<string, any>;\n [x: string]: any;\n}) {\n const message =\n err?.meta?.cause ||\n `Operation could not be completed as the required record was not found`;\n return new AppError(message, 404, err.meta || {}, \"RecordNotFound\");\n}\n\nexport function handlePrismaClientInitializationError(_: any) {\n return new AppError(\n \"Service temporarily unavailable\",\n 503,\n {},\n \"DatabaseNotAvailable\"\n );\n}\n"]}
|
|
@@ -17,6 +17,7 @@ const router_validator_1 = __importDefault(require("../base/utils/router-validat
|
|
|
17
17
|
const fs_helpers_1 = require("../../utils/helpers/fs.helpers.js");
|
|
18
18
|
const path_1 = __importDefault(require("path"));
|
|
19
19
|
const arkos_router_1 = __importDefault(require("../../utils/arkos-router/index.js"));
|
|
20
|
+
const file_upload_json_schema_generator_1 = __importDefault(require("./utils/file-upload-json-schema-generator.js"));
|
|
20
21
|
function getFileUploadRouter(arkosConfig) {
|
|
21
22
|
const router = (0, arkos_router_1.default)();
|
|
22
23
|
const { fileUpload } = arkosConfig;
|
|
@@ -44,6 +45,24 @@ function getFileUploadRouter(arkosConfig) {
|
|
|
44
45
|
else
|
|
45
46
|
throw Error(`ValidationError: The exported router from file-upload.router.${(0, fs_helpers_1.getUserFileExtension)()} is not a valid express or arkos Router.`);
|
|
46
47
|
}
|
|
48
|
+
const endpoints = [
|
|
49
|
+
"findFile",
|
|
50
|
+
"uploadFile",
|
|
51
|
+
"updateFile",
|
|
52
|
+
"deleteFile",
|
|
53
|
+
];
|
|
54
|
+
for (const endpoint of endpoints) {
|
|
55
|
+
const endpointConfig = routerConfig[endpoint];
|
|
56
|
+
if (endpointConfig?.experimental?.openapi === false)
|
|
57
|
+
continue;
|
|
58
|
+
routerConfig[endpoint] = {
|
|
59
|
+
...(endpointConfig || {}),
|
|
60
|
+
experimental: {
|
|
61
|
+
...(endpointConfig?.experimental || {}),
|
|
62
|
+
openapi: file_upload_json_schema_generator_1.default.getOpenApiConfig(endpointConfig, endpoint),
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
}
|
|
47
66
|
if (!(0, base_router_helpers_1.isEndpointDisabled)(routerConfig, "findFile")) {
|
|
48
67
|
const baseUploadDirFullPath = path_1.default.resolve(path_1.default
|
|
49
68
|
.join(process.cwd(), fileUpload?.baseUploadDir || "uploads")
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-upload.router.js","sourceRoot":"","sources":["../../../../src/modules/file-upload/file-upload.router.ts"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"file-upload.router.js","sourceRoot":"","sources":["../../../../src/modules/file-upload/file-upload.router.ts"],"names":[],"mappings":";;;;;AAsBA,kDA8JC;AAnLD,+DAAiE;AACjE,sFAA4D;AAC5D,sDAA8B;AAC9B,4FAA6D;AAE7D,+DAAwD;AACxD,yEAG6C;AAC7C,6EAAuE;AACvE,mFAA+E;AAC/E,oFAA2D;AAC3D,sFAA6D;AAC7D,+DAAsE;AAEtE,gDAAwB;AACxB,4EAAmD;AAEnD,kHAAsF;AAEtF,SAAgB,mBAAmB,CAAC,WAAwB;IAC1D,MAAM,MAAM,GAAG,IAAA,sBAAW,GAAE,CAAC;IAC7B,MAAM,EAAE,UAAU,EAAE,GAAG,WAAW,CAAC;IAEnC,MAAM,gBAAgB,GAAG,IAAA,oCAAmB,EAAC,aAAa,CAAC,CAAC;IAC5D,IAAI,EACF,YAAY,GAAG,EAAS,EACxB,WAAW,GAAG,EAAiB,EAC/B,MAAM,EAAE,kBAAkB,GAC3B,GAAQ,EAAE,CAAC;IAEZ,IAAI,gBAAgB;QAClB,CAAC;YACC,YAAY,GAAG,EAAE;YACjB,WAAW,GAAG,EAAE;YAChB,MAAM,EAAE,kBAAkB;SAC3B,GAAG,gBAAgB,CAAC,CAAC;IAExB,MAAM,YAAY,GAAG,kBAAkB,EAAE,MAAM,IAAI,EAAE,CAAC;IACtD,IAAI,YAAY,EAAE,OAAO,KAAK,IAAI;QAAE,OAAO,MAAM,CAAC;IAElD,MAAM,YAAY,GAAG,kBAAkB,EAAE,OAAiB,CAAC;IAC3D,IAAI,YAAY,GAAG,UAAU,EAAE,SAAS,IAAI,eAAe,C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AAiB,EACf,WAAW,EACX,YAAY,EACZ,eAAe,EACf,qBAAqB,EACrB,YAAY,EACZ,aAAa,EACb,WAAW,CACZ,EACD,GAAG,IAAA,mCAAiB,EAAC,YAAY,EAAE,gBAAgB,CAAC,EACpD,gCAAoB,CAAC,UAAU,EAC/B,GAAG,IAAA,mCAAiB,EAAC,YAAY,EAAE,eAAe,CAAC,EACnD,+BAAY,EACZ,GAAG,IAAA,mCAAiB,EAAC,YAAY,EAAE,iBAAiB,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CACzE,CAAC;IACJ,CAAC;IAED,IAAI,CAAC,IAAA,wCAAkB,EAAC,YAAY,EAAE,YAAY,CAAC,EAAE,CAAC;QACpD,MAAM,CAAC,MAAM,CACX,IAAA,mCAAiB,EACf,WAAW,EACX,YAAY,EACZ,eAAe,EACf,qBAAqB,EACrB,YAAY,EACZ,aAAa,EACb,WAAW,CACZ,EACD,GAAG,IAAA,mCAAiB,EAAC,YAAY,EAAE,gBAAgB,CAAC,EACpD,gCAAoB,CAAC,UAAU,EAC/B,GAAG,IAAA,mCAAiB,EAAC,YAAY,EAAE,eAAe,CAAC,EACnD,+BAAY,EACZ,GAAG,IAAA,mCAAiB,EAAC,YAAY,EAAE,iBAAiB,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CACzE,CAAC;IACJ,CAAC;IAED,0BAAe,CAAC,oBAAoB,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC;IAC5D,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import { Router } from \"express\";\nimport { getModuleComponents } from \"../../utils/dynamic-loader\";\nimport fileUploadController from \"./file-upload.controller\";\nimport express from \"express\";\nimport deepmerge from \"../../utils/helpers/deepmerge.helper\";\nimport { AuthConfigs } from \"../../types/auth\";\nimport { sendResponse } from \"../base/base.middlewares\";\nimport {\n createRouteConfig,\n processMiddleware,\n} from \"../../utils/helpers/routers.helpers\";\nimport { adjustRequestUrl } from \"./utils/helpers/file-upload.helpers\";\nimport { isEndpointDisabled } from \"../base/utils/helpers/base.router.helpers\";\nimport debuggerService from \"../debugger/debugger.service\";\nimport routerValidator from \"../base/utils/router-validator\";\nimport { getUserFileExtension } from \"../../utils/helpers/fs.helpers\";\nimport { ArkosConfig } from \"../../exports\";\nimport path from \"path\";\nimport ArkosRouter from \"../../utils/arkos-router\";\nimport { FileUploadRouterEndpoint } from \"../../types/router-config\";\nimport fileUploadJsonSchemaGenerator from \"./utils/file-upload-json-schema-generator\";\n\nexport function getFileUploadRouter(arkosConfig: ArkosConfig) {\n const router = ArkosRouter();\n const { fileUpload } = arkosConfig;\n\n const moduleComponents = getModuleComponents(\"file-upload\");\n let {\n interceptors = {} as any,\n authConfigs = {} as AuthConfigs,\n router: customRouterModule,\n }: any = {};\n\n if (moduleComponents)\n ({\n interceptors = {},\n authConfigs = {},\n router: customRouterModule,\n } = moduleComponents);\n\n const routerConfig = customRouterModule?.config || {};\n if (routerConfig?.disable === true) return router;\n\n const customRouter = customRouterModule?.default as Router;\n let basePathname = fileUpload?.baseRoute || \"/api/uploads/\";\n\n if (!basePathname.startsWith(\"/\")) basePathname = \"/\" + basePathname;\n if (!basePathname.endsWith(\"/\")) basePathname = basePathname + \"/\";\n\n // Strip leading slash so createRouteConfig can prepend its own \"/\"\n // e.g. \"/api/uploads/\" → \"api/uploads/\" → createRouteConfig builds \"/api/uploads/*\"\n const baseRoutePrefix = basePathname.slice(1);\n\n if (customRouter && customRouterModule) {\n if (routerValidator.isExpressRouter(customRouter))\n router.use(basePathname, customRouter);\n else\n throw Error(\n `ValidationError: The exported router from file-upload.router.${getUserFileExtension()} is not a valid express or arkos Router.`\n );\n }\n\n const endpoints: FileUploadRouterEndpoint[] = [\n \"findFile\",\n \"uploadFile\",\n \"updateFile\",\n \"deleteFile\",\n ];\n\n for (const endpoint of endpoints) {\n const endpointConfig = routerConfig[endpoint];\n if (endpointConfig?.experimental?.openapi === false) continue;\n routerConfig[endpoint] = {\n ...(endpointConfig || {}),\n experimental: {\n ...(endpointConfig?.experimental || {}),\n openapi: fileUploadJsonSchemaGenerator.getOpenApiConfig(\n endpointConfig,\n endpoint\n ),\n },\n };\n }\n\n if (!isEndpointDisabled(routerConfig, \"findFile\")) {\n const baseUploadDirFullPath = path.resolve(\n path\n .join(process.cwd(), fileUpload?.baseUploadDir || \"uploads\")\n .replaceAll(\"//\", \"/\")\n );\n router.get(\n createRouteConfig(\n arkosConfig,\n \"findFile\",\n baseRoutePrefix,\n `*`,\n routerConfig,\n \"file-upload\",\n authConfigs\n ),\n ...processMiddleware(interceptors?.beforeFindFile),\n adjustRequestUrl,\n express.static(\n baseUploadDirFullPath,\n deepmerge(\n {\n maxAge: \"1y\",\n etag: true,\n lastModified: true,\n dotfiles: \"ignore\",\n fallthrough: true,\n index: false,\n cacheControl: true,\n },\n fileUpload?.expressStatic || {}\n )\n ),\n ...processMiddleware(interceptors?.onFindFileError, { type: \"error\" })\n );\n }\n\n if (!isEndpointDisabled(routerConfig, \"uploadFile\")) {\n router.post(\n createRouteConfig(\n arkosConfig,\n \"uploadFile\",\n baseRoutePrefix,\n `:fileType`,\n routerConfig,\n \"file-upload\",\n authConfigs\n ),\n ...processMiddleware(interceptors?.beforeUploadFile),\n fileUploadController.uploadFile,\n ...processMiddleware(interceptors?.afterUploadFile),\n sendResponse,\n ...processMiddleware(interceptors?.onUploadFileError, { type: \"error\" })\n );\n }\n\n if (!isEndpointDisabled(routerConfig, \"updateFile\")) {\n router.patch(\n createRouteConfig(\n arkosConfig,\n \"updateFile\",\n baseRoutePrefix,\n `:fileType/:fileName`,\n routerConfig,\n \"file-upload\",\n authConfigs\n ),\n ...processMiddleware(interceptors?.beforeUpdateFile),\n fileUploadController.updateFile,\n ...processMiddleware(interceptors?.afterUpdateFile),\n sendResponse,\n ...processMiddleware(interceptors?.onUpdateFileError, { type: \"error\" })\n );\n }\n\n if (!isEndpointDisabled(routerConfig, \"deleteFile\")) {\n router.delete(\n createRouteConfig(\n arkosConfig,\n \"deleteFile\",\n baseRoutePrefix,\n `:fileType/:fileName`,\n routerConfig,\n \"file-upload\",\n authConfigs\n ),\n ...processMiddleware(interceptors?.beforeDeleteFile),\n fileUploadController.deleteFile,\n ...processMiddleware(interceptors?.afterDeleteFile),\n sendResponse,\n ...processMiddleware(interceptors?.onDeleteFileError, { type: \"error\" })\n );\n }\n\n debuggerService.logModuleFinalRouter(\"file-upload\", router);\n return router;\n}\n"]}
|