arkos 1.2.13-test → 1.2.13-test.2
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/README.md +22 -14
- package/cli.js +2 -11
- package/dist/cjs/app.js +1 -1
- package/dist/cjs/app.js.map +1 -1
- package/dist/cjs/exports/auth/index.js +1 -6
- package/dist/cjs/exports/controllers/index.js +1 -11
- package/dist/cjs/exports/error-handler/index.js +1 -11
- package/dist/cjs/exports/index.js +1 -12
- package/dist/cjs/exports/middlewares/index.js +1 -7
- package/dist/cjs/exports/prisma/index.js +1 -6
- package/dist/cjs/exports/services/index.js +1 -49
- package/dist/cjs/exports/utils/index.js +1 -44
- package/dist/cjs/exports/validation/index.js +1 -11
- package/dist/cjs/modules/auth/auth.controller.js +1 -194
- package/dist/cjs/modules/auth/auth.router.js +1 -124
- package/dist/cjs/modules/auth/auth.router.js.map +1 -1
- package/dist/cjs/modules/auth/auth.service.js +1 -192
- package/dist/cjs/modules/auth/auth.service.js.map +1 -1
- package/dist/cjs/modules/auth/utils/helpers/auth.controller.helpers.js +1 -83
- package/dist/cjs/modules/base/base.controller.js +1 -159
- package/dist/cjs/modules/base/base.controller.js.map +1 -1
- package/dist/cjs/modules/base/base.middlewares.js +1 -92
- package/dist/cjs/modules/base/base.middlewares.js.map +1 -1
- package/dist/cjs/modules/base/base.router.js +1 -24
- package/dist/cjs/modules/base/base.router.js.map +1 -1
- package/dist/cjs/modules/base/base.service.js +1 -128
- package/dist/cjs/modules/base/base.service.js.map +1 -1
- package/dist/cjs/modules/base/utils/helpers/base.controller.helpers.js +1 -82
- package/dist/cjs/modules/base/utils/helpers/base.middlewares.helpers.js +1 -50
- package/dist/cjs/modules/base/utils/helpers/base.router.helpers.js +1 -167
- 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 +1 -171
- package/dist/cjs/modules/email/email.service.js +1 -104
- package/dist/cjs/modules/error-handler/error-handler.controller.js +4 -144
- package/dist/cjs/modules/error-handler/error-handler.controller.js.map +1 -1
- package/dist/cjs/modules/error-handler/utils/app-error.js +1 -17
- package/dist/cjs/modules/error-handler/utils/catch-async.js +1 -12
- package/dist/cjs/modules/error-handler/utils/catch-async.js.map +1 -1
- package/dist/cjs/modules/error-handler/utils/error-handler.helpers.js +3 -195
- package/dist/cjs/modules/error-handler/utils/error-handler.helpers.js.map +1 -1
- package/dist/cjs/modules/file-upload/file-upload.controller.js +1 -271
- package/dist/cjs/modules/file-upload/file-upload.router.js +1 -56
- package/dist/cjs/modules/file-upload/file-upload.router.js.map +1 -1
- package/dist/cjs/modules/file-upload/file-upload.service.js +1 -322
- package/dist/cjs/modules/file-upload/utils/helpers/file-upload.helpers.js +1 -90
- package/dist/cjs/modules/file-upload/utils/helpers/file-upload.helpers.js.map +1 -1
- package/dist/cjs/modules/swagger/swagger.router.js +1 -141
- package/dist/cjs/modules/swagger/swagger.router.js.map +1 -1
- package/dist/cjs/modules/swagger/utils/helpers/get-authentication-json-schema-paths.js +1 -0
- package/dist/cjs/modules/swagger/utils/helpers/get-authentication-json-schema-paths.js.map +1 -0
- package/dist/cjs/modules/swagger/utils/helpers/get-system-json-schema-paths.js +1 -0
- package/dist/cjs/modules/swagger/utils/helpers/get-system-json-schema-paths.js.map +1 -0
- package/dist/cjs/modules/swagger/utils/helpers/json-schema-generators/generate-class-validator-json-schemas.js +1 -0
- package/dist/cjs/modules/swagger/utils/helpers/json-schema-generators/generate-class-validator-json-schemas.js.map +1 -0
- package/dist/cjs/modules/swagger/utils/helpers/json-schema-generators/generate-prisma-json-schemas.js +1 -0
- package/dist/cjs/modules/swagger/utils/helpers/json-schema-generators/generate-prisma-json-schemas.js.map +1 -0
- package/dist/cjs/modules/swagger/utils/helpers/json-schema-generators/generate-zod-json-schema.js +1 -0
- package/dist/cjs/modules/swagger/utils/helpers/json-schema-generators/generate-zod-json-schema.js.map +1 -0
- package/dist/cjs/modules/swagger/utils/helpers/json-schema-generators/prisma-models/generate-prisma-model-main-routes.js +1 -0
- package/dist/cjs/modules/swagger/utils/helpers/json-schema-generators/prisma-models/generate-prisma-model-main-routes.js.map +1 -0
- package/dist/cjs/modules/swagger/utils/helpers/json-schema-generators/prisma-models/generate-prisma-model-parent-routes.js +1 -0
- package/dist/cjs/modules/swagger/utils/helpers/json-schema-generators/prisma-models/generate-prisma-model-parent-routes.js.map +1 -0
- package/dist/cjs/modules/swagger/utils/helpers/missing-json-schemas-generator.js +1 -0
- package/dist/cjs/modules/swagger/utils/helpers/missing-json-schemas-generator.js.map +1 -0
- package/dist/cjs/modules/swagger/utils/helpers/swagger.router.helpers.js +1 -0
- package/dist/cjs/modules/swagger/utils/helpers/swagger.router.helpers.js.map +1 -0
- package/dist/cjs/server.js +4 -2
- package/dist/cjs/server.js.map +1 -1
- package/dist/cjs/types/arkos-config.js +1 -3
- package/dist/cjs/types/arkos-config.js.map +1 -1
- package/dist/cjs/types/auth.js +1 -3
- package/dist/cjs/types/index.js +1 -11
- package/dist/cjs/types/router-config.js +1 -3
- package/dist/cjs/utils/arkos-env.js +1 -9
- package/dist/cjs/utils/cli/build.js +6 -229
- package/dist/cjs/utils/cli/build.js.map +1 -1
- package/dist/cjs/utils/cli/dev.js +5 -268
- package/dist/cjs/utils/cli/dev.js.map +1 -1
- package/dist/cjs/utils/cli/generate.js +12 -189
- package/dist/cjs/utils/cli/generate.js.map +1 -1
- package/dist/cjs/utils/cli/index.js +1 -81
- package/dist/cjs/utils/cli/start.js +5 -93
- package/dist/cjs/utils/cli/start.js.map +1 -1
- package/dist/cjs/utils/cli/utils/cli.helpers.js +1 -26
- package/dist/cjs/utils/cli/utils/cli.helpers.js.map +1 -1
- package/dist/cjs/utils/cli/utils/template-generator/templates/generate-auth-configs-template.js +5 -20
- package/dist/cjs/utils/cli/utils/template-generator/templates/generate-controller-template.js +6 -15
- package/dist/cjs/utils/cli/utils/template-generator/templates/generate-middlewares.js +71 -133
- package/dist/cjs/utils/cli/utils/template-generator/templates/generate-middlewares.js.map +1 -1
- package/dist/cjs/utils/cli/utils/template-generator/templates/generate-prisma-query-options.js +24 -46
- package/dist/cjs/utils/cli/utils/template-generator/templates/generate-prisma-query-options.js.map +1 -1
- package/dist/cjs/utils/cli/utils/template-generator/templates/generate-router-template.js +12 -32
- package/dist/cjs/utils/cli/utils/template-generator/templates/generate-router-template.js.map +1 -1
- package/dist/cjs/utils/cli/utils/template-generator/templates/generate-service-template.js +7 -27
- package/dist/cjs/utils/cli/utils/template-generator/templates/generate-service-template.js.map +1 -1
- package/dist/cjs/utils/cli/utils/template-generators.js +2 -28
- package/dist/cjs/utils/dotenv.helpers.js +1 -43
- package/dist/cjs/utils/features/api.features.js +1 -161
- package/dist/cjs/utils/features/api.features.js.map +1 -1
- package/dist/cjs/utils/features/change-case.features.js +1 -67
- package/dist/cjs/utils/helpers/api.features.helpers.js +1 -106
- package/dist/cjs/utils/helpers/change-case.helpers.js +1 -177
- package/dist/cjs/utils/helpers/deepmerge.helper.js +1 -115
- package/dist/cjs/utils/helpers/fs.helpers.js +1 -54
- package/dist/cjs/utils/helpers/fs.helpers.js.map +1 -1
- package/dist/cjs/utils/helpers/global.helpers.js +1 -40
- package/dist/cjs/utils/helpers/global.helpers.js.map +1 -1
- package/dist/cjs/utils/helpers/models.helpers.js +11 -325
- package/dist/cjs/utils/helpers/models.helpers.js.map +1 -1
- package/dist/cjs/utils/helpers/prisma.helpers.js +1 -49
- package/dist/cjs/utils/helpers/prisma.helpers.js.map +1 -1
- package/dist/cjs/utils/helpers/query-parser.helpers.js +1 -45
- package/dist/cjs/utils/helpers/routers.helpers.js +1 -0
- package/dist/cjs/utils/helpers/routers.helpers.js.map +1 -0
- package/dist/cjs/utils/helpers/text.helpers.js +1 -28
- package/dist/cjs/utils/prisma/enhaced-prisma-json-schema-generator.js +1 -0
- package/dist/cjs/utils/prisma/enhaced-prisma-json-schema-generator.js.map +1 -0
- package/dist/cjs/utils/prisma/prisma-json-schema-generator.js +1 -0
- package/dist/cjs/utils/prisma/prisma-json-schema-generator.js.map +1 -0
- package/dist/cjs/utils/prisma/prisma-schema-parser.js +3 -0
- package/dist/cjs/utils/prisma/prisma-schema-parser.js.map +1 -0
- package/dist/cjs/utils/prisma/types.js +1 -0
- package/dist/cjs/utils/prisma/types.js.map +1 -0
- package/dist/cjs/utils/sheu.js +1 -0
- package/dist/cjs/utils/sheu.js.map +1 -0
- package/dist/cjs/utils/validate-dto.js +1 -17
- package/dist/cjs/utils/validate-schema.js +1 -15
- package/dist/esm/app.js +1 -0
- package/dist/esm/app.js.map +1 -0
- package/dist/esm/exports/auth/index.js +1 -0
- package/dist/esm/exports/controllers/index.js +1 -0
- package/dist/esm/exports/error-handler/index.js +1 -0
- package/dist/esm/exports/index.js +1 -0
- package/dist/esm/exports/middlewares/index.js +1 -0
- package/dist/esm/exports/prisma/index.js +1 -0
- package/dist/esm/exports/services/index.js +1 -0
- package/dist/esm/exports/utils/index.js +1 -0
- package/dist/esm/exports/validation/index.js +1 -0
- package/dist/esm/modules/auth/auth.controller.js +1 -0
- package/dist/esm/modules/auth/auth.router.js +1 -0
- package/dist/esm/modules/auth/auth.router.js.map +1 -0
- package/dist/esm/modules/auth/auth.service.js +1 -0
- package/dist/esm/modules/auth/auth.service.js.map +1 -0
- package/dist/esm/modules/auth/utils/helpers/auth.controller.helpers.js +1 -0
- package/dist/esm/modules/base/base.controller.js +1 -0
- package/dist/esm/modules/base/base.controller.js.map +1 -0
- package/dist/esm/modules/base/base.middlewares.js +1 -0
- package/dist/esm/modules/base/base.middlewares.js.map +1 -0
- package/dist/esm/modules/base/base.router.js +1 -0
- package/dist/esm/modules/base/base.router.js.map +1 -0
- package/dist/esm/modules/base/base.service.js +1 -0
- package/dist/{es2020 → esm}/modules/base/base.service.js.map +1 -1
- package/dist/esm/modules/base/utils/helpers/base.controller.helpers.js +1 -0
- package/dist/esm/modules/base/utils/helpers/base.middlewares.helpers.js +1 -0
- package/dist/esm/modules/base/utils/helpers/base.router.helpers.js +1 -0
- package/dist/esm/modules/base/utils/helpers/base.router.helpers.js.map +1 -0
- package/dist/esm/modules/base/utils/helpers/base.service.helpers.js +1 -0
- package/dist/esm/modules/email/email.service.js +1 -0
- package/dist/esm/modules/error-handler/error-handler.controller.js +4 -0
- package/dist/esm/modules/error-handler/error-handler.controller.js.map +1 -0
- package/dist/esm/modules/error-handler/utils/app-error.js +1 -0
- package/dist/esm/modules/error-handler/utils/catch-async.js +1 -0
- package/dist/esm/modules/error-handler/utils/catch-async.js.map +1 -0
- package/dist/esm/modules/error-handler/utils/error-handler.helpers.js +3 -0
- package/dist/esm/modules/error-handler/utils/error-handler.helpers.js.map +1 -0
- package/dist/esm/modules/file-upload/file-upload.controller.js +1 -0
- package/dist/esm/modules/file-upload/file-upload.router.js +1 -0
- package/dist/esm/modules/file-upload/file-upload.router.js.map +1 -0
- package/dist/esm/modules/file-upload/file-upload.service.js +1 -0
- package/dist/esm/modules/file-upload/utils/helpers/file-upload.helpers.js +1 -0
- package/dist/esm/modules/file-upload/utils/helpers/file-upload.helpers.js.map +1 -0
- package/dist/esm/modules/swagger/swagger.router.js +1 -0
- package/dist/esm/modules/swagger/swagger.router.js.map +1 -0
- package/dist/esm/modules/swagger/utils/helpers/get-authentication-json-schema-paths.js +1 -0
- package/dist/esm/modules/swagger/utils/helpers/get-authentication-json-schema-paths.js.map +1 -0
- package/dist/esm/modules/swagger/utils/helpers/get-system-json-schema-paths.js +1 -0
- package/dist/esm/modules/swagger/utils/helpers/get-system-json-schema-paths.js.map +1 -0
- package/dist/esm/modules/swagger/utils/helpers/json-schema-generators/generate-class-validator-json-schemas.js +1 -0
- package/dist/esm/modules/swagger/utils/helpers/json-schema-generators/generate-class-validator-json-schemas.js.map +1 -0
- package/dist/esm/modules/swagger/utils/helpers/json-schema-generators/generate-prisma-json-schemas.js +1 -0
- package/dist/esm/modules/swagger/utils/helpers/json-schema-generators/generate-prisma-json-schemas.js.map +1 -0
- package/dist/esm/modules/swagger/utils/helpers/json-schema-generators/generate-zod-json-schema.js +1 -0
- package/dist/esm/modules/swagger/utils/helpers/json-schema-generators/generate-zod-json-schema.js.map +1 -0
- package/dist/esm/modules/swagger/utils/helpers/json-schema-generators/prisma-models/generate-prisma-model-main-routes.js +1 -0
- package/dist/esm/modules/swagger/utils/helpers/json-schema-generators/prisma-models/generate-prisma-model-main-routes.js.map +1 -0
- package/dist/esm/modules/swagger/utils/helpers/json-schema-generators/prisma-models/generate-prisma-model-parent-routes.js +1 -0
- package/dist/esm/modules/swagger/utils/helpers/json-schema-generators/prisma-models/generate-prisma-model-parent-routes.js.map +1 -0
- package/dist/esm/modules/swagger/utils/helpers/missing-json-schemas-generator.js +1 -0
- package/dist/esm/modules/swagger/utils/helpers/missing-json-schemas-generator.js.map +1 -0
- package/dist/esm/modules/swagger/utils/helpers/swagger.router.helpers.js +1 -0
- package/dist/esm/modules/swagger/utils/helpers/swagger.router.helpers.js.map +1 -0
- package/dist/esm/server.js +5 -0
- package/dist/esm/server.js.map +1 -0
- package/dist/esm/types/arkos-config.js +1 -0
- package/dist/esm/types/arkos-config.js.map +1 -0
- package/dist/esm/types/auth.js +1 -0
- package/dist/esm/types/index.js +1 -0
- package/dist/esm/types/router-config.js +1 -0
- package/dist/esm/utils/arkos-env.js +1 -0
- package/dist/esm/utils/cli/build.js +6 -0
- package/dist/esm/utils/cli/build.js.map +1 -0
- package/dist/esm/utils/cli/dev.js +5 -0
- package/dist/esm/utils/cli/dev.js.map +1 -0
- package/dist/esm/utils/cli/generate.js +12 -0
- package/dist/{es2020 → esm}/utils/cli/generate.js.map +1 -1
- package/dist/esm/utils/cli/index.js +1 -0
- package/dist/esm/utils/cli/start.js +5 -0
- package/dist/esm/utils/cli/start.js.map +1 -0
- package/dist/esm/utils/cli/utils/cli.helpers.js +1 -0
- package/dist/esm/utils/cli/utils/cli.helpers.js.map +1 -0
- package/dist/esm/utils/cli/utils/template-generator/templates/generate-auth-configs-template.js +21 -0
- package/dist/esm/utils/cli/utils/template-generator/templates/generate-controller-template.js +12 -0
- package/dist/esm/utils/cli/utils/template-generator/templates/generate-middlewares.js +206 -0
- package/dist/esm/utils/cli/utils/template-generator/templates/generate-middlewares.js.map +1 -0
- package/dist/esm/utils/cli/utils/template-generator/templates/generate-prisma-query-options.js +36 -0
- package/dist/esm/utils/cli/utils/template-generator/templates/generate-prisma-query-options.js.map +1 -0
- package/dist/esm/utils/cli/utils/template-generator/templates/generate-router-template.js +18 -0
- package/dist/esm/utils/cli/utils/template-generator/templates/generate-router-template.js.map +1 -0
- package/dist/esm/utils/cli/utils/template-generator/templates/generate-service-template.js +15 -0
- package/dist/{es2020 → esm}/utils/cli/utils/template-generator/templates/generate-service-template.js.map +1 -1
- package/dist/esm/utils/cli/utils/template-generators.js +2 -0
- package/dist/esm/utils/dotenv.helpers.js +1 -0
- package/dist/esm/utils/features/api.features.js +1 -0
- package/dist/esm/utils/features/api.features.js.map +1 -0
- package/dist/esm/utils/features/change-case.features.js +1 -0
- package/dist/esm/utils/helpers/api.features.helpers.js +1 -0
- package/dist/esm/utils/helpers/change-case.helpers.js +1 -0
- package/dist/esm/utils/helpers/deepmerge.helper.js +1 -0
- package/dist/esm/utils/helpers/fs.helpers.js +1 -0
- package/dist/esm/utils/helpers/fs.helpers.js.map +1 -0
- package/dist/esm/utils/helpers/global.helpers.js +1 -0
- package/dist/esm/utils/helpers/global.helpers.js.map +1 -0
- package/dist/esm/utils/helpers/models.helpers.js +11 -0
- package/dist/esm/utils/helpers/models.helpers.js.map +1 -0
- package/dist/esm/utils/helpers/prisma.helpers.js +1 -0
- package/dist/esm/utils/helpers/prisma.helpers.js.map +1 -0
- package/dist/esm/utils/helpers/query-parser.helpers.js +1 -0
- package/dist/esm/utils/helpers/routers.helpers.js +1 -0
- package/dist/esm/utils/helpers/routers.helpers.js.map +1 -0
- package/dist/esm/utils/helpers/text.helpers.js +1 -0
- package/dist/esm/utils/prisma/enhaced-prisma-json-schema-generator.js +1 -0
- package/dist/esm/utils/prisma/enhaced-prisma-json-schema-generator.js.map +1 -0
- package/dist/esm/utils/prisma/prisma-json-schema-generator.js +1 -0
- package/dist/esm/utils/prisma/prisma-json-schema-generator.js.map +1 -0
- package/dist/esm/utils/prisma/prisma-schema-parser.js +3 -0
- package/dist/esm/utils/prisma/prisma-schema-parser.js.map +1 -0
- package/dist/esm/utils/prisma/types.js +1 -0
- package/dist/esm/utils/prisma/types.js.map +1 -0
- package/dist/esm/utils/sheu.js +1 -0
- package/dist/esm/utils/sheu.js.map +1 -0
- package/dist/esm/utils/validate-dto.js +1 -0
- package/dist/esm/utils/validate-schema.js +1 -0
- package/dist/types/modules/base/base.middlewares.d.ts +4 -4
- package/dist/types/modules/base/base.service.d.ts +1 -1
- package/dist/types/modules/base/utils/helpers/base.router.helpers.d.ts +4 -1
- package/dist/types/modules/error-handler/utils/catch-async.d.ts +1 -0
- package/dist/types/modules/error-handler/utils/error-handler.helpers.d.ts +4 -0
- package/dist/types/modules/file-upload/file-upload.router.d.ts +1 -1
- package/dist/types/modules/file-upload/utils/helpers/file-upload.helpers.d.ts +2 -1
- package/dist/types/modules/swagger/swagger.router.d.ts +1 -1
- package/dist/types/modules/swagger/utils/helpers/get-authentication-json-schema-paths.d.ts +3 -0
- package/dist/types/modules/swagger/utils/helpers/get-system-json-schema-paths.d.ts +2 -0
- package/dist/types/modules/swagger/utils/helpers/json-schema-generators/generate-class-validator-json-schemas.d.ts +1 -0
- package/dist/types/modules/swagger/utils/helpers/json-schema-generators/generate-prisma-json-schemas.d.ts +2 -0
- package/dist/types/modules/swagger/utils/helpers/json-schema-generators/generate-zod-json-schema.d.ts +1 -0
- package/dist/types/modules/swagger/utils/helpers/json-schema-generators/prisma-models/generate-prisma-model-main-routes.d.ts +3 -0
- package/dist/types/modules/swagger/utils/helpers/json-schema-generators/prisma-models/generate-prisma-model-parent-routes.d.ts +3 -0
- package/dist/types/modules/swagger/utils/helpers/missing-json-schemas-generator.d.ts +34 -0
- package/dist/types/modules/swagger/utils/helpers/swagger.router.helpers.d.ts +7 -0
- package/dist/types/server.d.ts +3 -0
- package/dist/types/types/arkos-config.d.ts +10 -5
- package/dist/types/utils/cli/utils/cli.helpers.d.ts +1 -1
- package/dist/types/utils/features/api.features.d.ts +1 -0
- package/dist/types/utils/helpers/global.helpers.d.ts +6 -1
- package/dist/types/utils/helpers/models.helpers.d.ts +31 -5
- package/dist/types/utils/helpers/routers.helpers.d.ts +2 -0
- package/dist/types/utils/prisma/enhaced-prisma-json-schema-generator.d.ts +34 -0
- package/dist/types/utils/prisma/prisma-json-schema-generator.d.ts +10 -0
- package/dist/types/utils/prisma/prisma-schema-parser.d.ts +18 -0
- package/dist/types/utils/prisma/types.d.ts +48 -0
- package/dist/types/utils/sheu.d.ts +70 -0
- package/package.json +34 -34
- package/dist/es2020/app.js +0 -1
- package/dist/es2020/app.js.map +0 -1
- package/dist/es2020/exports/auth/index.js +0 -2
- package/dist/es2020/exports/controllers/index.js +0 -4
- package/dist/es2020/exports/error-handler/index.js +0 -4
- package/dist/es2020/exports/index.js +0 -8
- package/dist/es2020/exports/middlewares/index.js +0 -2
- package/dist/es2020/exports/prisma/index.js +0 -3
- package/dist/es2020/exports/services/index.js +0 -9
- package/dist/es2020/exports/utils/index.js +0 -4
- package/dist/es2020/exports/validation/index.js +0 -4
- package/dist/es2020/modules/auth/auth.controller.js +0 -187
- package/dist/es2020/modules/auth/auth.router.js +0 -118
- package/dist/es2020/modules/auth/auth.router.js.map +0 -1
- package/dist/es2020/modules/auth/auth.service.js +0 -185
- package/dist/es2020/modules/auth/auth.service.js.map +0 -1
- package/dist/es2020/modules/auth/utils/helpers/auth.controller.helpers.js +0 -73
- package/dist/es2020/modules/base/base.controller.js +0 -151
- package/dist/es2020/modules/base/base.controller.js.map +0 -1
- package/dist/es2020/modules/base/base.middlewares.js +0 -81
- package/dist/es2020/modules/base/base.middlewares.js.map +0 -1
- package/dist/es2020/modules/base/base.router.js +0 -17
- package/dist/es2020/modules/base/base.router.js.map +0 -1
- package/dist/es2020/modules/base/base.service.js +0 -120
- package/dist/es2020/modules/base/utils/helpers/base.controller.helpers.js +0 -77
- package/dist/es2020/modules/base/utils/helpers/base.middlewares.helpers.js +0 -44
- package/dist/es2020/modules/base/utils/helpers/base.router.helpers.js +0 -161
- package/dist/es2020/modules/base/utils/helpers/base.router.helpers.js.map +0 -1
- package/dist/es2020/modules/base/utils/helpers/base.service.helpers.js +0 -165
- package/dist/es2020/modules/email/email.service.js +0 -97
- package/dist/es2020/modules/error-handler/error-handler.controller.js +0 -105
- package/dist/es2020/modules/error-handler/error-handler.controller.js.map +0 -1
- package/dist/es2020/modules/error-handler/utils/app-error.js +0 -15
- package/dist/es2020/modules/error-handler/utils/catch-async.js +0 -10
- package/dist/es2020/modules/error-handler/utils/catch-async.js.map +0 -1
- package/dist/es2020/modules/error-handler/utils/error-handler.helpers.js +0 -155
- package/dist/es2020/modules/error-handler/utils/error-handler.helpers.js.map +0 -1
- package/dist/es2020/modules/file-upload/file-upload.controller.js +0 -266
- package/dist/es2020/modules/file-upload/file-upload.router.js +0 -50
- package/dist/es2020/modules/file-upload/file-upload.router.js.map +0 -1
- package/dist/es2020/modules/file-upload/file-upload.service.js +0 -314
- package/dist/es2020/modules/file-upload/utils/helpers/file-upload.helpers.js +0 -81
- package/dist/es2020/modules/file-upload/utils/helpers/file-upload.helpers.js.map +0 -1
- package/dist/es2020/modules/swagger/swagger.router.js +0 -135
- package/dist/es2020/modules/swagger/swagger.router.js.map +0 -1
- package/dist/es2020/server.js +0 -3
- package/dist/es2020/server.js.map +0 -1
- package/dist/es2020/types/arkos-config.js +0 -2
- package/dist/es2020/types/arkos-config.js.map +0 -1
- package/dist/es2020/types/auth.js +0 -2
- package/dist/es2020/types/index.js +0 -8
- package/dist/es2020/types/router-config.js +0 -2
- package/dist/es2020/utils/arkos-env.js +0 -7
- package/dist/es2020/utils/cli/build.js +0 -223
- package/dist/es2020/utils/cli/build.js.map +0 -1
- package/dist/es2020/utils/cli/dev.js +0 -261
- package/dist/es2020/utils/cli/dev.js.map +0 -1
- package/dist/es2020/utils/cli/generate.js +0 -183
- package/dist/es2020/utils/cli/index.js +0 -74
- package/dist/es2020/utils/cli/start.js +0 -86
- package/dist/es2020/utils/cli/start.js.map +0 -1
- package/dist/es2020/utils/cli/utils/cli.helpers.js +0 -18
- package/dist/es2020/utils/cli/utils/cli.helpers.js.map +0 -1
- package/dist/es2020/utils/cli/utils/template-generator/templates/generate-auth-configs-template.js +0 -33
- package/dist/es2020/utils/cli/utils/template-generator/templates/generate-controller-template.js +0 -18
- package/dist/es2020/utils/cli/utils/template-generator/templates/generate-middlewares.js +0 -265
- package/dist/es2020/utils/cli/utils/template-generator/templates/generate-middlewares.js.map +0 -1
- package/dist/es2020/utils/cli/utils/template-generator/templates/generate-prisma-query-options.js +0 -55
- package/dist/es2020/utils/cli/utils/template-generator/templates/generate-prisma-query-options.js.map +0 -1
- package/dist/es2020/utils/cli/utils/template-generator/templates/generate-router-template.js +0 -32
- package/dist/es2020/utils/cli/utils/template-generator/templates/generate-router-template.js.map +0 -1
- package/dist/es2020/utils/cli/utils/template-generator/templates/generate-service-template.js +0 -32
- package/dist/es2020/utils/cli/utils/template-generators.js +0 -25
- package/dist/es2020/utils/dotenv.helpers.js +0 -37
- package/dist/es2020/utils/features/api.features.js +0 -154
- package/dist/es2020/utils/features/api.features.js.map +0 -1
- package/dist/es2020/utils/features/change-case.features.js +0 -31
- package/dist/es2020/utils/helpers/api.features.helpers.js +0 -103
- package/dist/es2020/utils/helpers/change-case.helpers.js +0 -161
- package/dist/es2020/utils/helpers/deepmerge.helper.js +0 -113
- package/dist/es2020/utils/helpers/fs.helpers.js +0 -45
- package/dist/es2020/utils/helpers/fs.helpers.js.map +0 -1
- package/dist/es2020/utils/helpers/global.helpers.js +0 -4
- package/dist/es2020/utils/helpers/global.helpers.js.map +0 -1
- package/dist/es2020/utils/helpers/models.helpers.js +0 -276
- package/dist/es2020/utils/helpers/models.helpers.js.map +0 -1
- package/dist/es2020/utils/helpers/prisma.helpers.js +0 -41
- package/dist/es2020/utils/helpers/prisma.helpers.js.map +0 -1
- package/dist/es2020/utils/helpers/query-parser.helpers.js +0 -40
- package/dist/es2020/utils/helpers/text.helpers.js +0 -22
- package/dist/es2020/utils/validate-dto.js +0 -11
- package/dist/es2020/utils/validate-schema.js +0 -9
- /package/dist/{es2020 → esm}/exports/auth/index.js.map +0 -0
- /package/dist/{es2020 → esm}/exports/controllers/index.js.map +0 -0
- /package/dist/{es2020 → esm}/exports/error-handler/index.js.map +0 -0
- /package/dist/{es2020 → esm}/exports/index.js.map +0 -0
- /package/dist/{es2020 → esm}/exports/middlewares/index.js.map +0 -0
- /package/dist/{es2020 → esm}/exports/prisma/index.js.map +0 -0
- /package/dist/{es2020 → esm}/exports/services/index.js.map +0 -0
- /package/dist/{es2020 → esm}/exports/utils/index.js.map +0 -0
- /package/dist/{es2020 → esm}/exports/validation/index.js.map +0 -0
- /package/dist/{es2020 → esm}/modules/auth/auth.controller.js.map +0 -0
- /package/dist/{es2020 → esm}/modules/auth/utils/helpers/auth.controller.helpers.js.map +0 -0
- /package/dist/{es2020 → esm}/modules/base/utils/helpers/base.controller.helpers.js.map +0 -0
- /package/dist/{es2020 → esm}/modules/base/utils/helpers/base.middlewares.helpers.js.map +0 -0
- /package/dist/{es2020 → esm}/modules/base/utils/helpers/base.service.helpers.js.map +0 -0
- /package/dist/{es2020 → esm}/modules/email/email.service.js.map +0 -0
- /package/dist/{es2020 → esm}/modules/error-handler/utils/app-error.js.map +0 -0
- /package/dist/{es2020 → esm}/modules/file-upload/file-upload.controller.js.map +0 -0
- /package/dist/{es2020 → esm}/modules/file-upload/file-upload.service.js.map +0 -0
- /package/dist/{es2020 → esm}/paths.js +0 -0
- /package/dist/{es2020 → esm}/paths.js.map +0 -0
- /package/dist/{es2020 → esm}/types/auth.js.map +0 -0
- /package/dist/{es2020 → esm}/types/index.js.map +0 -0
- /package/dist/{es2020 → esm}/types/router-config.js.map +0 -0
- /package/dist/{es2020 → esm}/utils/arkos-env.js.map +0 -0
- /package/dist/{es2020 → esm}/utils/cli/index.js.map +0 -0
- /package/dist/{es2020 → esm}/utils/cli/utils/template-generator/templates/generate-auth-configs-template.js.map +0 -0
- /package/dist/{es2020 → esm}/utils/cli/utils/template-generator/templates/generate-controller-template.js.map +0 -0
- /package/dist/{es2020 → esm}/utils/cli/utils/template-generators.js.map +0 -0
- /package/dist/{es2020 → esm}/utils/dotenv.helpers.js.map +0 -0
- /package/dist/{es2020 → esm}/utils/features/change-case.features.js.map +0 -0
- /package/dist/{es2020 → esm}/utils/helpers/api.features.helpers.js.map +0 -0
- /package/dist/{es2020 → esm}/utils/helpers/change-case.helpers.js.map +0 -0
- /package/dist/{es2020 → esm}/utils/helpers/deepmerge.helper.js.map +0 -0
- /package/dist/{es2020 → esm}/utils/helpers/query-parser.helpers.js.map +0 -0
- /package/dist/{es2020 → esm}/utils/helpers/text.helpers.js.map +0 -0
- /package/dist/{es2020 → esm}/utils/validate-dto.js.map +0 -0
- /package/dist/{es2020 → esm}/utils/validate-schema.js.map +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.getOpenAPIJsonSchemasByConfigMode=getOpenAPIJsonSchemasByConfigMode,exports.getCorrectJsonSchemaName=getCorrectJsonSchemaName,exports.kebabToHuman=kebabToHuman,exports.getSchemaRef=getSchemaRef,exports.generatePathsForModels=generatePathsForModels;const models_helpers_1=require("../../../../utils/helpers/models.helpers"),utils_1=require("../../../../exports/utils"),get_system_json_schema_paths_1=require("./get-system-json-schema-paths"),get_authentication_json_schema_paths_1=require("./get-authentication-json-schema-paths"),generate_zod_json_schema_1=require("./json-schema-generators/generate-zod-json-schema"),generate_class_validator_json_schemas_1=require("./json-schema-generators/generate-class-validator-json-schemas"),generate_prisma_json_schemas_1=require("./json-schema-generators/generate-prisma-json-schemas"),generate_prisma_model_main_routes_1=require("./json-schema-generators/prisma-models/generate-prisma-model-main-routes"),generate_prisma_model_parent_routes_1=require("./json-schema-generators/prisma-models/generate-prisma-model-parent-routes"),sheu_1=__importDefault(require("../../../../utils/sheu"));async function getOpenAPIJsonSchemasByConfigMode(e){switch(e?.swagger.mode){case"prisma":return await(0,generate_prisma_json_schemas_1.generatePrismaJsonSchemas)(e);case"class-validator":return await(0,generate_class_validator_json_schemas_1.generateClassValidatorJsonSchemas)();case"zod":return await(0,generate_zod_json_schema_1.generateZodJsonSchemas)();default:throw Error("Unknown mode for auto documentation, supported values are prisma, class-validator, zod or json-schemas")}}function getCorrectJsonSchemaName(e,t,s){const a=(0,utils_1.pascalCase)(t);return`${{model:a,create:`Create${a}`,createMany:`CreateMany${a}`,findOne:`FindOne${a}`,findMany:`FindMany${a}`,update:`Update${a}`,updateMany:`UpdateMany${a}`,query:`Query${a}`,login:"Login",signup:"Signup",updateMe:"UpdateMe",updatePassword:"UpdatePassword"}[e]??(0,utils_1.pascalCase)(e)}${s}`}function kebabToHuman(e){return e.split("-").map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}function getSchemaRef(e,t){const s=e.toLowerCase();if(["getme","updateme","login","signup","updatepassword","password","me"].some(o=>o===s)&&t==="prisma")return`#/components/schemas/${e}Schema`;switch(t){case"prisma":return`#/components/schemas/${e}ModelSchema`;case"zod":return`#/components/schemas/${e}Schema`;case"class-validator":return`#/components/schemas/${e}Dto`;default:return sheu_1.default.error(`Unknown Arkos.js swagger documentation provided, available options are prisma, zod or class-validator but received ${t}`),""}}async function generatePathsForModels(e){if(!e?.swagger)return{};let s={};const a=(0,models_helpers_1.getModels)();for(const r of a)await(0,generate_prisma_model_main_routes_1.generatePrismaModelMainRoutesPaths)(r,s,e),await(0,generate_prisma_model_parent_routes_1.generatePrismaModelParentRoutePaths)(r,s,e);return s={...s,...(0,get_system_json_schema_paths_1.getSystemJsonSchemaPaths)()},s={...s,...await(0,get_authentication_json_schema_paths_1.getAuthenticationJsonSchemaPaths)(e)||{}},s}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"swagger.router.helpers.js","sourceRoot":"","sources":["../../../../../../src/modules/swagger/utils/helpers/swagger.router.helpers.ts"],"names":[],"mappings":";;;;;AAgBA,8EAeC;AAED,4DAwBC;AAED,oCAKC;AAED,oCAqCC;AAED,wDA+BC;AAvID,6EAAqE;AACrE,qDAAuD;AAEvD,iFAA0E;AAC1E,iGAA0F;AAC1F,gGAA2F;AAC3F,0HAAmH;AACnH,wGAAkG;AAClG,gIAA8H;AAC9H,oIAAiI;AACjI,kEAA0C;AAKnC,KAAK,UAAU,iCAAiC,CACrD,WAAwB;IAExB,QAAQ,WAAW,EAAE,OAAQ,CAAC,IAAI,EAAE,CAAC;QACnC,KAAK,QAAQ;YACX,OAAO,MAAM,IAAA,wDAAyB,EAAC,WAAW,CAAC,CAAC;QACtD,KAAK,iBAAiB;YACpB,OAAO,MAAM,IAAA,yEAAiC,GAAE,CAAC;QACnD,KAAK,KAAK;YACR,OAAO,MAAM,IAAA,iDAAsB,GAAE,CAAC;QACxC;YACE,MAAM,KAAK,CACT,wGAAwG,CACzG,CAAC;IACN,CAAC;AACH,CAAC;AAED,SAAgB,wBAAwB,CACtC,IAAY,EACZ,SAAiB,EACjB,MAAwB;IAExB,MAAM,eAAe,GAAG,IAAA,kBAAU,EAAC,SAAS,CAAC,CAAC;IAE9C,MAAM,GAAG,GAA2B;QAClC,KAAK,EAAE,eAAe;QACtB,MAAM,EAAE,SAAS,eAAe,EAAE;QAClC,UAAU,EAAE,aAAa,eAAe,EAAE;QAC1C,OAAO,EAAE,UAAU,eAAe,EAAE;QACpC,QAAQ,EAAE,WAAW,eAAe,EAAE;QACtC,MAAM,EAAE,SAAS,eAAe,EAAE;QAClC,UAAU,EAAE,aAAa,eAAe,EAAE;QAC1C,KAAK,EAAE,QAAQ,eAAe,EAAE;QAChC,KAAK,EAAE,OAAO;QACd,MAAM,EA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IACd,CAAC;AACH,CAAC;AAEM,KAAK,UAAU,sBAAsB,CAC1C,WAAwB;IAExB,MAAM,aAAa,GAAG,WAAW,EAAE,OAAO,CAAC;IAE3C,IAAI,CAAC,aAAa;QAAE,OAAO,EAAE,CAAC;IAE9B,IAAI,KAAK,GAA0B,EAAE,CAAC;IACtC,MAAM,MAAM,GAAG,IAAA,0BAAS,GAAE,CAAC;IAE3B,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAE3B,MAAM,IAAA,sEAAkC,EAAC,KAAK,EAAE,KAAK,EAAE,WAAW,CAAC,CAAC;QAGpE,MAAM,IAAA,yEAAmC,EAAC,KAAK,EAAE,KAAK,EAAE,WAAW,CAAC,CAAC;IACvE,CAAC;IAGD,KAAK,GAAG;QACN,GAAG,KAAK;QACR,GAAG,IAAA,uDAAwB,GAAE;KAC9B,CAAC;IAGF,KAAK,GAAG;QACN,GAAG,KAAK;QACR,GAAG,CAAC,CAAC,MAAM,IAAA,uEAAgC,EAAC,WAAW,CAAC,CAAC,IAAI,EAAE,CAAC;KACjE,CAAC;IAEF,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["import { ArkosConfig } from \"../../../../exports\";\nimport { getModels } from \"../../../../utils/helpers/models.helpers\";\nimport { pascalCase } from \"../../../../exports/utils\";\nimport { OpenAPIV3 } from \"openapi-types\";\nimport { getSystemJsonSchemaPaths } from \"./get-system-json-schema-paths\";\nimport { getAuthenticationJsonSchemaPaths } from \"./get-authentication-json-schema-paths\";\nimport { generateZodJsonSchemas } from \"./json-schema-generators/generate-zod-json-schema\";\nimport { generateClassValidatorJsonSchemas } from \"./json-schema-generators/generate-class-validator-json-schemas\";\nimport { generatePrismaJsonSchemas } from \"./json-schema-generators/generate-prisma-json-schemas\";\nimport { generatePrismaModelMainRoutesPaths } from \"./json-schema-generators/prisma-models/generate-prisma-model-main-routes\";\nimport { generatePrismaModelParentRoutePaths } from \"./json-schema-generators/prisma-models/generate-prisma-model-parent-routes\";\nimport sheu from \"../../../../utils/sheu\";\n\n/**\n * Helps choosing the right json schemas according to swagger configurations\n */\nexport async function getOpenAPIJsonSchemasByConfigMode(\n arkosConfig: ArkosConfig\n) {\n switch (arkosConfig?.swagger!.mode) {\n case \"prisma\":\n return await generatePrismaJsonSchemas(arkosConfig);\n case \"class-validator\":\n return await generateClassValidatorJsonSchemas();\n case \"zod\":\n return await generateZodJsonSchemas();\n default:\n throw Error(\n \"Unknown mode for auto documentation, supported values are prisma, class-validator, zod or json-schemas\"\n );\n }\n}\n\nexport function getCorrectJsonSchemaName(\n type: string,\n modelName: string,\n suffix: \"Dto\" | \"Schema\"\n): string {\n const pascalModelName = pascalCase(modelName);\n\n const map: Record<string, string> = {\n model: pascalModelName,\n create: `Create${pascalModelName}`,\n createMany: `CreateMany${pascalModelName}`,\n findOne: `FindOne${pascalModelName}`,\n findMany: `FindMany${pascalModelName}`,\n update: `Update${pascalModelName}`,\n updateMany: `UpdateMany${pascalModelName}`,\n query: `Query${pascalModelName}`,\n login: \"Login\",\n signup: \"Signup\",\n updateMe: \"UpdateMe\",\n updatePassword: \"UpdatePassword\",\n };\n\n const baseName = map[type] ?? pascalCase(type);\n return `${baseName}${suffix}`;\n}\n\nexport function kebabToHuman(kebabStr: string): string {\n return kebabStr\n .split(\"-\")\n .map((word) => word.charAt(0).toUpperCase() + word.slice(1))\n .join(\" \");\n}\n\nexport function getSchemaRef(\n schemaName: string,\n mode: \"prisma\" | \"zod\" | \"class-validator\"\n): string {\n // Check if schemaName (lowercase) contains any of the specified keywords\n const lowerSchemaName = schemaName.toLowerCase();\n const specialCases = [\n \"getme\",\n \"updateme\",\n \"login\",\n \"signup\",\n \"updatepassword\",\n \"password\",\n \"me\",\n ];\n const isSpecialCase = specialCases.some(\n (keyword) => keyword === lowerSchemaName\n );\n\n // If it's a special case and mode is prisma, return zod style instead\n if (isSpecialCase && mode === \"prisma\") {\n return `#/components/schemas/${schemaName}Schema`;\n }\n\n switch (mode) {\n case \"prisma\":\n return `#/components/schemas/${schemaName}ModelSchema`;\n case \"zod\":\n return `#/components/schemas/${schemaName}Schema`;\n case \"class-validator\":\n return `#/components/schemas/${schemaName}Dto`;\n default:\n sheu.error(\n `Unknown Arkos.js swagger documentation provided, available options are prisma, zod or class-validator but received ${mode}`\n );\n return \"\";\n }\n}\n\nexport async function generatePathsForModels(\n arkosConfig: ArkosConfig\n): Promise<OpenAPIV3.PathsObject> {\n const swaggerConfig = arkosConfig?.swagger;\n\n if (!swaggerConfig) return {};\n\n let paths: OpenAPIV3.PathsObject = {};\n const models = getModels();\n\n for (const model of models) {\n // Generate main routes\n await generatePrismaModelMainRoutesPaths(model, paths, arkosConfig);\n\n // Generate parent routes if configured\n await generatePrismaModelParentRoutePaths(model, paths, arkosConfig);\n }\n\n // Add system routes\n paths = {\n ...paths,\n ...getSystemJsonSchemaPaths(),\n };\n\n // Add authentication routes\n paths = {\n ...paths,\n ...((await getAuthenticationJsonSchemaPaths(arkosConfig)) || {}),\n };\n\n return paths;\n}\n"]}
|
package/dist/cjs/server.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
"use strict";var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.server=void 0,exports.terminateApplicationRunningProcessAndServer=terminateApplicationRunningProcessAndServer,exports.getArkosConfig=getArkosConfig,exports.getExpressApp=getExpressApp,exports.initApp=initApp;const app_1=require("./app"),deepmerge_helper_1=__importDefault(require("./utils/helpers/deepmerge.helper")),http_1=__importDefault(require("http"));process.on("uncaughtException",e=>{
|
|
1
|
+
"use strict";var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.server=exports._arkosConfig=void 0,exports.terminateApplicationRunningProcessAndServer=terminateApplicationRunningProcessAndServer,exports.getArkosConfig=getArkosConfig,exports.getExpressApp=getExpressApp,exports.initApp=initApp;const app_1=require("./app"),deepmerge_helper_1=__importDefault(require("./utils/helpers/deepmerge.helper")),http_1=__importDefault(require("http")),models_helpers_1=require("./utils/helpers/models.helpers"),sheu_1=__importDefault(require("./utils/sheu")),text_helpers_1=require("./utils/helpers/text.helpers");process.on("uncaughtException",e=>{sheu_1.default.error(`
|
|
2
2
|
UNCAUGHT EXCEPTION! SHUTTING DOWN...
|
|
3
|
-
|
|
3
|
+
`,{timestamp:!0,bold:!0}),console.error(e.name,e.message),console.error(e),process.exit(1)});let server,_app;exports._arkosConfig={welcomeMessage:"Welcome to our RESTful API generated by Arkos, find out more about Arkos at www.arkosjs.com",port:Number(process.env.CLI_PORT)||Number(process.env.PORT)||8e3,host:process.env.CLI_HOST||process.env.HOST||"localhost",fileUpload:{baseUploadDir:"uploads",baseRoute:"/api/uploads"},available:!1};async function initApp(e={}){(0,models_helpers_1.initializePrismaModels)(),exports._arkosConfig.available=!0,exports._arkosConfig=(0,deepmerge_helper_1.default)(exports._arkosConfig,e);const r=process.env.CLI_PORT||exports._arkosConfig.port||process.env.PORT||"port"in exports._arkosConfig?exports._arkosConfig.port:8e3;_app=await(0,app_1.bootstrap)(exports._arkosConfig);const o=new Date().toTimeString().split(" ")[0];return r?(exports.server=server=http_1.default.createServer(_app),exports._arkosConfig?.configureServer&&await exports._arkosConfig.configureServer(server),server.listen(Number(r),exports._arkosConfig.host,()=>{sheu_1.default.ready(`${sheu_1.default.gray(o)} ${(0,text_helpers_1.capitalize)(process.env.NODE_ENV||"development")} server waiting on http://${exports._arkosConfig.host||"localhost"}:${r}`)})):sheu_1.default.warn(`${sheu_1.default.gray(o)} port set to undefined, hence no internal http server was setup.`),_app}process.on("unhandledRejection",e=>{sheu_1.default.error(`
|
|
4
|
+
UNHANDLED REJECTION! SHUTTING DOWN...
|
|
5
|
+
`,{timestamp:!0,bold:!0}),console.error(e.name,e.message),console.error(e),server?.close(()=>{process.exit(1)})});function terminateApplicationRunningProcessAndServer(){server?.close(()=>{process.exit(1)})}function getArkosConfig(){return exports._arkosConfig}function getExpressApp(){return _app}
|
package/dist/cjs/server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/server.ts"],"names":[],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/server.ts"],"names":[],"mappings":";;;;;;AAwGA,kGAIC;AAOD,wCAEC;AAED,sCAEC;AAEgB,0BAAO;AAxHxB,+BAAkC;AAElC,wFAAyD;AACzD,gDAAwB;AACxB,mEAAwE;AACxE,wDAAgC;AAChC,+DAA0D;AAE1D,OAAO,CAAC,EAAE,CAAC,mBAAmB,EAAE,CAAC,GAAG,EAAE,EAAE;IAGtC,cAAI,CAAC,KAAK,CAAC,0CAA0C,EAAE;QACrD,SAAS,EAAE,IAAI;QACf,IAAI,EAAE,IAAI;KACX,CAAC,CAAC;IACH,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;IACrC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACnB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC;AAEH,IAAI,MAA6D,CAAC;AAClE,IAAI,IAAa,CAAC;AAEP,QAAA,YAAY,GAA0C;IAC/D,cAAc,EACZ,6FAA6F;IAC/F,IAAI,EAAE,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,IAAI;IACtE,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,QAAQ,IAAI,OAAO,CAAC,GAAG,CAAC,IAAI,IAAI,WAAW;IAC7D,UAAU,EAAE;QACV,aAAa,EAAE,SAAS;QACxB,SAAS,EAAE,cAAc;KAC1B;IACD,SAAS,EAAE,KAAK;CACjB,CAAC;AAeF,KAAK,UAAU,OAAO,CAAC,cAA2B,EAAE;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EAAE,CAAC,oBAAoB,EAAE,CAAC,GAAa,EAAE,EAAE;IACjD,cAAI,CAAC,KAAK,CAAC,2CAA2C,EAAE;QACtD,SAAS,EAAE,IAAI;QACf,IAAI,EAAE,IAAI;KACX,CAAC,CAAC;IACH,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;IACrC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACnB,MAAM,EAAE,KAAK,CAAC,GAAG,EAAE;QACjB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAOH,SAAgB,2CAA2C;IACzD,MAAM,EAAE,KAAK,CAAC,GAAG,EAAE;QACjB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;AACL,CAAC;AAOD,SAAgB,cAAc;IAC5B,OAAO,oBAAY,CAAC;AACtB,CAAC;AAED,SAAgB,aAAa;IAC3B,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import { IncomingMessage, Server, ServerResponse } from \"http\";\nimport AppError from \"./modules/error-handler/utils/app-error\";\nimport { Express } from \"express\";\nimport { bootstrap } from \"./app\";\nimport { ArkosConfig } from \"./types/arkos-config\";\nimport deepmerge from \"./utils/helpers/deepmerge.helper\";\nimport http from \"http\";\nimport { initializePrismaModels } from \"./utils/helpers/models.helpers\";\nimport sheu from \"./utils/sheu\";\nimport { capitalize } from \"./utils/helpers/text.helpers\";\n\nprocess.on(\"uncaughtException\", (err) => {\n // if (err.message.includes(\"EPIPE\")) return;\n\n sheu.error(\"\\nUNCAUGHT EXCEPTION! SHUTTING DOWN...\\n\", {\n timestamp: true,\n bold: true,\n });\n console.error(err.name, err.message);\n console.error(err);\n process.exit(1);\n});\n\nlet server: Server<typeof IncomingMessage, typeof ServerResponse>;\nlet _app: Express;\n\nexport let _arkosConfig: ArkosConfig & { available?: boolean } = {\n welcomeMessage:\n \"Welcome to our RESTful API generated by Arkos, find out more about Arkos at www.arkosjs.com\",\n port: Number(process.env.CLI_PORT) || Number(process.env.PORT) || 8000,\n host: process.env.CLI_HOST || process.env.HOST || \"localhost\",\n fileUpload: {\n baseUploadDir: \"uploads\",\n baseRoute: \"/api/uploads\",\n },\n available: false,\n};\n\n/**\n * Initializes the application server.\n *\n * This function starts the server by listening on a specified port.\n * The port is determined by the following order of precedence:\n * 1. The `port` argument passed to the function.\n * 2. Defaults to `8000` if neither is provided.\n *\n * @param {ArkosConfig} arkosConfig - initial configs for the api ( authentication, port).\n * @returns {Promise<Express>} This function returns the Express App after all middlewares configurations.\n * You can prevent it from listen py passing port as undefined\n *\n */\nasync function initApp(arkosConfig: ArkosConfig = {}): Promise<Express> {\n initializePrismaModels();\n _arkosConfig.available = true;\n _arkosConfig = deepmerge(_arkosConfig, arkosConfig);\n\n const port =\n process.env.CLI_PORT ||\n _arkosConfig.port ||\n process.env.PORT ||\n \"port\" in _arkosConfig\n ? _arkosConfig.port\n : 8000;\n\n _app = await bootstrap(_arkosConfig);\n const time = new Date().toTimeString().split(\" \")[0];\n\n if (port) {\n server = http.createServer(_app);\n\n if (_arkosConfig?.configureServer)\n await _arkosConfig.configureServer(server);\n\n server.listen(Number(port), _arkosConfig.host!, () => {\n sheu.ready(\n `${sheu.gray(time)} ${capitalize(process.env.NODE_ENV || \"development\")} server waiting on http://${_arkosConfig.host || \"localhost\"}:${port}`\n );\n });\n } else {\n sheu.warn(\n `${sheu.gray(time)} port set to undefined, hence no internal http server was setup.`\n );\n }\n\n return _app;\n}\n\nprocess.on(\"unhandledRejection\", (err: AppError) => {\n sheu.error(\"\\nUNHANDLED REJECTION! SHUTTING DOWN...\\n\", {\n timestamp: true,\n bold: true,\n });\n console.error(err.name, err.message);\n console.error(err);\n server?.close(() => {\n process.exit(1);\n });\n});\n\n/**\n * Terminates the current running express application, server and process.\n *\n * @returns {void}\n */\nexport function terminateApplicationRunningProcessAndServer(): void {\n server?.close(() => {\n process.exit(1);\n });\n}\n\n/**\n * Gives access to the underlying current configurations being used by **Arkos** by default and also passed through `arkos.init()`\n *\n * @returns {ArkosConfig}\n */\nexport function getArkosConfig(): ArkosConfig {\n return _arkosConfig;\n}\n\nexport function getExpressApp() {\n return _app;\n}\n\nexport { server, initApp };\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"arkos-config.js","sourceRoot":"","sources":["../../../src/types/arkos-config.ts"],"names":[],"mappings":"","sourcesContent":["import http from \"http\";\nimport cors from \"cors\";\nimport express from \"express\";\nimport { Options as RateLimitOptions } from \"express-rate-limit\";\nimport cookieParser from \"cookie-parser\";\nimport compression from \"compression\";\nimport { Options as QueryParserOptions } from \"../utils/helpers/query-parser.helpers\";\nimport { ValidatorOptions } from \"class-validator\";\nimport { MsDuration } from \"../modules/auth/utils/helpers/auth.controller.helpers\";\n\n/**\n * Defines the initial configs of the api to be loaded at startup when arkos.init() is called.\n */\nexport type ArkosConfig = {\n /**\n * Allows to configure request configs\n */\n request?: {\n /**\n * Allows to configure request parameters\n */\n parameters?: {\n /**\n * Toggles allowing `VERY DANGEROUS` request paramateres under `req.query` for passing prisma query options.\n *\n * See more\n */\n allowDangerousPrismaQueryOptions?: boolean;\n };\n };\n /** Message you would like to send, as Json and 200 response when\n * ```curl\n * GET /api\n * ```\n *\n * ```json\n * { \"message\": \"Welcome to YourAppName\" }\n * ```\n *\n * default message is: Welcome to our Rest API generated by Arkos, find more about Arkos at www.arkosjs.com.\n *\n *\n * */\n welcomeMessage?: string;\n /**\n * Port where the application will run, can be set in 3 ways:\n *\n * 1. default is 8000\n * 2. PORT under environment variables (Lower precedence)\n * 3. this config option (Higher precedence)\n */\n port?: number | undefined;\n /**\n * Allows to listen on a different host than localhost only\n */\n host?: string;\n /**\n * Defines authentication related configurations, by default is undefined.\n *\n * See [www.arkosjs.com/docs/core-concepts/built-in-authentication-system](https://www.arkosjs.com/docs/core-concepts/built-in-authentication-system) for details.\n */\n authentication?: {\n /**\n * Defines whether to use Static or Dynamic Role-Based Acess Control\n *\n * Visit [www.arkosjs.com/docs/core-concepts/built-in-authentication-system](https://www.arkosjs.com/docs/core-concepts/built-in-authentication-system) for more details.\n */\n mode: \"static\" | \"dynamic\";\n /**\n * Defines auth login related configurations to customize the api.\n */\n login?: {\n /**\n * Defines the field that will be used as username by the built-in auth system, by default arkos will look for the field \"username\" in your model User, hence when making login for example you must send:\n *\n * ```json\n * {\n * \"username\": \"johndoe\",\n * \"password\": \"somePassword123\"\n * }\n * ```\n *\n * **Note:** You can also modify the usernameField on the fly by passing it to the request query parameters. example:\n *\n * ```curl\n * POST /api/auth/login?usernameField=email\n * ```\n *\n * See more at [www.arkosjs.com/docs/guide/authentication-system/sending-authentication-requests#example-changing-the-username-field](https://www.arkosjs.com/docs/guide/authentication-system/sending-authentication-requests#example-changing-the-username-field)\n *\n * By specifing here another field for username, for example passing \"email\", \"companyCode\" or something else your json will be like:\n *\n * **Example with email**\n *\n * ```json\n * {\n * \"email\": \"john.doe@example.com\",\n * \"password\": \"somePassword123\"\n * }\n * ```\n */\n allowedUsernames?: string[];\n /** Defines wether to send the access token in response after login or only send as cookie, defeault is both.*/\n sendAccessTokenThrough?: \"cookie-only\" | \"response-only\" | \"both\";\n };\n /**\n * Specifies the regex pattern used by the authentication system to enforce password strength requirements.\n *\n * **Important**: If using validation libraries like Zod or class-validator, this will be completely overwritten.\n *\n * **Default**: ```/^(?=.*[A-Z])(?=.*[a-z])(?=.*\\d).+$/``` - Ensures the password contains at least one uppercase letter, one lowercase letter, and one numeric digit.\n *\n * **message**: (Optional) A custom error message to display when the password does not meet the required strength criteria.\n */\n passwordValidation?: { regex: RegExp; message?: string };\n /**\n * Allows to specify the request rate limit for all authentication endpoints but `/api/users/me`.\n * \n * #### Default\n *{\n windowMs: 5000,\n limit: 10,\n standardHeaders: \"draft-7\",\n legacyHeaders: false,\n }\n * \n * Passing an object not overriding all the default options will only\n * cause it to be deepmerged and not actually replace with empty fields\n * \n *@see This is are the options used on the `express-rate-limit` npm package used on epxress. read more about [https://www.npmjs.com/package/express-rate-limit](https://www.npmjs.com/package/express-rate-limit)\n */\n requestRateLimitOptions?: Partial<RateLimitOptions>;\n /**\n * JWT (JSON Web Token) authentication configuration.\n *\n * You can override these values directly in code, or use environment variables:\n *\n * - `JWT_SECRET`: Secret used to sign and verify JWT tokens.\n * - `JWT_EXPIRES_IN`: Duration string or number indicating when the token should expire (e.g. \"30d\", 3600).\n * - `JWT_COOKIE_SECURE`: Whether the cookie is sent only over HTTPS. Default: `true` in production.\n * - `JWT_COOKIE_HTTP_ONLY`: Whether the cookie is HTTP-only. Default: `true`.\n * - `JWT_COOKIE_SAME_SITE`: Can be \"lax\", \"strict\", or \"none\". Defaults to \"lax\" in dev, \"none\" in prod.\n *\n * ⚠️ Values passed here take precedence over environment variables.\n */\n jwt?: {\n /** Secret key used for signing and verifying JWT tokens */\n secret?: string;\n /**\n * Duration after which the JWT token expires.\n * Accepts either a duration string (e.g. \"30d\", \"1h\") or a number in milliseconds.\n * Defaults to \"30d\" if not provided.\n */\n expiresIn?: MsDuration | number;\n\n /**\n * Configuration for the JWT cookie sent to the client\n */\n cookie?: {\n /**\n * Whether the cookie should be marked as secure (sent only over HTTPS).\n * Defaults to `true` in production and `false` in development.\n */\n secure?: boolean;\n\n /**\n * Whether the cookie should be marked as HTTP-only.\n * Default is `true` to prevent access via JavaScript.\n */\n httpOnly?: boolean;\n\n /**\n * Controls the SameSite attribute of the cookie.\n * Defaults to \"none\" in production and \"lax\" in development.\n * Options: \"lax\" | \"strict\" | \"none\"\n */\n sameSite?: \"lax\" | \"strict\" | \"none\";\n };\n };\n };\n /** Allows to customize and toggle the built-in validation, by default it is set to `false`. If true is passed it will use validation with the default resolver set to `class-validator` if you intend to change the resolver to `zod` do the following:\n *\n *```ts\n * // src/app.ts\n * import arkos from 'arkos'\n *\n * arkos.init({\n * validation: {\n * resolver: \"zod\"\n * }\n * })\n * ```\n *\n * @See [www.arkosjs.com/docs/core-concepts/request-data-validation](https://www.arkosjs.com/docs/core-concepts/request-data-validation) for more details.\n */\n validation?:\n | {\n resolver?: \"class-validator\";\n /**\n * ValidatorOptions to used while validating request data.\n *\n * **Default**:\n * ```ts\n * {\n * whitelist: true\n * }\n * ```\n */\n validationOptions?: ValidatorOptions;\n }\n | {\n resolver?: \"zod\";\n validationOptions?: Record<string, any>;\n };\n /**\n * Defines file upload configurations\n *\n * See [www.arkosjs.com/docs/core-concepts/file-upload#costum-configurations](https://www.arkosjs.com/docs/core-concepts/file-upload#costum-configurations)\n */\n fileUpload?: {\n /**\n * Defiens the base file upload directory, default is set to /uploads (on root directory)\n *\n * When setting up a path dir always now that root directory will be the starting reference.\n *\n * #### Example\n * passing `../my-arkos-uploaded-files`\n *\n * Will save uploaded files one level outside the root dir inside `my-arkos-uploaded-files`\n *\n * NB: You must be aware of permissions on your server to acess files outside your project directory.\n *\n */\n baseUploadDir?: string;\n /**\n * Changes the default `/api/uploads` base route for accessing file upload route.\n *\n * #### IMPORTANT\n * Changing this will not affect the `baseUploadDir` folder. You can\n * pass here `/api/files/my-user-files` and `baseUploadDir` be `/uploaded-files`.\n *\n */\n baseRoute?: string;\n /**\n * Defines options for `express.static(somePath, someOptions)`\n *\n * #### Default:\n *\n * ```ts\n *{\n maxAge: \"1y\",\n etag: true,\n lastModified: true,\n dotfiles: \"ignore\",\n fallthrough: true,\n index: false,\n cacheControl: true,\n }\n * ```\n * \n * By passing your custom options have in mind that it\n * will be deepmerged with the default.\n * \n * Visit [https://expressjs.com/en/4x/api.html#express.static](https://expressjs.com/en/4x/api.html#express.static) for more understanding.\n * \n */\n expressStaticOptions?: Parameters<typeof express.static>[1];\n /**\n * Defines upload restrictions for each file type: image, video, document or other.\n *\n * #### Important:\n * Passing an object without overriding everything will only cause it\n * to be deepmerged with the default options.\n *\n * See [www.arkosjs.com/docs/api-reference/default-supported-upload-files](https://www.arkosjs.com/docs/api-reference/default-supported-upload-files) for detailed explanation about default values.\n * ```\n */\n restrictions?: {\n images?: {\n maxCount?: number;\n maxSize?: number;\n supportedFilesRegex?: RegExp;\n };\n videos?: {\n maxCount?: number;\n maxSize?: number;\n supportedFilesRegex?: RegExp;\n };\n documents?: {\n maxCount?: number;\n maxSize?: number;\n supportedFilesRegex?: RegExp;\n };\n files?: {\n maxCount?: number;\n maxSize?: number;\n supportedFilesRegex?: RegExp;\n };\n };\n };\n /**\n * Allows to specify the request rate limit for all endpoints.\n * \n * #### Default\n *```ts\n *{\n windowMs: 60 * 1000,\n limit: 1000,\n standardHeaders: \"draft-7\",\n legacyHeaders: false,\n }\n ```\n * \n * Passing an object not overriding all the default options will only\n * cause it to be deepmerged and not actually replace with empty fields\n * \n * This is are the options used on the `express-rate-limit` npm package used on epxress. read more about [https://www.npmjs.com/package/express-rate-limit](https://www.npmjs.com/package/express-rate-limit)\n */\n globalRequestRateLimitOptions?: Partial<RateLimitOptions>;\n /**\n * Defines options for the built-in express.json() middleware\n * Nothing is passed by default.\n */\n jsonBodyParserOptions?: Parameters<typeof express.json>[0];\n /**\n * Allows to pass paremeters to cookieParser from npm package cookie-parser\n * Nothing is passed by default.\n *\n * See [www.npmjs.com/package/cookie-parser](https://www.npmjs.com/package/cookie-parser) for further details.\n */\n cookieParserParameters?: Parameters<typeof cookieParser>;\n /**\n * Allows to define options for npm package compression\n * Nothing is passed by default.\n *\n * See [www.npmjs.com/package/compression](https://www.npmjs.com/package/compression) for further details.\n */\n compressionOptions?: compression.CompressionOptions;\n /**\n * Options to define how query must be parsed.\n *\n * #### for example:\n * ```\n * GET /api/product?saleId=null\n * ```\n *\n * Normally would parsed to { saleId: \"null\" } so query parser\n * trough setting option `parseNull` will transform { saleId: null }\n * \n * #### Default:\n * \n * {\n parseNull: true,\n parseUndefined: true,\n parseBoolean: true,\n }\n * \n * parseNumber may convert fields that are string but you only passed\n * numbers to query pay attention to this.\n * \n * Soon a feature to converted the query to the end prisma type will be added.\n */\n queryParserOptions?: QueryParserOptions;\n /**\n * Configuration for CORS (Cross-Origin Resource Sharing).\n *\n * @property {string | string[] | \"all\"} [allowedOrigins] - List of allowed origins. If set to `\"all\"`, all origins are accepted.\n * @property {import('cors').CorsOptions} [options] - Additional CORS options passed directly to the `cors` middleware.\n * @property {import('cors').CorsOptionsDelegate} [customMiddleware] - A custom middleware function that overrides the default behavior.\n *\n * @remarks\n * If `customMiddleware` is provided, both `allowedOrigins` and `options` will be ignored in favor of the custom logic.\n *\n * See https://www.npmjs.com/package/cors\n */\n cors?: {\n /**\n * Defines allowed origins to acess the API.\n */\n allowedOrigins?: string | string[] | \"*\";\n options?: cors.CorsOptions;\n /**\n * If you would like to override the entire middleware\n *\n * see\n */\n customHandler?: cors.CorsOptionsDelegate;\n };\n /**\n * Defines express/arkos middlewares configurations\n */\n middlewares?: {\n /**\n * Allows to add an array of custom express middlewares into the default middleware stack.\n *\n * **Tip**: If you would like to acess the express app before everthing use `configureApp` and pass a function.\n *\n * **Where will these be placed?**: see [www.arkosjs.com/docs/advanced-guide/replace-or-disable-built-in-middlewares#middleware-execution-order](https://www.arkosjs.com/docs/advanced-guide/replace-or-disable-built-in-middlewares#middleware-execution-order)\n *\n * **Note**: If you want to use custom global error handler middleware use `middlewares.replace.globalErrorHandler`.\n *\n * Read more about The Arkos Middleware Stack at [www.arkosjs.com/docs/the-middleware-stack](https://www.arkosjs.com/docs/the-middleware-stack) for in-depth details.\n */\n additional?: express.RequestHandler[];\n /**\n * An array containing a list of defaults middlewares to be disabled\n *\n * **Caution**: Be careful with this because you may endup breaking your entire application.\n */\n disable?: (\n | \"compression\"\n | \"global-rate-limit\"\n | \"auth-rate-limit\"\n | \"cors\"\n | \"express-json\"\n | \"cookie-parser\"\n | \"query-parser\"\n | \"database-connection\"\n | \"request-logger\"\n | \"global-error-handler\"\n )[];\n /**\n * Allows you to replace each of the built-in middlewares with your own implementation\n *\n * **Caution**: Be careful with this because you may endup breaking your entire application.\n */\n replace?: {\n /**\n * Replace the default compression middleware\n */\n compression?: express.RequestHandler;\n /**\n * Replace the default global rate limit middleware\n */\n globalRateLimit?: express.RequestHandler;\n /**\n * Replace the default authentication rate limit middleware\n */\n authRateLimit?: express.RequestHandler;\n /**\n * Replace the default CORS middleware\n */\n cors?: express.RequestHandler;\n /**\n * Replace the default JSON body parser middleware\n */\n expressJson?: express.RequestHandler;\n /**\n * Replace the default cookie parser middleware\n */\n cookieParser?: express.RequestHandler;\n /**\n * Replace the default query parser middleware\n */\n queryParser?: express.RequestHandler;\n /**\n * Replace the default database connection check middleware\n */\n databaseConnection?: express.RequestHandler;\n /**\n * Replace the default request logger middleware\n */\n requestLogger?: express.RequestHandler;\n /**\n * Replace the default global error handler middleware\n */\n globalErrorHandler?: express.ErrorRequestHandler;\n };\n };\n /**\n * Defines express/arkos routers configurations\n */\n routers?: {\n /**\n * Allows to add an array of custom express routers into the default middleware/router stack.\n *\n * **Where will these be placed?**: see [www.arkosjs.com/docs/advanced-guide/adding-custom-routers](https://www.arkosjs.com/docs/advanced-guide/adding-custom-routers)\n *\n *\n * Read more about The Arkos Middleware Stack at [www.arkosjs.com/docs/the-middleware-stack](https://www.arkosjs.com/docs/the-middleware-stack) for in-depth details.\n */\n additional?: express.Router[];\n disable?: (\n | \"auth-router\"\n | \"prisma-models-router\"\n | \"file-upload\"\n | \"welcome-endpoint\"\n )[];\n /**\n * Allows you to replace each of the built-in routers with your own implementation.\n *\n * **Note**: Doing this you will lose all default middleware chaining, auth control, handlers from the specific router.\n *\n * **Tip**: I you want to disable some prisma models specific endpoint\n * see [www.arkosjs.com/docs/guide/adding-custom-routers#disabling-auto-generated-endpoints](https://www.arkosjs.com/docs/guide/adding-custom-routers#disabling-auto-generated-endpoints)\n *\n * **Caution**: Be careful with this because you may endup breaking your entire application.\n */\n replace?: {\n /**\n * Replace the default authentication router\n * @param config The original Arkos configuration\n * @returns A router handling authentication endpoints\n */\n authRouter?: (\n config: ArkosConfig\n ) => express.Router | Promise<express.Router>;\n /**\n * Replace the default Prisma models router\n * @param config The original Arkos configuration\n * @returns A router handling Prisma model endpoints\n */\n prismaModelsRouter?: (\n config: ArkosConfig\n ) => express.Router | Promise<express.Router>;\n /**\n * Replace the default file upload router\n * @param config The original Arkos configuration\n * @returns A router handling file upload endpoints\n */\n fileUpload?: (\n config: ArkosConfig\n ) => express.Router | Promise<express.Router>;\n /**\n * Replace the default welcome endpoint handler\n * @param req Express request object\n * @param res Express response object\n * @param next Express next function\n */\n welcomeEndpoint?: express.RequestHandler;\n };\n };\n /**\n * Gives acess to the underlying express app so that you can add custom configurations beyong **Arkos** customization capabilities\n *\n * **Note**: In the end **Arkos** will call `app.listen` for you.\n *\n * If you want to call `app.listen` by yourself pass port as `undefined` and then use the return app from `arkos.init()`.\n *\n * See how to call `app.listen` correctly [www.arkosjs.com/docs/guide/accessing-the-express-app#calling-applisten-by-yourself](https://www.arkosjs.com/docs/guide/accessing-the-express-app#calling-applisten-by-yourself)\n *\n * See [www.arkosjs.com/docs/guide/accessing-the-express-app](https://www.arkosjs.com/docs/guide/accessing-the-express-app) for further details on the method configureApp.\n *\n * @param {express.Express} app\n * @returns {any}\n */\n configureApp?: (app: express.Express) => Promise<any> | any;\n /**\n * Gives access to the underlying HTTP server so that you can add custom configurations beyond **Arkos** customization capabilities\n *\n * **Note**: In the end **Arkos** will call `server.listen` for you.\n *\n * If you want to call `server.listen` by yourself pass port as `undefined` and then use the return server from `arkos.init()`.\n *\n * See how to call `server.listen` correctly [www.arkosjs.com/docs/guide/accessing-the-express-app#creating-your-own-http-server](https://www.arkosjs.com/docs/guide/accessing-the-express-app#creating-your-own-http-server)\n *\n * See [www.arkosjs.com/docs/guide/accessing-the-express-app#accessing-the-http-server](https://www.arkosjs.com/docs/guide/accessing-the-express-app#accessing-the-http-server) for further details on the method configureServer.\n *\n * @param {http.Server} server - The HTTP server instance\n * @returns {any}\n */\n configureServer?: (server: http.Server) => Promise<any> | any;\n /**\n * Allows to configure email configurations for sending emails through `emailService`\n *\n * See [www.arkosjs.com/docs/core-concepts/sending-emails](https://www.arkosjs.com/docs/core-concepts/sending-emails)\n */\n email?: {\n /**\n * Your email provider url\n */\n host: string;\n /**\n * Email provider SMTP port, Default is `465`\n */\n port?: number;\n /**\n * If smtp connection must be secure, Default is `true`\n */\n secure?: boolean;\n /**\n * Used to authenticate in your smtp server\n */\n auth: {\n /**\n * Email used for auth as well as sending emails\n */\n user: string;\n /**\n * Your SMTP password\n */\n pass: string;\n };\n /**\n * Email name to used like:\n *\n * John Doe\\<john.doe@gmail.com>\n */\n name?: string;\n };\n /**\n * Defines Swagger and OpenApi specifications for auto generating swagger documentation UI using whether it is Prisma Schemas, Class-validator DTOs, Zod Schemas or JSON-Schemas\n *\n * **Usage**\n *\n * ```ts\n * // src/app.ts\n *\n * import arkos from \"arkos\"\n *\n * arkos.init({\n * // other configs\n * swagger: {\n * mode: \"zod\",\n * options: {\n * openapi: \"3.0.0\",\n * title: \"API Generated By Arkos.js\",\n * description: \"This API was automatically generated by Arkos.js read more about at www.arkosjs.com\"\n * }\n * }\n * })\n * ```\n *\n *\n * @see {@link https://www.arkosjs.com/docs/core-concepts/swagger-api-documentation}\n */\n swagger?: {\n /**\n * Endpoint where the Swagger UI will be available.\n *\n * @default \"/api/docs\"\n */\n endpoint?: string;\n /**\n * Determines how your API schemas should be generated.\n *\n * - \"prisma\": Generates schemas based on Prisma models\n * - \"class-validator\": Uses class-validator and class-transformer DTO classes\n * - \"zod`\": Uses OpenAPI-compliant schemas directly\n * - \"json-schema\": Uses OpenAPI-compliant schemas directly\n */\n mode: \"prisma\" | \"class-validator\" | \"zod\" | \"json-schema\";\n /**\n *\n */\n options: {\n /**\n * Swagger definition according to OpenAPI Specification.\n */\n definition: {\n /**\n * OpenAPI version.\n *\n * @default \"3.0.0\"\n */\n openapi?: string;\n\n /**\n * Information about your API.\n */\n info?: {\n /**\n * Title of the API documentation.\n *\n *\n * @example \"My API\"\n *\n * @default \"API Generated By Arkos.js\"\n */\n title?: string;\n\n /**\n * Version of the API.\n *\n * @example \"1.0.0\"\n */\n version?: string;\n\n /**\n * Description of the API.\n *\n * @default \"This API was automatically generated by Arkos.js read more about at www.arkosjs.com\"\n */\n description?: string;\n };\n\n /**\n * Server configurations for the API.\n *\n * @default [{ url: \"http://localhost:8000\", description: \"Local server\" }]\n *\n * This can be overridden automatically by Arkos based on CLI, .env, or `arkos.init()`.\n */\n servers?: {\n /**\n * Base URL of the server.\n *\n * @example \"http://localhost:8000\"\n */\n url: string;\n\n /**\n * Human-readable description of the server.\n *\n * @example \"Development Server\"\n */\n description: string;\n }[];\n\n /**\n * (Optional) Additional metadata such as terms of service, contact, or license.\n *\n * See: https://swagger.io/specification/#infoObject\n */\n termsOfService?: string;\n contact?: {\n name?: string;\n url?: string;\n email?: string;\n };\n license?: {\n name: string;\n url?: string;\n };\n\n /**\n * Tags to group and describe endpoints.\n */\n tags?: {\n name: string;\n description?: string;\n }[];\n\n /**\n * Security definitions (e.g., Bearer Auth).\n */\n components?: {\n securitySchemes?: Record<string, any>;\n schemas?: Record<string, any>;\n };\n\n /**\n * Global security requirements.\n */\n security?: Array<Record<string, string[]>>;\n };\n\n /**\n * Glob patterns defining where Swagger should look for API route definitions and comments.\n *\n * @default \n * ```ts\n * [\"./src/routers/*.router.{ts,js}\", \"./src/modules/**\\/*.router.{ts,js}\"]\n ```\n *\n * Adjust depending on TypeScript or JavaScript usage.\n */\n apis?: string[];\n\n /**\n * Custom Swagger UI options.\n *\n * See: https://github.com/swagger-api/swagger-ui/blob/master/docs/usage/configuration.md\n */\n swaggerUiOptions?: Record<string, any>;\n\n /**\n * Enables deep linking in the Swagger UI.\n *\n * @default true\n */\n deepLinking?: boolean;\n\n /**\n * Enable/disable the \"Try it out\" button globally.\n *\n * @default true\n */\n tryItOutEnabled?: boolean;\n\n /**\n * Whether to persist authorization data across page reloads.\n *\n * @default false\n */\n persistAuthorization?: boolean;\n };\n };\n};\n"]}
|
|
1
|
+
{"version":3,"file":"arkos-config.js","sourceRoot":"","sources":["../../../src/types/arkos-config.ts"],"names":[],"mappings":"","sourcesContent":["import http from \"http\";\nimport cors from \"cors\";\nimport express from \"express\";\nimport { Options as RateLimitOptions } from \"express-rate-limit\";\nimport cookieParser from \"cookie-parser\";\nimport compression from \"compression\";\nimport { Options as QueryParserOptions } from \"../utils/helpers/query-parser.helpers\";\nimport { ValidatorOptions } from \"class-validator\";\nimport { MsDuration } from \"../modules/auth/utils/helpers/auth.controller.helpers\";\nimport { OpenAPIV3 } from \"openapi-types\";\nimport type { ApiReferenceConfiguration } from \"@scalar/express-api-reference\" with { \"resolution-mode\": \"import\" };\n\n/**\n * Defines the initial configs of the api to be loaded at startup when arkos.init() is called.\n */\nexport type ArkosConfig = {\n /**\n * Allows to configure request configs\n */\n request?: {\n /**\n * Allows to configure request parameters\n */\n parameters?: {\n /**\n * Toggles allowing `VERY DANGEROUS` request paramateres under `req.query` for passing prisma query options.\n *\n * See more\n */\n allowDangerousPrismaQueryOptions?: boolean;\n };\n };\n /** Message you would like to send, as Json and 200 response when\n * ```curl\n * GET /api\n * ```\n *\n * ```json\n * { \"message\": \"Welcome to YourAppName\" }\n * ```\n *\n * default message is: Welcome to our Rest API generated by Arkos, find more about Arkos at www.arkosjs.com.\n *\n *\n * */\n welcomeMessage?: string;\n /**\n * Port where the application will run, can be set in 3 ways:\n *\n * 1. default is 8000\n * 2. PORT under environment variables (Lower precedence)\n * 3. this config option (Higher precedence)\n */\n port?: number | undefined;\n /**\n * Allows to listen on a different host than localhost only\n */\n host?: string;\n /**\n * Defines authentication related configurations, by default is undefined.\n *\n * See [www.arkosjs.com/docs/core-concepts/built-in-authentication-system](https://www.arkosjs.com/docs/core-concepts/built-in-authentication-system) for details.\n */\n authentication?: {\n /**\n * Defines whether to use Static or Dynamic Role-Based Acess Control\n *\n * Visit [www.arkosjs.com/docs/core-concepts/built-in-authentication-system](https://www.arkosjs.com/docs/core-concepts/built-in-authentication-system) for more details.\n */\n mode: \"static\" | \"dynamic\";\n /**\n * Defines auth login related configurations to customize the api.\n */\n login?: {\n /**\n * Defines the field that will be used as username by the built-in auth system, by default arkos will look for the field \"username\" in your model User, hence when making login for example you must send:\n *\n * ```json\n * {\n * \"username\": \"johndoe\",\n * \"password\": \"somePassword123\"\n * }\n * ```\n *\n * **Note:** You can also modify the usernameField on the fly by passing it to the request query parameters. example:\n *\n * ```curl\n * POST /api/auth/login?usernameField=email\n * ```\n *\n * See more at [www.arkosjs.com/docs/guide/authentication-system/sending-authentication-requests#example-changing-the-username-field](https://www.arkosjs.com/docs/guide/authentication-system/sending-authentication-requests#example-changing-the-username-field)\n *\n * By specifing here another field for username, for example passing \"email\", \"companyCode\" or something else your json will be like:\n *\n * **Example with email**\n *\n * ```json\n * {\n * \"email\": \"john.doe@example.com\",\n * \"password\": \"somePassword123\"\n * }\n * ```\n */\n allowedUsernames?: string[];\n /** Defines wether to send the access token in response after login or only send as cookie, defeault is both.*/\n sendAccessTokenThrough?: \"cookie-only\" | \"response-only\" | \"both\";\n };\n /**\n * Specifies the regex pattern used by the authentication system to enforce password strength requirements.\n *\n * **Important**: If using validation libraries like Zod or class-validator, this will be completely overwritten.\n *\n * **Default**: ```/^(?=.*[A-Z])(?=.*[a-z])(?=.*\\d).+$/``` - Ensures the password contains at least one uppercase letter, one lowercase letter, and one numeric digit.\n *\n * **message**: (Optional) A custom error message to display when the password does not meet the required strength criteria.\n */\n passwordValidation?: { regex: RegExp; message?: string };\n /**\n * Allows to specify the request rate limit for all authentication endpoints but `/api/users/me`.\n * \n * #### Default\n *{\n windowMs: 5000,\n limit: 10,\n standardHeaders: \"draft-7\",\n legacyHeaders: false,\n }\n * \n * Passing an object not overriding all the default options will only\n * cause it to be deepmerged and not actually replace with empty fields\n * \n *@see This is are the options used on the `express-rate-limit` npm package used on epxress. read more about [https://www.npmjs.com/package/express-rate-limit](https://www.npmjs.com/package/express-rate-limit)\n */\n requestRateLimitOptions?: Partial<RateLimitOptions>;\n /**\n * JWT (JSON Web Token) authentication configuration.\n *\n * You can override these values directly in code, or use environment variables:\n *\n * - `JWT_SECRET`: Secret used to sign and verify JWT tokens.\n * - `JWT_EXPIRES_IN`: Duration string or number indicating when the token should expire (e.g. \"30d\", 3600).\n * - `JWT_COOKIE_SECURE`: Whether the cookie is sent only over HTTPS. Default: `true` in production.\n * - `JWT_COOKIE_HTTP_ONLY`: Whether the cookie is HTTP-only. Default: `true`.\n * - `JWT_COOKIE_SAME_SITE`: Can be \"lax\", \"strict\", or \"none\". Defaults to \"lax\" in dev, \"none\" in prod.\n *\n * ⚠️ Values passed here take precedence over environment variables.\n */\n jwt?: {\n /** Secret key used for signing and verifying JWT tokens */\n secret?: string;\n /**\n * Duration after which the JWT token expires.\n * Accepts either a duration string (e.g. \"30d\", \"1h\") or a number in milliseconds.\n * Defaults to \"30d\" if not provided.\n */\n expiresIn?: MsDuration | number;\n\n /**\n * Configuration for the JWT cookie sent to the client\n */\n cookie?: {\n /**\n * Whether the cookie should be marked as secure (sent only over HTTPS).\n * Defaults to `true` in production and `false` in development.\n */\n secure?: boolean;\n\n /**\n * Whether the cookie should be marked as HTTP-only.\n * Default is `true` to prevent access via JavaScript.\n */\n httpOnly?: boolean;\n\n /**\n * Controls the SameSite attribute of the cookie.\n * Defaults to \"none\" in production and \"lax\" in development.\n * Options: \"lax\" | \"strict\" | \"none\"\n */\n sameSite?: \"lax\" | \"strict\" | \"none\";\n };\n };\n };\n /** Allows to customize and toggle the built-in validation, by default it is set to `false`. If true is passed it will use validation with the default resolver set to `class-validator` if you intend to change the resolver to `zod` do the following:\n *\n *```ts\n * // src/app.ts\n * import arkos from 'arkos'\n *\n * arkos.init({\n * validation: {\n * resolver: \"zod\"\n * }\n * })\n * ```\n *\n * @See [www.arkosjs.com/docs/core-concepts/request-data-validation](https://www.arkosjs.com/docs/core-concepts/request-data-validation) for more details.\n */\n validation?:\n | {\n resolver?: \"class-validator\";\n /**\n * ValidatorOptions to used while validating request data.\n *\n * **Default**:\n * ```ts\n * {\n * whitelist: true\n * }\n * ```\n */\n validationOptions?: ValidatorOptions;\n }\n | {\n resolver?: \"zod\";\n validationOptions?: Record<string, any>;\n };\n /**\n * Defines file upload configurations\n *\n * See [www.arkosjs.com/docs/core-concepts/file-upload#costum-configurations](https://www.arkosjs.com/docs/core-concepts/file-upload#costum-configurations)\n */\n fileUpload?: {\n /**\n * Defiens the base file upload directory, default is set to /uploads (on root directory)\n *\n * When setting up a path dir always now that root directory will be the starting reference.\n *\n * #### Example\n * passing `../my-arkos-uploaded-files`\n *\n * Will save uploaded files one level outside the root dir inside `my-arkos-uploaded-files`\n *\n * NB: You must be aware of permissions on your server to acess files outside your project directory.\n *\n */\n baseUploadDir?: string;\n /**\n * Changes the default `/api/uploads` base route for accessing file upload route.\n *\n * #### IMPORTANT\n * Changing this will not affect the `baseUploadDir` folder. You can\n * pass here `/api/files/my-user-files` and `baseUploadDir` be `/uploaded-files`.\n *\n */\n baseRoute?: string;\n /**\n * Defines options for `express.static(somePath, someOptions)`\n *\n * #### Default:\n *\n * ```ts\n *{\n maxAge: \"1y\",\n etag: true,\n lastModified: true,\n dotfiles: \"ignore\",\n fallthrough: true,\n index: false,\n cacheControl: true,\n }\n * ```\n * \n * By passing your custom options have in mind that it\n * will be deepmerged with the default.\n * \n * Visit [https://expressjs.com/en/4x/api.html#express.static](https://expressjs.com/en/4x/api.html#express.static) for more understanding.\n * \n */\n expressStaticOptions?: Parameters<typeof express.static>[1];\n /**\n * Defines upload restrictions for each file type: image, video, document or other.\n *\n * #### Important:\n * Passing an object without overriding everything will only cause it\n * to be deepmerged with the default options.\n *\n * See [www.arkosjs.com/docs/api-reference/default-supported-upload-files](https://www.arkosjs.com/docs/api-reference/default-supported-upload-files) for detailed explanation about default values.\n * ```\n */\n restrictions?: {\n images?: {\n maxCount?: number;\n maxSize?: number;\n supportedFilesRegex?: RegExp;\n };\n videos?: {\n maxCount?: number;\n maxSize?: number;\n supportedFilesRegex?: RegExp;\n };\n documents?: {\n maxCount?: number;\n maxSize?: number;\n supportedFilesRegex?: RegExp;\n };\n files?: {\n maxCount?: number;\n maxSize?: number;\n supportedFilesRegex?: RegExp;\n };\n };\n };\n /**\n * Allows to specify the request rate limit for all endpoints.\n * \n * #### Default\n *```ts\n *{\n windowMs: 60 * 1000,\n limit: 1000,\n standardHeaders: \"draft-7\",\n legacyHeaders: false,\n }\n ```\n * \n * Passing an object not overriding all the default options will only\n * cause it to be deepmerged and not actually replace with empty fields\n * \n * This is are the options used on the `express-rate-limit` npm package used on epxress. read more about [https://www.npmjs.com/package/express-rate-limit](https://www.npmjs.com/package/express-rate-limit)\n */\n globalRequestRateLimitOptions?: Partial<RateLimitOptions>;\n /**\n * Defines options for the built-in express.json() middleware\n * Nothing is passed by default.\n */\n jsonBodyParserOptions?: Parameters<typeof express.json>[0];\n /**\n * Allows to pass paremeters to cookieParser from npm package cookie-parser\n * Nothing is passed by default.\n *\n * See [www.npmjs.com/package/cookie-parser](https://www.npmjs.com/package/cookie-parser) for further details.\n */\n cookieParserParameters?: Parameters<typeof cookieParser>;\n /**\n * Allows to define options for npm package compression\n * Nothing is passed by default.\n *\n * See [www.npmjs.com/package/compression](https://www.npmjs.com/package/compression) for further details.\n */\n compressionOptions?: compression.CompressionOptions;\n /**\n * Options to define how query must be parsed.\n *\n * #### for example:\n * ```\n * GET /api/product?saleId=null\n * ```\n *\n * Normally would parsed to { saleId: \"null\" } so query parser\n * trough setting option `parseNull` will transform { saleId: null }\n * \n * #### Default:\n * \n * {\n parseNull: true,\n parseUndefined: true,\n parseBoolean: true,\n }\n * \n * parseNumber may convert fields that are string but you only passed\n * numbers to query pay attention to this.\n * \n * Soon a feature to converted the query to the end prisma type will be added.\n */\n queryParserOptions?: QueryParserOptions;\n /**\n * Configuration for CORS (Cross-Origin Resource Sharing).\n *\n * @property {string | string[] | \"all\"} [allowedOrigins] - List of allowed origins. If set to `\"all\"`, all origins are accepted.\n * @property {import('cors').CorsOptions} [options] - Additional CORS options passed directly to the `cors` middleware.\n * @property {import('cors').CorsOptionsDelegate} [customMiddleware] - A custom middleware function that overrides the default behavior.\n *\n * @remarks\n * If `customMiddleware` is provided, both `allowedOrigins` and `options` will be ignored in favor of the custom logic.\n *\n * See https://www.npmjs.com/package/cors\n */\n cors?: {\n /**\n * Defines allowed origins to acess the API.\n */\n allowedOrigins?: string | string[] | \"*\";\n options?: cors.CorsOptions;\n /**\n * If you would like to override the entire middleware\n *\n * see\n */\n customHandler?: cors.CorsOptionsDelegate;\n };\n /**\n * Defines express/arkos middlewares configurations\n */\n middlewares?: {\n /**\n * Allows to add an array of custom express middlewares into the default middleware stack.\n *\n * **Tip**: If you would like to acess the express app before everthing use `configureApp` and pass a function.\n *\n * **Where will these be placed?**: see [www.arkosjs.com/docs/advanced-guide/replace-or-disable-built-in-middlewares#middleware-execution-order](https://www.arkosjs.com/docs/advanced-guide/replace-or-disable-built-in-middlewares#middleware-execution-order)\n *\n * **Note**: If you want to use custom global error handler middleware use `middlewares.replace.globalErrorHandler`.\n *\n * Read more about The Arkos Middleware Stack at [www.arkosjs.com/docs/the-middleware-stack](https://www.arkosjs.com/docs/the-middleware-stack) for in-depth details.\n */\n additional?: express.RequestHandler[];\n /**\n * An array containing a list of defaults middlewares to be disabled\n *\n * **Caution**: Be careful with this because you may endup breaking your entire application.\n */\n disable?: (\n | \"compression\"\n | \"global-rate-limit\"\n | \"auth-rate-limit\"\n | \"cors\"\n | \"express-json\"\n | \"cookie-parser\"\n | \"query-parser\"\n | \"database-connection\"\n | \"request-logger\"\n | \"global-error-handler\"\n )[];\n /**\n * Allows you to replace each of the built-in middlewares with your own implementation\n *\n * **Caution**: Be careful with this because you may endup breaking your entire application.\n */\n replace?: {\n /**\n * Replace the default compression middleware\n */\n compression?: express.RequestHandler;\n /**\n * Replace the default global rate limit middleware\n */\n globalRateLimit?: express.RequestHandler;\n /**\n * Replace the default authentication rate limit middleware\n */\n authRateLimit?: express.RequestHandler;\n /**\n * Replace the default CORS middleware\n */\n cors?: express.RequestHandler;\n /**\n * Replace the default JSON body parser middleware\n */\n expressJson?: express.RequestHandler;\n /**\n * Replace the default cookie parser middleware\n */\n cookieParser?: express.RequestHandler;\n /**\n * Replace the default query parser middleware\n */\n queryParser?: express.RequestHandler;\n /**\n * Replace the default database connection check middleware\n */\n databaseConnection?: express.RequestHandler;\n /**\n * Replace the default request logger middleware\n */\n requestLogger?: express.RequestHandler;\n /**\n * Replace the default global error handler middleware\n */\n globalErrorHandler?: express.ErrorRequestHandler;\n };\n };\n /**\n * Defines express/arkos routers configurations\n */\n routers?: {\n /**\n * Allows to add an array of custom express routers into the default middleware/router stack.\n *\n * **Where will these be placed?**: see [www.arkosjs.com/docs/advanced-guide/adding-custom-routers](https://www.arkosjs.com/docs/advanced-guide/adding-custom-routers)\n *\n *\n * Read more about The Arkos Middleware Stack at [www.arkosjs.com/docs/the-middleware-stack](https://www.arkosjs.com/docs/the-middleware-stack) for in-depth details.\n */\n additional?: express.Router[];\n disable?: (\n | \"auth-router\"\n | \"prisma-models-router\"\n | \"file-upload\"\n | \"welcome-endpoint\"\n )[];\n /**\n * Allows you to replace each of the built-in routers with your own implementation.\n *\n * **Note**: Doing this you will lose all default middleware chaining, auth control, handlers from the specific router.\n *\n * **Tip**: I you want to disable some prisma models specific endpoint\n * see [www.arkosjs.com/docs/guide/adding-custom-routers#disabling-auto-generated-endpoints](https://www.arkosjs.com/docs/guide/adding-custom-routers#disabling-auto-generated-endpoints)\n *\n * **Caution**: Be careful with this because you may endup breaking your entire application.\n */\n replace?: {\n /**\n * Replace the default authentication router\n * @param config The original Arkos configuration\n * @returns A router handling authentication endpoints\n */\n authRouter?: (\n config: ArkosConfig\n ) => express.Router | Promise<express.Router>;\n /**\n * Replace the default Prisma models router\n * @param config The original Arkos configuration\n * @returns A router handling Prisma model endpoints\n */\n prismaModelsRouter?: (\n config: ArkosConfig\n ) => express.Router | Promise<express.Router>;\n /**\n * Replace the default file upload router\n * @param config The original Arkos configuration\n * @returns A router handling file upload endpoints\n */\n fileUpload?: (\n config: ArkosConfig\n ) => express.Router | Promise<express.Router>;\n /**\n * Replace the default welcome endpoint handler\n * @param req Express request object\n * @param res Express response object\n * @param next Express next function\n */\n welcomeEndpoint?: express.RequestHandler;\n };\n };\n /**\n * Gives acess to the underlying express app so that you can add custom configurations beyong **Arkos** customization capabilities\n *\n * **Note**: In the end **Arkos** will call `app.listen` for you.\n *\n * If you want to call `app.listen` by yourself pass port as `undefined` and then use the return app from `arkos.init()`.\n *\n * See how to call `app.listen` correctly [www.arkosjs.com/docs/guide/accessing-the-express-app#calling-applisten-by-yourself](https://www.arkosjs.com/docs/guide/accessing-the-express-app#calling-applisten-by-yourself)\n *\n * See [www.arkosjs.com/docs/guide/accessing-the-express-app](https://www.arkosjs.com/docs/guide/accessing-the-express-app) for further details on the method configureApp.\n *\n * @param {express.Express} app\n * @returns {any}\n */\n configureApp?: (app: express.Express) => Promise<any> | any;\n /**\n * Gives access to the underlying HTTP server so that you can add custom configurations beyond **Arkos** customization capabilities\n *\n * **Note**: In the end **Arkos** will call `server.listen` for you.\n *\n * If you want to call `server.listen` by yourself pass port as `undefined` and then use the return server from `arkos.init()`.\n *\n * See how to call `server.listen` correctly [www.arkosjs.com/docs/guide/accessing-the-express-app#creating-your-own-http-server](https://www.arkosjs.com/docs/guide/accessing-the-express-app#creating-your-own-http-server)\n *\n * See [www.arkosjs.com/docs/guide/accessing-the-express-app#accessing-the-http-server](https://www.arkosjs.com/docs/guide/accessing-the-express-app#accessing-the-http-server) for further details on the method configureServer.\n *\n * @param {http.Server} server - The HTTP server instance\n * @returns {any}\n */\n configureServer?: (server: http.Server) => Promise<any> | any;\n /**\n * Allows to configure email configurations for sending emails through `emailService`\n *\n * See [www.arkosjs.com/docs/core-concepts/sending-emails](https://www.arkosjs.com/docs/core-concepts/sending-emails)\n */\n email?: {\n /**\n * Your email provider url\n */\n host: string;\n /**\n * Email provider SMTP port, Default is `465`\n */\n port?: number;\n /**\n * If smtp connection must be secure, Default is `true`\n */\n secure?: boolean;\n /**\n * Used to authenticate in your smtp server\n */\n auth: {\n /**\n * Email used for auth as well as sending emails\n */\n user: string;\n /**\n * Your SMTP password\n */\n pass: string;\n };\n /**\n * Email name to used like:\n *\n * John Doe\\<john.doe@gmail.com>\n */\n name?: string;\n };\n /**\n * Defines Swagger and OpenApi specifications for auto generating swagger documentation UI using whether it is Prisma Schemas, Class-validator DTOs, Zod Schemas or JSON-Schemas.\n *\n * **Important**: Is worth mentioning that this works alongside `@scalar/express-api-reference` npm package, you define it's ApiReferenceConfiguration under ``. also consider checking the package documentation at []\n *\n * **Usage**\n *\n * ```ts\n * // src/app.ts\n *\n * import arkos from \"arkos\"\n *\n * arkos.init({\n * // other configs\n * swagger: {\n * mode: \"zod\",\n * options: {\n * defintion: {\n * info: {\n * openapi: \"3.0.0\",\n * title: \"API Generated By Arkos.js\",\n * description: \"This API was automatically generated by Arkos.js read more about at www.arkosjs.com\"\n * }\n * }\n * }\n * }\n * })\n * ```\n * @see {@link https://www.arkosjs.com/docs/core-concepts/swagger-api-documentation}\n */\n swagger?: {\n /**\n * By default Arkos will disable API Documentation when the project is built `npm run build`, it does not matter what node environment is set. If you want to use it even after the `arkos build` command just set this to `true`.\n * */\n enableAfterBuild?: boolean;\n /**\n * Endpoint where the Swagger UI will be available.\n *\n * @default \"/api/api-docs\"\n */\n endpoint?: string;\n /**\n * Determines how your API schemas should be generated.\n *\n * - \"prisma\": Generates schemas based on Prisma models\n * - \"class-validator\": Uses class-validator and class-transformer DTO classes\n * - \"zod\": Uses OpenAPI-compliant schemas directly\n */\n mode: \"prisma\" | \"class-validator\" | \"zod\";\n /**\n * Allows `Arkos.js` to fallback to prisma schema and use them as json schema for defining request body and response data\n * when a given zod Schema or class-validator Class is not found to be transformed to json schema.\n *\n * @default false\n */\n strict: boolean;\n /**\n * Defines your swagger configurations\n */\n options?: {\n /**\n * Swagger definition according to OpenAPI Specification.\n */\n definition?: {\n /**\n * OpenAPI version.\n *\n * @default \"3.0.0\"\n */\n openapi?: string;\n\n /**\n * Information about your API.\n */\n info?: {\n /**\n * Title of the API documentation.\n *\n *\n * @example \"My API\"\n *\n * @default \"API Generated By Arkos.js\"\n */\n title?: string;\n\n /**\n * Version of the API.\n *\n * @example \"1.0.0\"\n */\n version?: string;\n\n /**\n * Description of the API.\n *\n * @default \"This API was automatically generated by Arkos.js read more about at www.arkosjs.com\"\n */\n description?: string;\n };\n\n /**\n * Server configurations for the API.\n *\n * @default [{ url: \"http://localhost:8000\", description: \"Development server\" }]\n *\n * This can be overridden automatically by Arkos based on CLI, .env, or `arkos.init()`.\n */\n servers?: {\n /**\n * Base URL of the server.\n *\n * @example \"http://localhost:8000\"\n */\n url: string;\n\n /**\n * Human-readable description of the server.\n *\n * @example \"Development Server\"\n */\n description?: string;\n }[];\n /**\n * Allows adding more paths for your OpenAPI documentation\n *\n * */\n paths?: OpenAPIV3.PathsObject;\n /**\n * (Optional) Additional metadata such as terms of service, contact, or license.\n *\n * See: https://swagger.io/specification/#infoObject\n */\n termsOfService?: string;\n contact?: {\n name?: string;\n url?: string;\n email?: string;\n };\n license?: {\n name: string;\n url?: string;\n };\n\n /**\n * Tags to group and describe endpoints.\n */\n tags?: {\n name: string;\n description?: string;\n }[];\n\n /**\n * Security definitions (e.g., Bearer Auth).\n */\n components?: {\n securitySchemes?: Record<string, any>;\n schemas?: Record<string, any>;\n };\n\n /**\n * Global security requirements.\n */\n security?: Array<Record<string, string[]>>;\n };\n\n /**\n * Glob patterns defining where Swagger should look for API route definitions and comments.\n *\n * @default \n * ```ts\n * [\"./src/routers/*.router.{ts,js}\", \"./src/modules/**\\/*.router.{ts,js}\"]\n ```\n *\n * Adjust depending on TypeScript or JavaScript usage.\n */\n apis?: string[];\n\n /**\n * Enables deep linking in the Swagger UI.\n *\n * @default true\n */\n deepLinking?: boolean;\n\n /**\n * Enable/disable the \"Try it out\" button globally.\n *\n * @default true\n */\n tryItOutEnabled?: boolean;\n\n /**\n * Whether to persist authorization data across page reloads.\n *\n * @default false\n */\n persistAuthorization?: boolean;\n };\n /**\n * Custom `@scalar/express-api-reference` package options.\n *\n * @see {@link https://guides.scalar.com/scalar/scalar-api-references/integrations/express}\n */\n scalarApiReferenceConfiguration?: Partial<ApiReferenceConfiguration>;\n };\n};\n"]}
|
package/dist/cjs/types/auth.js
CHANGED
package/dist/cjs/types/index.js
CHANGED
|
@@ -1,11 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AuthPermissionAction = void 0;
|
|
4
|
-
var AuthPermissionAction;
|
|
5
|
-
(function (AuthPermissionAction) {
|
|
6
|
-
AuthPermissionAction["Create"] = "Create";
|
|
7
|
-
AuthPermissionAction["View"] = "View";
|
|
8
|
-
AuthPermissionAction["Update"] = "Update";
|
|
9
|
-
AuthPermissionAction["Delete"] = "Delete";
|
|
10
|
-
})(AuthPermissionAction || (exports.AuthPermissionAction = AuthPermissionAction = {}));
|
|
11
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.AuthPermissionAction=void 0;var AuthPermissionAction;(function(e){e.Create="Create",e.View="View",e.Update="Update",e.Delete="Delete"})(AuthPermissionAction||(exports.AuthPermissionAction=AuthPermissionAction={}));
|
|
@@ -1,9 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const arkosEnv = {
|
|
4
|
-
JWT_SECRET: "13a9279eedb286f756212511267152e9585055809ec0606ea9f7eb98a87660c1616fbd39c44d4238a82f29df90b529e24bfdf72a480d1149d79c991c863a22b5ae0fb3ae6f5323bfd6664faef99792637477c38da488e7aa0d39b83ba99aba8e8a20efde7fd5c7ba21a6c938e17a9f99f73226dc61e89cd63f159257841194323f100d1a49b88ce4fdcdf2b066a5f32f88ee12f6487b55b4b5687d7c0caffdd8524e2adc4b941cf52e948f5b330f527eb1354341c876eed12dfa92cef3c341d030d05e6beb1e0a7f6d3e08e7b1aac045130457fd3a53ee469fecdd20fdd2c7a6a72b07cbcb1157c5b1cc581e6767bea32be8e125016a48951e85c7bdb961d9c9fab28444499ce063664fe0bd1a05d60294323bdd69af6d6ff1a2533dac8d4a869f76dbc746ee12f144e0af41029f620471817843140c23d036e731f3ebee21a70ff1549e97486fdf9cbef132ff2ced59fde9be35dd04b358c9a25ec4fd9cc0e36dae651e626d8c13b0c6d2a21f237517a05059680173e71817597062c792ea9c66030ca0d8ed82987e29189947692a0be5fffac4c988ca33f14ce96349661ef850dbff6909c7797676c90a5e47655346f59759482ef8a3a948e97e30f889bd4571610fd19e8ea4818651d37f6529cf32f0fc805bc053e911f0fe96f52b4420d54bd1f40739a95f5853b036c86ab9a51bed57fa9bd48607b5302e88db00900adf",
|
|
5
|
-
JWT_EXPIRES_IN: "30d",
|
|
6
|
-
PRISMA_SCHEMA_PATH: `./prisma/schema`,
|
|
7
|
-
};
|
|
8
|
-
exports.default = arkosEnv;
|
|
9
|
-
//# sourceMappingURL=arkos-env.js.map
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const arkosEnv={JWT_SECRET:"13a9279eedb286f756212511267152e9585055809ec0606ea9f7eb98a87660c1616fbd39c44d4238a82f29df90b529e24bfdf72a480d1149d79c991c863a22b5ae0fb3ae6f5323bfd6664faef99792637477c38da488e7aa0d39b83ba99aba8e8a20efde7fd5c7ba21a6c938e17a9f99f73226dc61e89cd63f159257841194323f100d1a49b88ce4fdcdf2b066a5f32f88ee12f6487b55b4b5687d7c0caffdd8524e2adc4b941cf52e948f5b330f527eb1354341c876eed12dfa92cef3c341d030d05e6beb1e0a7f6d3e08e7b1aac045130457fd3a53ee469fecdd20fdd2c7a6a72b07cbcb1157c5b1cc581e6767bea32be8e125016a48951e85c7bdb961d9c9fab28444499ce063664fe0bd1a05d60294323bdd69af6d6ff1a2533dac8d4a869f76dbc746ee12f144e0af41029f620471817843140c23d036e731f3ebee21a70ff1549e97486fdf9cbef132ff2ced59fde9be35dd04b358c9a25ec4fd9cc0e36dae651e626d8c13b0c6d2a21f237517a05059680173e71817597062c792ea9c66030ca0d8ed82987e29189947692a0be5fffac4c988ca33f14ce96349661ef850dbff6909c7797676c90a5e47655346f59759482ef8a3a948e97e30f889bd4571610fd19e8ea4818651d37f6529cf32f0fc805bc053e911f0fe96f52b4420d54bd1f40739a95f5853b036c86ab9a51bed57fa9bd48607b5302e88db00900adf",JWT_EXPIRES_IN:"30d",PRISMA_SCHEMA_PATH:"./prisma/schema"};exports.default=arkosEnv;
|
|
@@ -1,229 +1,6 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const path_1 = __importDefault(require("path"));
|
|
8
|
-
const fs_1 = __importDefault(require("fs"));
|
|
9
|
-
const child_process_1 = require("child_process");
|
|
10
|
-
const fs_helpers_1 = require("../helpers/fs.helpers");
|
|
11
|
-
const dotenv_helpers_1 = require("../dotenv.helpers");
|
|
12
|
-
const cli_helpers_1 = require("./utils/cli.helpers");
|
|
13
|
-
const BUILD_DIR = ".build";
|
|
14
|
-
const MODULE_TYPES = ["cjs", "esm"];
|
|
15
|
-
function detectPackageManagerFromUserAgent() {
|
|
16
|
-
const userAgent = process.env.npm_config_user_agent || "";
|
|
17
|
-
if (userAgent.includes("pnpm"))
|
|
18
|
-
return "pnpm";
|
|
19
|
-
if (userAgent.includes("yarn"))
|
|
20
|
-
return "yarn";
|
|
21
|
-
if (userAgent.includes("npm"))
|
|
22
|
-
return "npm";
|
|
23
|
-
if (userAgent.includes("bun"))
|
|
24
|
-
return "bun";
|
|
25
|
-
if (userAgent.includes("cnpm"))
|
|
26
|
-
return "cnpm";
|
|
27
|
-
if (userAgent.includes("corepack"))
|
|
28
|
-
return "corepack";
|
|
29
|
-
if (userAgent.includes("deno"))
|
|
30
|
-
return "deno";
|
|
31
|
-
return "npm";
|
|
32
|
-
}
|
|
33
|
-
function buildCommand(options = {}) {
|
|
34
|
-
const fileExt = (0, fs_helpers_1.getUserFileExtension)();
|
|
35
|
-
process.env.NODE_ENV = "production";
|
|
36
|
-
process.env.NODE_ENV = "true";
|
|
37
|
-
const envFiles = (0, dotenv_helpers_1.loadEnvironmentVariables)();
|
|
38
|
-
const moduleType = validateModuleType(options.module);
|
|
39
|
-
try {
|
|
40
|
-
console.info(` \x1b[1m\x1b[36m Arkos.js ${(0, cli_helpers_1.getVersion)()}\x1b[0m`);
|
|
41
|
-
console.info(` - Environments: ${(0, fs_helpers_1.fullCleanCwd)(envFiles?.join(", ") || "")
|
|
42
|
-
.replaceAll(`${process.cwd()}/`, "")
|
|
43
|
-
.replaceAll("/", "")}`);
|
|
44
|
-
console.info(`\n Creating an optimized production build...`);
|
|
45
|
-
ensureBuildDir();
|
|
46
|
-
if (fileExt === "ts") {
|
|
47
|
-
buildTypeScriptProject(options, moduleType);
|
|
48
|
-
}
|
|
49
|
-
else {
|
|
50
|
-
buildJavaScriptProject(options, moduleType);
|
|
51
|
-
}
|
|
52
|
-
const packageManger = detectPackageManagerFromUserAgent();
|
|
53
|
-
console.info(`\n\x1b[1m\x1b[32m Build complete!\x1b[0m\n`);
|
|
54
|
-
console.info(` \x1b[1mNext step:\x1b[0m`);
|
|
55
|
-
console.info(` Run it using \x1b[1m\x1b[36m${packageManger} run start\x1b[0m\n`);
|
|
56
|
-
}
|
|
57
|
-
catch (error) {
|
|
58
|
-
console.info("\n");
|
|
59
|
-
console.error("❌ Build failed:", error);
|
|
60
|
-
process.exit(1);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
function validateModuleType(moduleType) {
|
|
64
|
-
if (!moduleType)
|
|
65
|
-
return "cjs";
|
|
66
|
-
const normalizedType = moduleType.toLowerCase();
|
|
67
|
-
if (normalizedType === "cjs" || normalizedType === "commonjs") {
|
|
68
|
-
return "cjs";
|
|
69
|
-
}
|
|
70
|
-
else if (["esm", "es", "es2020", "esnext", "module"].includes(normalizedType)) {
|
|
71
|
-
return "esm";
|
|
72
|
-
}
|
|
73
|
-
console.warn(`⚠️ Unrecognized module type "${moduleType}", defaulting to "cjs"`);
|
|
74
|
-
return "cjs";
|
|
75
|
-
}
|
|
76
|
-
function ensureBuildDir() {
|
|
77
|
-
if (!fs_1.default.existsSync(BUILD_DIR)) {
|
|
78
|
-
fs_1.default.mkdirSync(BUILD_DIR, { recursive: true });
|
|
79
|
-
}
|
|
80
|
-
for (const moduleType of MODULE_TYPES) {
|
|
81
|
-
const moduleDir = path_1.default.join(BUILD_DIR, moduleType);
|
|
82
|
-
if (!fs_1.default.existsSync(moduleDir)) {
|
|
83
|
-
fs_1.default.mkdirSync(moduleDir, { recursive: true });
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
function buildTypeScriptProject(options, moduleType) {
|
|
88
|
-
const tsconfigPath = path_1.default.join(process.cwd(), options.config || "tsconfig.json");
|
|
89
|
-
let tsconfig = {};
|
|
90
|
-
try {
|
|
91
|
-
if (fs_1.default.existsSync(tsconfigPath)) {
|
|
92
|
-
const tsconfigContent = fs_1.default.readFileSync(tsconfigPath, "utf8");
|
|
93
|
-
tsconfig = JSON.parse(tsconfigContent);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
catch (error) {
|
|
97
|
-
console.error("❌ Error reading tsconfig.json:", error);
|
|
98
|
-
}
|
|
99
|
-
const tempTsconfig = {
|
|
100
|
-
...tsconfig,
|
|
101
|
-
compilerOptions: {
|
|
102
|
-
...(tsconfig.compilerOptions || {}),
|
|
103
|
-
rootDir: ".",
|
|
104
|
-
outDir: path_1.default.join(`./${BUILD_DIR}`),
|
|
105
|
-
},
|
|
106
|
-
};
|
|
107
|
-
const tempTsconfigPath = path_1.default.join(process.cwd(), `tsconfig.arkos-build.json`);
|
|
108
|
-
fs_1.default.writeFileSync(tempTsconfigPath, JSON.stringify(tempTsconfig, null, 2));
|
|
109
|
-
try {
|
|
110
|
-
(0, child_process_1.execSync)(`npx rimraf ${BUILD_DIR} && npx tsc -p ${tempTsconfigPath}`, {
|
|
111
|
-
stdio: "inherit",
|
|
112
|
-
cwd: process.cwd(),
|
|
113
|
-
});
|
|
114
|
-
copyAllNonSourceFiles(moduleType, [".ts", ".tsx"]);
|
|
115
|
-
cleanupTempConfig(tempTsconfigPath);
|
|
116
|
-
}
|
|
117
|
-
catch (error) {
|
|
118
|
-
cleanupTempConfig(tempTsconfigPath);
|
|
119
|
-
throw error;
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
function buildJavaScriptProject(options, moduleType) {
|
|
123
|
-
const targetDir = path_1.default.join(BUILD_DIR);
|
|
124
|
-
try {
|
|
125
|
-
if (moduleType === "esm") {
|
|
126
|
-
(0, child_process_1.execSync)(`npx copyfiles -u 0 "src/**/*.js" "src/**/*.jsx" "src/**/*.mjs" ${targetDir}`, {
|
|
127
|
-
stdio: "inherit",
|
|
128
|
-
cwd: process.cwd(),
|
|
129
|
-
});
|
|
130
|
-
console.info("Note: .cjs files are skipped in ESM build");
|
|
131
|
-
}
|
|
132
|
-
else {
|
|
133
|
-
(0, child_process_1.execSync)(`npx copyfiles -u 0 "src/**/*.js" "src/**/*.jsx" "src/**/*.cjs" "src/**/*.mjs" ${targetDir}`, {
|
|
134
|
-
stdio: "inherit",
|
|
135
|
-
cwd: process.cwd(),
|
|
136
|
-
});
|
|
137
|
-
}
|
|
138
|
-
copyAllNonSourceFiles(moduleType, [
|
|
139
|
-
".js",
|
|
140
|
-
".jsx",
|
|
141
|
-
".mjs",
|
|
142
|
-
".cjs",
|
|
143
|
-
".ts",
|
|
144
|
-
".tsx",
|
|
145
|
-
]);
|
|
146
|
-
createModulePackageJson(moduleType);
|
|
147
|
-
}
|
|
148
|
-
catch (error) {
|
|
149
|
-
console.error("❌ Error building JavaScript project:", error);
|
|
150
|
-
throw error;
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
function copyAllNonSourceFiles(moduleType, skipExtensions) {
|
|
154
|
-
const targetDir = path_1.default.join(BUILD_DIR);
|
|
155
|
-
const sourceDir = "src";
|
|
156
|
-
try {
|
|
157
|
-
function copyDirRecursive(dir) {
|
|
158
|
-
if (!fs_1.default.existsSync(dir))
|
|
159
|
-
return;
|
|
160
|
-
const items = fs_1.default.readdirSync(dir);
|
|
161
|
-
for (const item of items) {
|
|
162
|
-
const sourcePath = path_1.default.join(dir, item);
|
|
163
|
-
const targetPath = path_1.default.join(targetDir, dir.replace(sourceDir, ""), item);
|
|
164
|
-
const stats = fs_1.default.statSync(sourcePath);
|
|
165
|
-
if (stats.isDirectory()) {
|
|
166
|
-
if (!fs_1.default.existsSync(targetPath)) {
|
|
167
|
-
fs_1.default.mkdirSync(targetPath, { recursive: true });
|
|
168
|
-
}
|
|
169
|
-
copyDirRecursive(sourcePath);
|
|
170
|
-
}
|
|
171
|
-
else if (stats.isFile()) {
|
|
172
|
-
const ext = path_1.default.extname(item).toLowerCase();
|
|
173
|
-
if (!skipExtensions.includes(ext)) {
|
|
174
|
-
const targetDir = path_1.default.dirname(targetPath);
|
|
175
|
-
if (!fs_1.default.existsSync(targetDir)) {
|
|
176
|
-
fs_1.default.mkdirSync(targetDir, { recursive: true });
|
|
177
|
-
}
|
|
178
|
-
fs_1.default.copyFileSync(sourcePath, targetPath);
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
copyDirRecursive(sourceDir);
|
|
184
|
-
const rootFilesToCopy = ["README.md", "LICENSE"];
|
|
185
|
-
for (const file of rootFilesToCopy) {
|
|
186
|
-
if (fs_1.default.existsSync(path_1.default.join(process.cwd(), file))) {
|
|
187
|
-
fs_1.default.copyFileSync(path_1.default.join(process.cwd(), file), path_1.default.join(targetDir, file));
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
catch (error) {
|
|
192
|
-
console.warn("Warning: Error copying project files:", error);
|
|
193
|
-
console.error(error);
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
function createModulePackageJson(moduleType) {
|
|
197
|
-
const packageJsonPath = path_1.default.join(process.cwd(), "package.json");
|
|
198
|
-
if (!fs_1.default.existsSync(packageJsonPath)) {
|
|
199
|
-
return;
|
|
200
|
-
}
|
|
201
|
-
try {
|
|
202
|
-
const packageJson = JSON.parse(fs_1.default.readFileSync(packageJsonPath, "utf8"));
|
|
203
|
-
const buildPackageJson = {
|
|
204
|
-
name: packageJson.name,
|
|
205
|
-
version: packageJson.version,
|
|
206
|
-
description: packageJson.description,
|
|
207
|
-
main: "index.js",
|
|
208
|
-
dependencies: packageJson.dependencies,
|
|
209
|
-
};
|
|
210
|
-
if (moduleType === "esm") {
|
|
211
|
-
buildPackageJson.type = "module";
|
|
212
|
-
}
|
|
213
|
-
const targetDir = path_1.default.join(BUILD_DIR, moduleType);
|
|
214
|
-
fs_1.default.writeFileSync(path_1.default.join(targetDir, "package.json"), JSON.stringify(buildPackageJson, null, 2));
|
|
215
|
-
}
|
|
216
|
-
catch (error) {
|
|
217
|
-
console.warn("Warning: Failed to create module-specific package.json", error);
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
function cleanupTempConfig(configPath) {
|
|
221
|
-
try {
|
|
222
|
-
if (fs_1.default.existsSync(configPath))
|
|
223
|
-
fs_1.default.unlinkSync(configPath);
|
|
224
|
-
}
|
|
225
|
-
catch (error) {
|
|
226
|
-
console.warn("Warning: Error cleaning up temporary config:", error);
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
//# sourceMappingURL=build.js.map
|
|
1
|
+
"use strict";var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.buildCommand=buildCommand;const path_1=__importDefault(require("path")),fs_1=__importDefault(require("fs")),child_process_1=require("child_process"),fs_helpers_1=require("../helpers/fs.helpers"),dotenv_helpers_1=require("../dotenv.helpers"),cli_helpers_1=require("./utils/cli.helpers"),global_helpers_1=require("../helpers/global.helpers"),BUILD_DIR=".build",MODULE_TYPES=["cjs","esm"];function buildCommand(e={}){const s=(0,fs_helpers_1.getUserFileExtension)();process.env.NODE_ENV="production",process.env.NODE_ENV="true";const t=(0,dotenv_helpers_1.loadEnvironmentVariables)(),n=validateModuleType(e.module);try{console.info(` \x1B[1m\x1B[36m Arkos.js ${(0,cli_helpers_1.getVersion)()}\x1B[0m`),console.info(` - Environments: ${(0,fs_helpers_1.fullCleanCwd)(t?.join(", ")||"").replaceAll(`${process.cwd()}/`,"").replaceAll("/","")}`),console.info(`
|
|
2
|
+
Creating an optimized production build...`),ensureBuildDir(),s==="ts"?buildTypeScriptProject(e,n):buildJavaScriptProject(e,n);const r=(0,global_helpers_1.detectPackageManagerFromUserAgent)();console.info(`
|
|
3
|
+
\x1B[1m\x1B[32m Build complete!\x1B[0m
|
|
4
|
+
`),console.info(" \x1B[1mNext step:\x1B[0m"),console.info(` Run it using \x1B[1m\x1B[36m${r} run start\x1B[0m
|
|
5
|
+
`)}catch(r){console.info(`
|
|
6
|
+
`),console.error("\u274C Build failed:",r),process.exit(1)}}function validateModuleType(e){if(!e)return"cjs";const s=e.toLowerCase();return s==="cjs"||s==="commonjs"?"cjs":["esm","es","es2020","esnext","module"].includes(s)?"esm":(console.warn(`\u26A0\uFE0F Unrecognized module type "${e}", defaulting to "cjs"`),"cjs")}function ensureBuildDir(){fs_1.default.existsSync(BUILD_DIR)||fs_1.default.mkdirSync(BUILD_DIR,{recursive:!0});for(const e of MODULE_TYPES){const s=path_1.default.join(BUILD_DIR,e);fs_1.default.existsSync(s)||fs_1.default.mkdirSync(s,{recursive:!0})}}function buildTypeScriptProject(e,s){const t=path_1.default.join(process.cwd(),e.config||"tsconfig.json");let n={};try{if(fs_1.default.existsSync(t)){const o=fs_1.default.readFileSync(t,"utf8");n=JSON.parse(o)}}catch(o){console.error("\u274C Error reading tsconfig.json:",o)}const r={...n,compilerOptions:{...n.compilerOptions||{},rootDir:".",outDir:path_1.default.join(`./${BUILD_DIR}`)}},c=path_1.default.join(process.cwd(),"tsconfig.arkos-build.json");fs_1.default.writeFileSync(c,JSON.stringify(r,null,2));try{(0,child_process_1.execSync)(`npx rimraf ${BUILD_DIR} && npx tsc -p ${c}`,{stdio:"inherit",cwd:process.cwd()}),copyAllNonSourceFiles(s,[".ts",".tsx"]),cleanupTempConfig(c)}catch(o){throw cleanupTempConfig(c),o}}function buildJavaScriptProject(e,s){const t=path_1.default.join(BUILD_DIR);try{s==="esm"?((0,child_process_1.execSync)(`npx copyfiles -u 0 "src/**/*.js" "src/**/*.jsx" "src/**/*.mjs" ${t}`,{stdio:"inherit",cwd:process.cwd()}),console.info("Note: .cjs files are skipped in ESM build")):(0,child_process_1.execSync)(`npx copyfiles -u 0 "src/**/*.js" "src/**/*.jsx" "src/**/*.cjs" "src/**/*.mjs" ${t}`,{stdio:"inherit",cwd:process.cwd()}),copyAllNonSourceFiles(s,[".js",".jsx",".mjs",".cjs",".ts",".tsx"]),createModulePackageJson(s)}catch(n){throw console.error("\u274C Error building JavaScript project:",n),n}}function copyAllNonSourceFiles(e,s){const t=path_1.default.join(BUILD_DIR),n="src";try{let r=function(o){if(!fs_1.default.existsSync(o))return;const d=fs_1.default.readdirSync(o);for(const l of d){const a=path_1.default.join(o,l),i=path_1.default.join(t,o.replace(n,""),l),u=fs_1.default.statSync(a);if(u.isDirectory())fs_1.default.existsSync(i)||fs_1.default.mkdirSync(i,{recursive:!0}),r(a);else if(u.isFile()){const p=path_1.default.extname(l).toLowerCase();if(!s.includes(p)){const f=path_1.default.dirname(i);fs_1.default.existsSync(f)||fs_1.default.mkdirSync(f,{recursive:!0}),fs_1.default.copyFileSync(a,i)}}}};r(n);const c=["README.md","LICENSE"];for(const o of c)fs_1.default.existsSync(path_1.default.join(process.cwd(),o))&&fs_1.default.copyFileSync(path_1.default.join(process.cwd(),o),path_1.default.join(t,o))}catch(r){console.warn("Warning: Error copying project files:",r),console.error(r)}}function createModulePackageJson(e){const s=path_1.default.join(process.cwd(),"package.json");if(fs_1.default.existsSync(s))try{const t=JSON.parse(fs_1.default.readFileSync(s,"utf8")),n={name:t.name,version:t.version,description:t.description,main:"index.js",dependencies:t.dependencies};e==="esm"&&(n.type="module");const r=path_1.default.join(BUILD_DIR,e);fs_1.default.writeFileSync(path_1.default.join(r,"package.json"),JSON.stringify(n,null,2))}catch(t){console.warn("Warning: Failed to create module-specific package.json",t)}}function cleanupTempConfig(e){try{fs_1.default.existsSync(e)&&fs_1.default.unlinkSync(e)}catch(s){console.warn("Warning: Error cleaning up temporary config:",s)}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.js","sourceRoot":"","sources":["../../../../src/utils/cli/build.ts"],"names":[],"mappings":";;;;;AAkCA,oCAwCC;AA1ED,gDAAwB;AACxB,4CAAoB;AACpB,iDAAyC;AACzC,sDAA2E;AAC3E,sDAA6D;AAC7D,qDAAiD;AAGjD,MAAM,SAAS,GAAG,QAAQ,CAAC;AAC3B,MAAM,YAAY,GAAG,CAAC,KAAK,EAAE,KAAK,CAAU,CAAC;AAQ7C,SAAS,iCAAiC;IACxC,MAAM,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,qBAAqB,IAAI,EAAE,CAAC;IAE1D,IAAI,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC;QAAE,OAAO,MAAM,CAAC;IAC9C,IAAI,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC;QAAE,OAAO,MAAM,CAAC;IAC9C,IAAI,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IAC5C,IAAI,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IAC5C,IAAI,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC;QAAE,OAAO,MAAM,CAAC;IAC9C,IAAI,SAAS,CAAC,QAAQ,CAAC,UAAU,CAAC;QAAE,OAAO,UAAU,CAAC;IACtD,IAAI,SAAS,CAAC,QAAQ,CAAC,MAA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gB,CAAC,IAAI,GAAG,QAAQ,CAAC;QACnC,CAAC;QAED,MAAM,SAAS,GAAG,cAAI,CAAC,IAAI,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;QACnD,YAAE,CAAC,aAAa,CACd,cAAI,CAAC,IAAI,CAAC,SAAS,EAAE,cAAc,CAAC,EACpC,IAAI,CAAC,SAAS,CAAC,gBAAgB,EAAE,IAAI,EAAE,CAAC,CAAC,CAC1C,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,IAAI,CACV,wDAAwD,EACxD,KAAK,CACN,CAAC;IACJ,CAAC;AACH,CAAC;AAKD,SAAS,iBAAiB,CAAC,UAAkB;IAC3C,IAAI,CAAC;QACH,IAAI,YAAE,CAAC,UAAU,CAAC,UAAU,CAAC;YAAE,YAAE,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;IAC3D,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,IAAI,CAAC,8CAA8C,EAAE,KAAK,CAAC,CAAC;IACtE,CAAC;AACH,CAAC","sourcesContent":["import path from \"path\";\nimport fs from \"fs\";\nimport { execSync } from \"child_process\";\nimport { fullCleanCwd, getUserFileExtension } from \"../helpers/fs.helpers\";\nimport { loadEnvironmentVariables } from \"../dotenv.helpers\";\nimport { getVersion } from \"./utils/cli.helpers\";\n\n// Constants\nconst BUILD_DIR = \".build\";\nconst MODULE_TYPES = [\"cjs\", \"esm\"] as const;\ntype ModuleType = (typeof MODULE_TYPES)[number];\n\ninterface BuildOptions {\n config?: string;\n module?: string;\n}\n\nfunction detectPackageManagerFromUserAgent() {\n const userAgent = process.env.npm_config_user_agent || \"\";\n\n if (userAgent.includes(\"pnpm\")) return \"pnpm\";\n if (userAgent.includes(\"yarn\")) return \"yarn\";\n if (userAgent.includes(\"npm\")) return \"npm\";\n if (userAgent.includes(\"bun\")) return \"bun\";\n if (userAgent.includes(\"cnpm\")) return \"cnpm\";\n if (userAgent.includes(\"corepack\")) return \"corepack\";\n if (userAgent.includes(\"deno\")) return \"deno\";\n\n return \"npm\";\n}\n\n/**\n * Main build function for the arkos CLI\n */\nexport function buildCommand(options: BuildOptions = {}) {\n const fileExt = getUserFileExtension();\n process.env.NODE_ENV = \"production\";\n process.env.NODE_ENV = \"true\";\n\n const envFiles = loadEnvironmentVariables();\n const moduleType = validateModuleType(options.module);\n\n try {\n console.info(` \\x1b[1m\\x1b[36m Arkos.js ${getVersion()}\\x1b[0m`);\n console.info(\n ` - Environments: ${fullCleanCwd(envFiles?.join(\", \") || \"\")\n .replaceAll(`${process.cwd()}/`, \"\")\n .replaceAll(\"/\", \"\")}`\n );\n\n console.info(`\\n Creating an optimized production build...`);\n\n ensureBuildDir();\n\n // Detect project type\n\n if (fileExt === \"ts\") {\n buildTypeScriptProject(options, moduleType);\n } else {\n buildJavaScriptProject(options, moduleType);\n }\n\n const packageManger = detectPackageManagerFromUserAgent();\n\n console.info(`\\n\\x1b[1m\\x1b[32m Build complete!\\x1b[0m\\n`);\n console.info(` \\x1b[1mNext step:\\x1b[0m`);\n console.info(\n ` Run it using \\x1b[1m\\x1b[36m${packageManger} run start\\x1b[0m\\n`\n );\n } catch (error) {\n console.info(\"\\n\");\n console.error(\"❌ Build failed:\", error);\n process.exit(1);\n }\n}\n\n/**\n * Validates and normalizes module type option\n */\nfunction validateModuleType(moduleType?: string): ModuleType {\n if (!moduleType) return \"cjs\";\n\n const normalizedType = moduleType.toLowerCase();\n\n // Map common terms to our module types\n if (normalizedType === \"cjs\" || normalizedType === \"commonjs\") {\n return \"cjs\";\n } else if (\n [\"esm\", \"es\", \"es2020\", \"esnext\", \"module\"].includes(normalizedType)\n ) {\n return \"esm\";\n }\n\n // Default to CJS if unrecognized\n console.warn(\n `⚠️ Unrecognized module type \"${moduleType}\", defaulting to \"cjs\"`\n );\n return \"cjs\";\n}\n\n/**\n * Ensure the build directory exists\n */\nfunction ensureBuildDir() {\n if (!fs.existsSync(BUILD_DIR)) {\n fs.mkdirSync(BUILD_DIR, { recursive: true });\n }\n\n // Create module-specific subdirectories\n for (const moduleType of MODULE_TYPES) {\n const moduleDir = path.join(BUILD_DIR, moduleType);\n if (!fs.existsSync(moduleDir)) {\n fs.mkdirSync(moduleDir, { recursive: true });\n }\n }\n}\n\n/**\n * Build a TypeScript project\n */\nfunction buildTypeScriptProject(options: BuildOptions, moduleType: ModuleType) {\n // Read the user's tsconfig.json\n const tsconfigPath = path.join(\n process.cwd(),\n options.config || \"tsconfig.json\"\n );\n let tsconfig: any = {};\n\n try {\n if (fs.existsSync(tsconfigPath)) {\n const tsconfigContent = fs.readFileSync(tsconfigPath, \"utf8\");\n tsconfig = JSON.parse(tsconfigContent);\n }\n } catch (error) {\n console.error(\"❌ Error reading tsconfig.json:\", error);\n // Continue with default config\n }\n\n // Create a custom tsconfig that outputs to our build directory with the correct module type\n const tempTsconfig = {\n ...tsconfig,\n compilerOptions: {\n ...(tsconfig.compilerOptions || {}),\n rootDir: \".\",\n outDir: path.join(`./${BUILD_DIR}`),\n // module: moduleType === \"esm\" ? \"ESNext\" : \"CommonJS\",\n },\n };\n\n const tempTsconfigPath = path.join(\n process.cwd(),\n `tsconfig.arkos-build.json`\n );\n fs.writeFileSync(tempTsconfigPath, JSON.stringify(tempTsconfig, null, 2));\n\n try {\n // Run TypeScript compiler\n execSync(`npx rimraf ${BUILD_DIR} && npx tsc -p ${tempTsconfigPath}`, {\n stdio: \"inherit\",\n cwd: process.cwd(),\n });\n\n // Copy non-TypeScript files\n\n copyAllNonSourceFiles(moduleType, [\".ts\", \".tsx\"]);\n\n // Clean up temp config\n cleanupTempConfig(tempTsconfigPath);\n } catch (error) {\n cleanupTempConfig(tempTsconfigPath);\n throw error;\n }\n}\n\n/**\n * Build a JavaScript project\n */\nfunction buildJavaScriptProject(options: BuildOptions, moduleType: ModuleType) {\n // Target directory\n const targetDir = path.join(BUILD_DIR);\n\n try {\n // Copy JavaScript files based on module type\n if (moduleType === \"esm\") {\n // Copy JS files for ESM (skip .cjs files as they are CommonJS)\n\n execSync(\n `npx copyfiles -u 0 \"src/**/*.js\" \"src/**/*.jsx\" \"src/**/*.mjs\" ${targetDir}`,\n {\n stdio: \"inherit\",\n cwd: process.cwd(),\n }\n );\n\n // Note about CommonJS files\n console.info(\"Note: .cjs files are skipped in ESM build\");\n } else {\n // Copy all JS files for CommonJS\n\n execSync(\n `npx copyfiles -u 0 \"src/**/*.js\" \"src/**/*.jsx\" \"src/**/*.cjs\" \"src/**/*.mjs\" ${targetDir}`,\n {\n stdio: \"inherit\",\n cwd: process.cwd(),\n }\n );\n }\n\n // Copy all non-JS files\n copyAllNonSourceFiles(moduleType, [\n \".js\",\n \".jsx\",\n \".mjs\",\n \".cjs\",\n \".ts\",\n \".tsx\",\n ]);\n\n // Create appropriate package.json in the build directory\n createModulePackageJson(moduleType);\n } catch (error) {\n console.error(\"❌ Error building JavaScript project:\", error);\n throw error;\n }\n}\n\n/**\n * Copy all non-source code files to the build directory\n * This function will copy everything except the specified source file extensions\n */\nfunction copyAllNonSourceFiles(\n moduleType: ModuleType,\n skipExtensions: string[]\n) {\n const targetDir = path.join(BUILD_DIR);\n const sourceDir = \"src\";\n\n try {\n // Recursive function to copy files\n function copyDirRecursive(dir: string) {\n if (!fs.existsSync(dir)) return;\n\n const items = fs.readdirSync(dir);\n\n for (const item of items) {\n const sourcePath = path.join(dir, item);\n const targetPath = path.join(\n targetDir,\n dir.replace(sourceDir, \"\"),\n item\n );\n\n // Get file stats\n const stats = fs.statSync(sourcePath);\n\n if (stats.isDirectory()) {\n // Ensure target directory exists\n if (!fs.existsSync(targetPath)) {\n fs.mkdirSync(targetPath, { recursive: true });\n }\n // Recurse into subdirectory\n copyDirRecursive(sourcePath);\n } else if (stats.isFile()) {\n // Check if this is a file we should skip\n const ext = path.extname(item).toLowerCase();\n if (!skipExtensions.includes(ext)) {\n // Ensure the target directory exists\n const targetDir = path.dirname(targetPath);\n if (!fs.existsSync(targetDir)) {\n fs.mkdirSync(targetDir, { recursive: true });\n }\n // Copy the file\n fs.copyFileSync(sourcePath, targetPath);\n }\n }\n }\n }\n\n // Start copying from src directory\n copyDirRecursive(sourceDir);\n\n // Copy project root files if needed\n const rootFilesToCopy = [\"README.md\", \"LICENSE\"];\n\n for (const file of rootFilesToCopy) {\n if (fs.existsSync(path.join(process.cwd(), file))) {\n fs.copyFileSync(\n path.join(process.cwd(), file),\n path.join(targetDir, file)\n );\n }\n }\n\n // console.info(`Copied all non-source files to ${targetDir}`);\n } catch (error) {\n console.warn(\"Warning: Error copying project files:\", error);\n console.error(error);\n }\n}\n\n/**\n * Create appropriate package.json in the build directory\n */\nfunction createModulePackageJson(moduleType: ModuleType) {\n const packageJsonPath = path.join(process.cwd(), \"package.json\");\n\n if (!fs.existsSync(packageJsonPath)) {\n return;\n }\n\n try {\n const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, \"utf8\"));\n const buildPackageJson: any = {\n name: packageJson.name,\n version: packageJson.version,\n description: packageJson.description,\n main: \"index.js\",\n dependencies: packageJson.dependencies,\n };\n\n // Set appropriate type field for ESM\n if (moduleType === \"esm\") {\n buildPackageJson.type = \"module\";\n }\n\n const targetDir = path.join(BUILD_DIR, moduleType);\n fs.writeFileSync(\n path.join(targetDir, \"package.json\"),\n JSON.stringify(buildPackageJson, null, 2)\n );\n } catch (error) {\n console.warn(\n \"Warning: Failed to create module-specific package.json\",\n error\n );\n }\n}\n\n/**\n * Clean up temporary tsconfig\n */\nfunction cleanupTempConfig(configPath: string) {\n try {\n if (fs.existsSync(configPath)) fs.unlinkSync(configPath);\n } catch (error) {\n console.warn(\"Warning: Error cleaning up temporary config:\", error);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"build.js","sourceRoot":"","sources":["../../../../src/utils/cli/build.ts"],"names":[],"mappings":";;;;;AAqBA,oCAwCC;AA7DD,gDAAwB;AACxB,4CAAoB;AACpB,iDAAyC;AACzC,sDAA2E;AAC3E,sDAA6D;AAC7D,qDAAiD;AACjD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,IAAI,UAAU,KAAK,KAAK,EAAE,CAAC;YACzB,gBAAgB,CAAC,IAAI,GAAG,QAAQ,CAAC;QACnC,CAAC;QAED,MAAM,SAAS,GAAG,cAAI,CAAC,IAAI,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;QACnD,YAAE,CAAC,aAAa,CACd,cAAI,CAAC,IAAI,CAAC,SAAS,EAAE,cAAc,CAAC,EACpC,IAAI,CAAC,SAAS,CAAC,gBAAgB,EAAE,IAAI,EAAE,CAAC,CAAC,CAC1C,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,IAAI,CACV,wDAAwD,EACxD,KAAK,CACN,CAAC;IACJ,CAAC;AACH,CAAC;AAKD,SAAS,iBAAiB,CAAC,UAAkB;IAC3C,IAAI,CAAC;QACH,IAAI,YAAE,CAAC,UAAU,CAAC,UAAU,CAAC;YAAE,YAAE,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;IAC3D,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,IAAI,CAAC,8CAA8C,EAAE,KAAK,CAAC,CAAC;IACtE,CAAC;AACH,CAAC","sourcesContent":["import path from \"path\";\nimport fs from \"fs\";\nimport { execSync } from \"child_process\";\nimport { fullCleanCwd, getUserFileExtension } from \"../helpers/fs.helpers\";\nimport { loadEnvironmentVariables } from \"../dotenv.helpers\";\nimport { getVersion } from \"./utils/cli.helpers\";\nimport { detectPackageManagerFromUserAgent } from \"../helpers/global.helpers\";\n\n// Constants\nconst BUILD_DIR = \".build\";\nconst MODULE_TYPES = [\"cjs\", \"esm\"] as const;\ntype ModuleType = (typeof MODULE_TYPES)[number];\n\ninterface BuildOptions {\n config?: string;\n module?: string;\n}\n\n/**\n * Main build function for the arkos CLI\n */\nexport function buildCommand(options: BuildOptions = {}) {\n const fileExt = getUserFileExtension();\n process.env.NODE_ENV = \"production\";\n process.env.NODE_ENV = \"true\";\n\n const envFiles = loadEnvironmentVariables();\n const moduleType = validateModuleType(options.module);\n\n try {\n console.info(` \\x1b[1m\\x1b[36m Arkos.js ${getVersion()}\\x1b[0m`);\n console.info(\n ` - Environments: ${fullCleanCwd(envFiles?.join(\", \") || \"\")\n .replaceAll(`${process.cwd()}/`, \"\")\n .replaceAll(\"/\", \"\")}`\n );\n\n console.info(`\\n Creating an optimized production build...`);\n\n ensureBuildDir();\n\n // Detect project type\n\n if (fileExt === \"ts\") {\n buildTypeScriptProject(options, moduleType);\n } else {\n buildJavaScriptProject(options, moduleType);\n }\n\n const packageManger = detectPackageManagerFromUserAgent();\n\n console.info(`\\n\\x1b[1m\\x1b[32m Build complete!\\x1b[0m\\n`);\n console.info(` \\x1b[1mNext step:\\x1b[0m`);\n console.info(\n ` Run it using \\x1b[1m\\x1b[36m${packageManger} run start\\x1b[0m\\n`\n );\n } catch (error) {\n console.info(\"\\n\");\n console.error(\"❌ Build failed:\", error);\n process.exit(1);\n }\n}\n\n/**\n * Validates and normalizes module type option\n */\nfunction validateModuleType(moduleType?: string): ModuleType {\n if (!moduleType) return \"cjs\";\n\n const normalizedType = moduleType.toLowerCase();\n\n // Map common terms to our module types\n if (normalizedType === \"cjs\" || normalizedType === \"commonjs\") {\n return \"cjs\";\n } else if (\n [\"esm\", \"es\", \"es2020\", \"esnext\", \"module\"].includes(normalizedType)\n ) {\n return \"esm\";\n }\n\n // Default to CJS if unrecognized\n console.warn(\n `⚠️ Unrecognized module type \"${moduleType}\", defaulting to \"cjs\"`\n );\n return \"cjs\";\n}\n\n/**\n * Ensure the build directory exists\n */\nfunction ensureBuildDir() {\n if (!fs.existsSync(BUILD_DIR)) {\n fs.mkdirSync(BUILD_DIR, { recursive: true });\n }\n\n // Create module-specific subdirectories\n for (const moduleType of MODULE_TYPES) {\n const moduleDir = path.join(BUILD_DIR, moduleType);\n if (!fs.existsSync(moduleDir)) {\n fs.mkdirSync(moduleDir, { recursive: true });\n }\n }\n}\n\n/**\n * Build a TypeScript project\n */\nfunction buildTypeScriptProject(options: BuildOptions, moduleType: ModuleType) {\n // Read the user's tsconfig.json\n const tsconfigPath = path.join(\n process.cwd(),\n options.config || \"tsconfig.json\"\n );\n let tsconfig: any = {};\n\n try {\n if (fs.existsSync(tsconfigPath)) {\n const tsconfigContent = fs.readFileSync(tsconfigPath, \"utf8\");\n tsconfig = JSON.parse(tsconfigContent);\n }\n } catch (error) {\n console.error(\"❌ Error reading tsconfig.json:\", error);\n // Continue with default config\n }\n\n // Create a custom tsconfig that outputs to our build directory with the correct module type\n const tempTsconfig = {\n ...tsconfig,\n compilerOptions: {\n ...(tsconfig.compilerOptions || {}),\n rootDir: \".\",\n outDir: path.join(`./${BUILD_DIR}`),\n // module: moduleType === \"esm\" ? \"ESNext\" : \"CommonJS\",\n },\n };\n\n const tempTsconfigPath = path.join(\n process.cwd(),\n `tsconfig.arkos-build.json`\n );\n fs.writeFileSync(tempTsconfigPath, JSON.stringify(tempTsconfig, null, 2));\n\n try {\n // Run TypeScript compiler\n execSync(`npx rimraf ${BUILD_DIR} && npx tsc -p ${tempTsconfigPath}`, {\n stdio: \"inherit\",\n cwd: process.cwd(),\n });\n\n // Copy non-TypeScript files\n\n copyAllNonSourceFiles(moduleType, [\".ts\", \".tsx\"]);\n\n // Clean up temp config\n cleanupTempConfig(tempTsconfigPath);\n } catch (error) {\n cleanupTempConfig(tempTsconfigPath);\n throw error;\n }\n}\n\n/**\n * Build a JavaScript project\n */\nfunction buildJavaScriptProject(options: BuildOptions, moduleType: ModuleType) {\n // Target directory\n const targetDir = path.join(BUILD_DIR);\n\n try {\n // Copy JavaScript files based on module type\n if (moduleType === \"esm\") {\n // Copy JS files for ESM (skip .cjs files as they are CommonJS)\n\n execSync(\n `npx copyfiles -u 0 \"src/**/*.js\" \"src/**/*.jsx\" \"src/**/*.mjs\" ${targetDir}`,\n {\n stdio: \"inherit\",\n cwd: process.cwd(),\n }\n );\n\n // Note about CommonJS files\n console.info(\"Note: .cjs files are skipped in ESM build\");\n } else {\n // Copy all JS files for CommonJS\n\n execSync(\n `npx copyfiles -u 0 \"src/**/*.js\" \"src/**/*.jsx\" \"src/**/*.cjs\" \"src/**/*.mjs\" ${targetDir}`,\n {\n stdio: \"inherit\",\n cwd: process.cwd(),\n }\n );\n }\n\n // Copy all non-JS files\n copyAllNonSourceFiles(moduleType, [\n \".js\",\n \".jsx\",\n \".mjs\",\n \".cjs\",\n \".ts\",\n \".tsx\",\n ]);\n\n // Create appropriate package.json in the build directory\n createModulePackageJson(moduleType);\n } catch (error) {\n console.error(\"❌ Error building JavaScript project:\", error);\n throw error;\n }\n}\n\n/**\n * Copy all non-source code files to the build directory\n * This function will copy everything except the specified source file extensions\n */\nfunction copyAllNonSourceFiles(\n moduleType: ModuleType,\n skipExtensions: string[]\n) {\n const targetDir = path.join(BUILD_DIR);\n const sourceDir = \"src\";\n\n try {\n // Recursive function to copy files\n function copyDirRecursive(dir: string) {\n if (!fs.existsSync(dir)) return;\n\n const items = fs.readdirSync(dir);\n\n for (const item of items) {\n const sourcePath = path.join(dir, item);\n const targetPath = path.join(\n targetDir,\n dir.replace(sourceDir, \"\"),\n item\n );\n\n // Get file stats\n const stats = fs.statSync(sourcePath);\n\n if (stats.isDirectory()) {\n // Ensure target directory exists\n if (!fs.existsSync(targetPath)) {\n fs.mkdirSync(targetPath, { recursive: true });\n }\n // Recurse into subdirectory\n copyDirRecursive(sourcePath);\n } else if (stats.isFile()) {\n // Check if this is a file we should skip\n const ext = path.extname(item).toLowerCase();\n if (!skipExtensions.includes(ext)) {\n // Ensure the target directory exists\n const targetDir = path.dirname(targetPath);\n if (!fs.existsSync(targetDir)) {\n fs.mkdirSync(targetDir, { recursive: true });\n }\n // Copy the file\n fs.copyFileSync(sourcePath, targetPath);\n }\n }\n }\n }\n\n // Start copying from src directory\n copyDirRecursive(sourceDir);\n\n // Copy project root files if needed\n const rootFilesToCopy = [\"README.md\", \"LICENSE\"];\n\n for (const file of rootFilesToCopy) {\n if (fs.existsSync(path.join(process.cwd(), file))) {\n fs.copyFileSync(\n path.join(process.cwd(), file),\n path.join(targetDir, file)\n );\n }\n }\n\n // console.info(`Copied all non-source files to ${targetDir}`);\n } catch (error) {\n console.warn(\"Warning: Error copying project files:\", error);\n console.error(error);\n }\n}\n\n/**\n * Create appropriate package.json in the build directory\n */\nfunction createModulePackageJson(moduleType: ModuleType) {\n const packageJsonPath = path.join(process.cwd(), \"package.json\");\n\n if (!fs.existsSync(packageJsonPath)) {\n return;\n }\n\n try {\n const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, \"utf8\"));\n const buildPackageJson: any = {\n name: packageJson.name,\n version: packageJson.version,\n description: packageJson.description,\n main: \"index.js\",\n dependencies: packageJson.dependencies,\n };\n\n // Set appropriate type field for ESM\n if (moduleType === \"esm\") {\n buildPackageJson.type = \"module\";\n }\n\n const targetDir = path.join(BUILD_DIR, moduleType);\n fs.writeFileSync(\n path.join(targetDir, \"package.json\"),\n JSON.stringify(buildPackageJson, null, 2)\n );\n } catch (error) {\n console.warn(\n \"Warning: Failed to create module-specific package.json\",\n error\n );\n }\n}\n\n/**\n * Clean up temporary tsconfig\n */\nfunction cleanupTempConfig(configPath: string) {\n try {\n if (fs.existsSync(configPath)) fs.unlinkSync(configPath);\n } catch (error) {\n console.warn(\"Warning: Error cleaning up temporary config:\", error);\n }\n}\n"]}
|