arkos 1.2.20-test → 1.2.21-test
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/app.js +1 -1
- package/dist/esm/exports/auth/index.js +1 -1
- package/dist/esm/exports/controllers/index.js +2 -2
- package/dist/esm/exports/error-handler/index.js +2 -2
- package/dist/esm/exports/index.js +2 -2
- package/dist/esm/exports/middlewares/index.js +1 -1
- package/dist/esm/exports/prisma/index.js +1 -1
- package/dist/esm/exports/services/index.js +4 -4
- package/dist/esm/exports/utils/index.js +2 -2
- package/dist/esm/exports/validation/index.js +2 -2
- package/dist/esm/modules/auth/auth.controller.js +7 -7
- package/dist/esm/modules/auth/auth.router.js +6 -6
- package/dist/esm/modules/auth/auth.service.js +6 -6
- package/dist/esm/modules/auth/utils/helpers/auth.controller.helpers.js +2 -2
- package/dist/esm/modules/base/base.controller.js +7 -7
- package/dist/esm/modules/base/base.middlewares.js +6 -6
- package/dist/esm/modules/base/base.router.js +4 -4
- package/dist/esm/modules/base/base.service.js +6 -6
- package/dist/esm/modules/base/utils/helpers/base.controller.helpers.js +1 -1
- package/dist/esm/modules/base/utils/helpers/base.middlewares.helpers.js +1 -1
- package/dist/esm/modules/base/utils/helpers/base.router.helpers.js +6 -6
- package/dist/esm/modules/base/utils/helpers/base.service.helpers.js +1 -1
- package/dist/esm/modules/email/email.service.js +2 -2
- package/dist/esm/modules/error-handler/error-handler.controller.js +3 -3
- package/dist/esm/modules/error-handler/utils/error-handler.helpers.js +1 -1
- package/dist/esm/modules/file-upload/file-upload.controller.js +7 -7
- package/dist/esm/modules/file-upload/file-upload.router.js +5 -5
- package/dist/esm/modules/file-upload/file-upload.service.js +5 -5
- package/dist/esm/modules/file-upload/utils/helpers/file-upload.helpers.js +2 -2
- package/dist/esm/modules/swagger/swagger.router.js +2 -2
- package/dist/esm/modules/swagger/utils/helpers/get-authentication-json-schema-paths.js +2 -2
- package/dist/esm/modules/swagger/utils/helpers/json-schema-generators/generate-class-validator-json-schemas.js +3 -3
- package/dist/esm/modules/swagger/utils/helpers/json-schema-generators/generate-prisma-json-schemas.js +2 -2
- package/dist/esm/modules/swagger/utils/helpers/json-schema-generators/generate-zod-json-schema.js +2 -2
- package/dist/esm/modules/swagger/utils/helpers/json-schema-generators/prisma-models/generate-prisma-model-main-routes.js +2 -2
- package/dist/esm/modules/swagger/utils/helpers/json-schema-generators/prisma-models/generate-prisma-model-parent-routes.js +3 -3
- package/dist/esm/modules/swagger/utils/helpers/swagger.router.helpers.js +9 -9
- package/dist/esm/server.js +1 -1
- package/dist/esm/utils/cli/build.js +4 -4
- package/dist/esm/utils/cli/dev.js +5 -5
- package/dist/esm/utils/cli/generate.js +4 -4
- package/dist/esm/utils/cli/index.js +5 -5
- package/dist/esm/utils/cli/start.js +4 -4
- package/dist/esm/utils/cli/utils/cli.helpers.js +2 -2
- package/dist/esm/utils/cli/utils/template-generator/templates/generate-auth-configs-template.js +1 -1
- package/dist/esm/utils/cli/utils/template-generator/templates/generate-middlewares.js +1 -1
- package/dist/esm/utils/cli/utils/template-generator/templates/generate-prisma-query-options.js +2 -2
- package/dist/esm/utils/cli/utils/template-generator/templates/generate-router-template.js +1 -1
- package/dist/esm/utils/cli/utils/template-generator/templates/generate-service-template.js +2 -2
- package/dist/esm/utils/cli/utils/template-generators.js +6 -6
- package/dist/esm/utils/features/api.features.js +4 -4
- package/dist/esm/utils/features/change-case.features.js +1 -1
- package/dist/esm/utils/helpers/models.helpers.js +4 -4
- package/dist/esm/utils/helpers/prisma.helpers.js +4 -4
- package/dist/esm/utils/validate-dto.js +1 -1
- package/dist/esm/utils/validate-schema.js +1 -1
- package/package.json +2 -1
package/dist/esm/app.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import c from"express";import p from"cors";import m from"cookie-parser";import{getAuthRouter as f}from"./modules/auth/auth.router";import{getPrismaModelsRouter as w,getAvailableResourcesAndRoutesRouter as R}from"./modules/base/base.router";import h from"./modules/error-handler/error-handler.controller";import{rateLimit as P}from"express-rate-limit";import y from"compression";import{handleRequestLogs as b}from"./modules/base/base.middlewares";import{checkDatabaseConnection as q,loadPrismaModule as A}from"./utils/helpers/prisma.helpers";import{getFileUploadRouter as O}from"./modules/file-upload/file-upload.router";import{queryParser as g}from"./utils/helpers/query-parser.helpers";import d from"./utils/helpers/deepmerge.helper";import{getSwaggerRouter as E}from"./modules/swagger/swagger.router";export const app=c();export async function bootstrap(e){await A(),e?.configureApp&&await e.configureApp(app);const n=e?.middlewares,t=n?.disable||[],a=n?.replace||{};t?.includes?.("compression")||app.use(a.compression||y(e?.compressionOptions)),t?.includes?.("global-rate-limit")||app.use(a.globalRateLimit||P(d({windowMs:60*1e3,limit:500,standardHeaders:"draft-7",legacyHeaders:!1,handler:(r,s)=>{s.status(429).json({message:"Too many requests, please try again later"})}},e?.globalRequestRateLimitOptions||{}))),t?.includes?.("cors")||app.use(a.cors||p(e?.cors?.customHandler?e.cors.customHandler:d({origin:(r,s)=>{const i=e?.cors?.allowedOrigins;i==="*"?s(null,!0):Array.isArray(i)?s(null,!r||i?.includes?.(r)):typeof i=="string"?s(null,!r||i===r):s(null,!1)},methods:["GET","POST","PUT","DELETE","PATCH","OPTIONS"],allowedHeaders:["Content-Type","Authorization","Connection"],credentials:!0},e?.cors?.options||{}))),t?.includes?.("express-json")||app.use(a.expressJson||c.json(e?.jsonBodyParserOptions)),t?.includes?.("cookie-parser")||app.use(a.cookieParser||m(...e?.cookieParserParameters||[])),t?.includes?.("query-parser")||app.use(a.queryParser||g(d({parseNull:!0,parseUndefined:!0,parseBoolean:!0},e?.queryParserOptions||{}))),t?.includes?.("database-connection")||app.use(a.databaseConnection||q),t?.includes?.("request-logger")||app.use(a.requestLogger||b),e?.middlewares?.additional&&e.middlewares.additional.forEach(r=>{app.use(r)});const l=e?.routers,u=l?.disable||[],o=l?.replace||{};if(u?.includes?.("welcome-endpoint")||app.get("/api",o.welcomeEndpoint||((r,s)=>{s.status(200).json({message:e.welcomeMessage})})),!u?.includes?.("file-upload")){const r=o.fileUpload?await o.fileUpload(e):await O(e);app.use(r)}if(!u?.includes?.("auth-router")&&e.authentication){const r=o.authRouter?await o.authRouter(e):await f(e);app.use("/api",r)}if(!u?.includes?.("prisma-models-router")){const r=o.prismaModelsRouter?await o.prismaModelsRouter(e):await w(e);app.use("/api",r)}return app.use("/api",R()),e.swagger&&(process.env.ARKOS_BUILD!=="true"||e.swagger.enableAfterBuild===!0)&&app.use("/api",await E(e)),l?.additional&&l.additional.forEach(r=>{app.use(r)}),t?.includes?.("global-error-handler")||app.use(a.globalErrorHandler||h),app.use("*",(r,s)=>{s.status(404).json({message:"Route not found!"})}),app}
|
|
1
|
+
"use strict";import c from"express";import p from"cors";import m from"cookie-parser";import{getAuthRouter as f}from"./modules/auth/auth.router.js";import{getPrismaModelsRouter as w,getAvailableResourcesAndRoutesRouter as R}from"./modules/base/base.router.js";import h from"./modules/error-handler/error-handler.controller.js";import{rateLimit as P}from"express-rate-limit";import y from"compression";import{handleRequestLogs as b}from"./modules/base/base.middlewares.js";import{checkDatabaseConnection as q,loadPrismaModule as A}from"./utils/helpers/prisma.helpers.js";import{getFileUploadRouter as O}from"./modules/file-upload/file-upload.router.js";import{queryParser as g}from"./utils/helpers/query-parser.helpers.js";import d from"./utils/helpers/deepmerge.helper.js";import{getSwaggerRouter as E}from"./modules/swagger/swagger.router.js";export const app=c();export async function bootstrap(e){await A(),e?.configureApp&&await e.configureApp(app);const n=e?.middlewares,t=n?.disable||[],a=n?.replace||{};t?.includes?.("compression")||app.use(a.compression||y(e?.compressionOptions)),t?.includes?.("global-rate-limit")||app.use(a.globalRateLimit||P(d({windowMs:60*1e3,limit:500,standardHeaders:"draft-7",legacyHeaders:!1,handler:(r,s)=>{s.status(429).json({message:"Too many requests, please try again later"})}},e?.globalRequestRateLimitOptions||{}))),t?.includes?.("cors")||app.use(a.cors||p(e?.cors?.customHandler?e.cors.customHandler:d({origin:(r,s)=>{const i=e?.cors?.allowedOrigins;i==="*"?s(null,!0):Array.isArray(i)?s(null,!r||i?.includes?.(r)):typeof i=="string"?s(null,!r||i===r):s(null,!1)},methods:["GET","POST","PUT","DELETE","PATCH","OPTIONS"],allowedHeaders:["Content-Type","Authorization","Connection"],credentials:!0},e?.cors?.options||{}))),t?.includes?.("express-json")||app.use(a.expressJson||c.json(e?.jsonBodyParserOptions)),t?.includes?.("cookie-parser")||app.use(a.cookieParser||m(...e?.cookieParserParameters||[])),t?.includes?.("query-parser")||app.use(a.queryParser||g(d({parseNull:!0,parseUndefined:!0,parseBoolean:!0},e?.queryParserOptions||{}))),t?.includes?.("database-connection")||app.use(a.databaseConnection||q),t?.includes?.("request-logger")||app.use(a.requestLogger||b),e?.middlewares?.additional&&e.middlewares.additional.forEach(r=>{app.use(r)});const l=e?.routers,u=l?.disable||[],o=l?.replace||{};if(u?.includes?.("welcome-endpoint")||app.get("/api",o.welcomeEndpoint||((r,s)=>{s.status(200).json({message:e.welcomeMessage})})),!u?.includes?.("file-upload")){const r=o.fileUpload?await o.fileUpload(e):await O(e);app.use(r)}if(!u?.includes?.("auth-router")&&e.authentication){const r=o.authRouter?await o.authRouter(e):await f(e);app.use("/api",r)}if(!u?.includes?.("prisma-models-router")){const r=o.prismaModelsRouter?await o.prismaModelsRouter(e):await w(e);app.use("/api",r)}return app.use("/api",R()),e.swagger&&(process.env.ARKOS_BUILD!=="true"||e.swagger.enableAfterBuild===!0)&&app.use("/api",await E(e)),l?.additional&&l.additional.forEach(r=>{app.use(r)}),t?.includes?.("global-error-handler")||app.use(a.globalErrorHandler||h),app.use("*",(r,s)=>{s.status(404).json({message:"Route not found!"})}),app}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { defaultExcludedUserFields } from "./../../modules/auth/auth.controller";
|
|
1
|
+
export { defaultExcludedUserFields } from "./../../modules/auth/auth.controller.js";
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BaseController } from "./../../modules/base/base.controller";
|
|
2
|
-
import fileUploadController from "../../modules/file-upload/file-upload.controller";
|
|
1
|
+
import { BaseController } from "./../../modules/base/base.controller.js";
|
|
2
|
+
import fileUploadController from "../../modules/file-upload/file-upload.controller.js";
|
|
3
3
|
export { fileUploadController, BaseController };
|
|
4
4
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import catchAsync from "../../modules/error-handler/utils/catch-async";
|
|
2
|
-
import AppError from "../../modules/error-handler/utils/app-error";
|
|
1
|
+
import catchAsync from "../../modules/error-handler/utils/catch-async.js";
|
|
2
|
+
import AppError from "../../modules/error-handler/utils/app-error.js";
|
|
3
3
|
export { catchAsync, AppError };
|
|
4
4
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { BaseController } from "./../modules/base/base.controller";
|
|
2
|
-
import { initApp, getArkosConfig } from "../server";
|
|
1
|
+
import { BaseController } from "./../modules/base/base.controller.js";
|
|
2
|
+
import { initApp, getArkosConfig } from "../server.js";
|
|
3
3
|
const arkos = {
|
|
4
4
|
init: initApp,
|
|
5
5
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { addPrismaQueryOptionsToRequest, handleRequestBodyValidationAndTransformation, } from "../../modules/base/base.middlewares";
|
|
1
|
+
export { addPrismaQueryOptionsToRequest, handleRequestBodyValidationAndTransformation, } from "../../modules/base/base.middlewares.js";
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { getFileUploadServices, FileUploadService, } from "../../modules/file-upload/file-upload.service";
|
|
2
|
-
import authService, { AuthService } from "../../modules/auth/auth.service";
|
|
3
|
-
import emailService, { EmailService } from "../../modules/email/email.service";
|
|
4
|
-
import { BaseService, getBaseServices } from "../../modules/base/base.service";
|
|
1
|
+
import { getFileUploadServices, FileUploadService, } from "../../modules/file-upload/file-upload.service.js";
|
|
2
|
+
import authService, { AuthService } from "../../modules/auth/auth.service.js";
|
|
3
|
+
import emailService, { EmailService } from "../../modules/email/email.service.js";
|
|
4
|
+
import { BaseService, getBaseServices } from "../../modules/base/base.service.js";
|
|
5
5
|
export { authService, AuthService };
|
|
6
6
|
export { BaseService, getBaseServices };
|
|
7
7
|
export { emailService, EmailService };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from "../../utils/helpers/change-case.helpers";
|
|
2
|
-
import APIFeatures, { apiFeatures } from "../../utils/features/api.features";
|
|
1
|
+
export * from "../../utils/helpers/change-case.helpers.js";
|
|
2
|
+
import APIFeatures, { apiFeatures } from "../../utils/features/api.features.js";
|
|
3
3
|
export { APIFeatures, apiFeatures };
|
|
4
4
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import validateDto from "../../utils/validate-dto";
|
|
2
|
-
import validateSchema from "../../utils/validate-schema";
|
|
1
|
+
import validateDto from "../../utils/validate-dto.js";
|
|
2
|
+
import validateSchema from "../../utils/validate-schema.js";
|
|
3
3
|
export { validateDto, validateSchema };
|
|
4
4
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import catchAsync from "../error-handler/utils/catch-async";
|
|
2
|
-
import AppError from "../error-handler/utils/app-error";
|
|
3
|
-
import authService from "./auth.service";
|
|
4
|
-
import { getBaseServices } from "../base/base.service";
|
|
5
|
-
import arkosEnv from "../../utils/arkos-env";
|
|
6
|
-
import { getArkosConfig } from "../../server";
|
|
7
|
-
import { createPrismaWhereClause, determineUsernameField, getNestedValue, toMs, } from "./utils/helpers/auth.controller.helpers";
|
|
1
|
+
import catchAsync from "../error-handler/utils/catch-async.js";
|
|
2
|
+
import AppError from "../error-handler/utils/app-error.js";
|
|
3
|
+
import authService from "./auth.service.js";
|
|
4
|
+
import { getBaseServices } from "../base/base.service.js";
|
|
5
|
+
import arkosEnv from "../../utils/arkos-env.js";
|
|
6
|
+
import { getArkosConfig } from "../../server.js";
|
|
7
|
+
import { createPrismaWhereClause, determineUsernameField, getNestedValue, toMs, } from "./utils/helpers/auth.controller.helpers.js";
|
|
8
8
|
export const defaultExcludedUserFields = {
|
|
9
9
|
password: false,
|
|
10
10
|
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Router } from "express";
|
|
2
|
-
import { authControllerFactory } from "./auth.controller";
|
|
3
|
-
import authService from "./auth.service";
|
|
2
|
+
import { authControllerFactory } from "./auth.controller.js";
|
|
3
|
+
import authService from "./auth.service.js";
|
|
4
4
|
import rateLimit from "express-rate-limit";
|
|
5
|
-
import { importPrismaModelModules } from "../../utils/helpers/models.helpers";
|
|
6
|
-
import { addPrismaQueryOptionsToRequest, handleRequestBodyValidationAndTransformation, sendResponse, } from "../base/base.middlewares";
|
|
7
|
-
import deepmerge from "../../utils/helpers/deepmerge.helper";
|
|
8
|
-
import catchAsync from "../error-handler/utils/catch-async";
|
|
5
|
+
import { importPrismaModelModules } from "../../utils/helpers/models.helpers.js";
|
|
6
|
+
import { addPrismaQueryOptionsToRequest, handleRequestBodyValidationAndTransformation, sendResponse, } from "../base/base.middlewares.js";
|
|
7
|
+
import deepmerge from "../../utils/helpers/deepmerge.helper.js";
|
|
8
|
+
import catchAsync from "../error-handler/utils/catch-async.js";
|
|
9
9
|
const router = Router();
|
|
10
10
|
export async function getAuthRouter(arkosConfigs) {
|
|
11
11
|
const { middlewares, dtos, schemas, prismaQueryOptions } = await importPrismaModelModules("auth");
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import jwt from "jsonwebtoken";
|
|
2
2
|
import bcrypt from "bcryptjs";
|
|
3
|
-
import catchAsync from "../error-handler/utils/catch-async";
|
|
4
|
-
import AppError from "../error-handler/utils/app-error";
|
|
5
|
-
import { callNext } from "../base/base.middlewares";
|
|
6
|
-
import { getArkosConfig } from "../../server";
|
|
7
|
-
import arkosEnv from "../../utils/arkos-env";
|
|
8
|
-
import { getPrismaInstance } from "../../utils/helpers/prisma.helpers";
|
|
3
|
+
import catchAsync from "../error-handler/utils/catch-async.js";
|
|
4
|
+
import AppError from "../error-handler/utils/app-error.js";
|
|
5
|
+
import { callNext } from "../base/base.middlewares.js";
|
|
6
|
+
import { getArkosConfig } from "../../server.js";
|
|
7
|
+
import arkosEnv from "../../utils/arkos-env.js";
|
|
8
|
+
import { getPrismaInstance } from "../../utils/helpers/prisma.helpers.js";
|
|
9
9
|
export class AuthService {
|
|
10
10
|
constructor() {
|
|
11
11
|
this.authenticate = catchAsync(async (req, res, next) => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { getArkosConfig } from "../../../../server";
|
|
2
|
-
import AppError from "../../../error-handler/utils/app-error";
|
|
1
|
+
import { getArkosConfig } from "../../../../server.js";
|
|
2
|
+
import AppError from "../../../error-handler/utils/app-error.js";
|
|
3
3
|
export const determineUsernameField = (req) => {
|
|
4
4
|
const authConfigs = getArkosConfig()?.authentication;
|
|
5
5
|
if (req.query?.usernameField &&
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import catchAsync from "../error-handler/utils/catch-async";
|
|
2
|
-
import APIFeatures from "../../utils/features/api.features";
|
|
3
|
-
import { BaseService } from "./base.service";
|
|
4
|
-
import AppError from "../error-handler/utils/app-error";
|
|
5
|
-
import { kebabCase, pascalCase } from "../../utils/helpers/change-case.helpers";
|
|
6
|
-
import { getModelModules, getModels } from "../../utils/helpers/models.helpers";
|
|
7
|
-
import { getAppRoutes } from "./utils/helpers/base.controller.helpers";
|
|
1
|
+
import catchAsync from "../error-handler/utils/catch-async.js";
|
|
2
|
+
import APIFeatures from "../../utils/features/api.features.js";
|
|
3
|
+
import { BaseService } from "./base.service.js";
|
|
4
|
+
import AppError from "../error-handler/utils/app-error.js";
|
|
5
|
+
import { kebabCase, pascalCase } from "../../utils/helpers/change-case.helpers.js";
|
|
6
|
+
import { getModelModules, getModels } from "../../utils/helpers/models.helpers.js";
|
|
7
|
+
import { getAppRoutes } from "./utils/helpers/base.controller.helpers.js";
|
|
8
8
|
import pluralize from "pluralize";
|
|
9
9
|
export class BaseController {
|
|
10
10
|
constructor(modelName) {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { getArkosConfig } from "../../server";
|
|
2
|
-
import deepmerge from "../../utils/helpers/deepmerge.helper";
|
|
3
|
-
import { catchAsync } from "../../exports/error-handler";
|
|
4
|
-
import validateDto from "../../utils/validate-dto";
|
|
5
|
-
import validateSchema from "../../utils/validate-schema";
|
|
6
|
-
import { resolvePrismaQueryOptions } from "./utils/helpers/base.middlewares.helpers";
|
|
1
|
+
import { getArkosConfig } from "../../server.js";
|
|
2
|
+
import deepmerge from "../../utils/helpers/deepmerge.helper.js";
|
|
3
|
+
import { catchAsync } from "../../exports/error-handler/index.js";
|
|
4
|
+
import validateDto from "../../utils/validate-dto.js";
|
|
5
|
+
import validateSchema from "../../utils/validate-schema.js";
|
|
6
|
+
import { resolvePrismaQueryOptions } from "./utils/helpers/base.middlewares.helpers.js";
|
|
7
7
|
export function callNext(req, res, next) {
|
|
8
8
|
next();
|
|
9
9
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Router } from "express";
|
|
2
|
-
import { getAvalibleRoutes, getAvailableResources } from "./base.controller";
|
|
3
|
-
import { getModels } from "../../utils/helpers/models.helpers";
|
|
4
|
-
import authService from "../auth/auth.service";
|
|
5
|
-
import { setupRouters } from "./utils/helpers/base.router.helpers";
|
|
2
|
+
import { getAvalibleRoutes, getAvailableResources } from "./base.controller.js";
|
|
3
|
+
import { getModels } from "../../utils/helpers/models.helpers.js";
|
|
4
|
+
import authService from "../auth/auth.service.js";
|
|
5
|
+
import { setupRouters } from "./utils/helpers/base.router.helpers.js";
|
|
6
6
|
export async function getPrismaModelsRouter(arkosConfigs) {
|
|
7
7
|
const router = Router();
|
|
8
8
|
await Promise.all(setupRouters(getModels(), router, arkosConfigs));
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { camelCase, kebabCase, pascalCase, } from "../../utils/helpers/change-case.helpers";
|
|
2
|
-
import { getModels, getPrismaModelRelations, } from "../../utils/helpers/models.helpers";
|
|
3
|
-
import deepmerge from "../../utils/helpers/deepmerge.helper";
|
|
4
|
-
import { handleRelationFieldsInBody } from "./utils/helpers/base.service.helpers";
|
|
5
|
-
import { getPrismaInstance } from "../../utils/helpers/prisma.helpers";
|
|
6
|
-
import authService from "../auth/auth.service";
|
|
1
|
+
import { camelCase, kebabCase, pascalCase, } from "../../utils/helpers/change-case.helpers.js";
|
|
2
|
+
import { getModels, getPrismaModelRelations, } from "../../utils/helpers/models.helpers.js";
|
|
3
|
+
import deepmerge from "../../utils/helpers/deepmerge.helper.js";
|
|
4
|
+
import { handleRelationFieldsInBody } from "./utils/helpers/base.service.helpers.js";
|
|
5
|
+
import { getPrismaInstance } from "../../utils/helpers/prisma.helpers.js";
|
|
6
|
+
import authService from "../auth/auth.service.js";
|
|
7
7
|
export class BaseService {
|
|
8
8
|
constructor(modelName) {
|
|
9
9
|
this.modelName = camelCase(modelName);
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import pluralize from "pluralize";
|
|
2
|
-
import { kebabCase } from "../../../../exports/utils";
|
|
3
|
-
import { importPrismaModelModules } from "../../../../utils/helpers/models.helpers";
|
|
4
|
-
import authService from "../../../auth/auth.service";
|
|
5
|
-
import { BaseController } from "../../base.controller";
|
|
6
|
-
import { addPrismaQueryOptionsToRequest, handleRequestBodyValidationAndTransformation, sendResponse, } from "../../base.middlewares";
|
|
7
|
-
import catchAsync from "../../../error-handler/utils/catch-async";
|
|
2
|
+
import { kebabCase } from "../../../../exports/utils/index.js";
|
|
3
|
+
import { importPrismaModelModules } from "../../../../utils/helpers/models.helpers.js";
|
|
4
|
+
import authService from "../../../auth/auth.service.js";
|
|
5
|
+
import { BaseController } from "../../base.controller.js";
|
|
6
|
+
import { addPrismaQueryOptionsToRequest, handleRequestBodyValidationAndTransformation, sendResponse, } from "../../base.middlewares.js";
|
|
7
|
+
import catchAsync from "../../../error-handler/utils/catch-async.js";
|
|
8
8
|
export function setupRouters(models, router, arkosConfigs) {
|
|
9
9
|
return models.map(async (model) => {
|
|
10
10
|
const modelNameInKebab = kebabCase(model);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getPrismaModelRelations, getModelUniqueFields, } from "../../../../utils/helpers/models.helpers";
|
|
1
|
+
import { getPrismaModelRelations, getModelUniqueFields, } from "../../../../utils/helpers/models.helpers.js";
|
|
2
2
|
export function removeApiAction(obj) {
|
|
3
3
|
if (!obj || typeof obj !== "object")
|
|
4
4
|
return obj;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import nodemailer from "nodemailer";
|
|
2
2
|
import { convert } from "html-to-text";
|
|
3
|
-
import { getArkosConfig } from "../../server";
|
|
4
|
-
import AppError from "../error-handler/utils/app-error";
|
|
3
|
+
import { getArkosConfig } from "../../server.js";
|
|
4
|
+
import AppError from "../error-handler/utils/app-error.js";
|
|
5
5
|
export class EmailService {
|
|
6
6
|
constructor(config) {
|
|
7
7
|
this.transporter = null;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import AppError from "./utils/app-error";
|
|
2
|
-
import * as errorControllerHelper from "./utils/error-handler.helpers";
|
|
3
|
-
import { server } from "../../server";
|
|
1
|
+
import AppError from "./utils/app-error.js";
|
|
2
|
+
import * as errorControllerHelper from "./utils/error-handler.helpers.js";
|
|
3
|
+
import { server } from "../../server.js";
|
|
4
4
|
export default function errorHandler(err, req, res, next) {
|
|
5
5
|
console.error("[\x1b[31mERROR\x1b[0m]:", err);
|
|
6
6
|
err.statusCode = err.statusCode || 500;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import AppError from "../error-handler/utils/app-error";
|
|
2
|
-
import { getFileUploadServices, } from "./file-upload.service";
|
|
1
|
+
import AppError from "../error-handler/utils/app-error.js";
|
|
2
|
+
import { getFileUploadServices, } from "./file-upload.service.js";
|
|
3
3
|
import path from "path";
|
|
4
4
|
import fs from "fs";
|
|
5
|
-
import catchAsync from "../error-handler/utils/catch-async";
|
|
6
|
-
import { getArkosConfig } from "../../server";
|
|
7
|
-
import { processFile, processImage } from "./utils/helpers/file-upload.helpers";
|
|
8
|
-
import { accessAsync, mkdirAsync, statAsync, } from "../../utils/helpers/fs.helpers";
|
|
9
|
-
import { getModelModules } from "../../utils/helpers/models.helpers";
|
|
5
|
+
import catchAsync from "../error-handler/utils/catch-async.js";
|
|
6
|
+
import { getArkosConfig } from "../../server.js";
|
|
7
|
+
import { processFile, processImage } from "./utils/helpers/file-upload.helpers.js";
|
|
8
|
+
import { accessAsync, mkdirAsync, statAsync, } from "../../utils/helpers/fs.helpers.js";
|
|
9
|
+
import { getModelModules } from "../../utils/helpers/models.helpers.js";
|
|
10
10
|
class FileUploadController {
|
|
11
11
|
constructor() {
|
|
12
12
|
this.uploadFile = catchAsync(async (req, res, next) => {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Router } from "express";
|
|
2
|
-
import { importPrismaModelModules } from "../../utils/helpers/models.helpers";
|
|
3
|
-
import authService from "../auth/auth.service";
|
|
4
|
-
import fileUploadController from "./file-upload.controller";
|
|
2
|
+
import { importPrismaModelModules } from "../../utils/helpers/models.helpers.js";
|
|
3
|
+
import authService from "../auth/auth.service.js";
|
|
4
|
+
import fileUploadController from "./file-upload.controller.js";
|
|
5
5
|
import path from "path";
|
|
6
6
|
import express from "express";
|
|
7
|
-
import deepmerge from "../../utils/helpers/deepmerge.helper";
|
|
8
|
-
import { sendResponse } from "../base/base.middlewares";
|
|
7
|
+
import deepmerge from "../../utils/helpers/deepmerge.helper.js";
|
|
8
|
+
import { sendResponse } from "../base/base.middlewares.js";
|
|
9
9
|
const router = Router();
|
|
10
10
|
export async function getFileUploadRouter({ fileUpload }) {
|
|
11
11
|
const modelModules = await importPrismaModelModules("file-upload");
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import multer from "multer";
|
|
2
2
|
import path from "path";
|
|
3
3
|
import fs from "fs";
|
|
4
|
-
import AppError from "../error-handler/utils/app-error";
|
|
4
|
+
import AppError from "../error-handler/utils/app-error.js";
|
|
5
5
|
import { promisify } from "util";
|
|
6
|
-
import { getArkosConfig } from "../../server";
|
|
7
|
-
import deepmerge from "../../utils/helpers/deepmerge.helper";
|
|
8
|
-
import { processFile, processImage } from "./utils/helpers/file-upload.helpers";
|
|
9
|
-
import { removeBothSlashes } from "../../utils/helpers/text.helpers";
|
|
6
|
+
import { getArkosConfig } from "../../server.js";
|
|
7
|
+
import deepmerge from "../../utils/helpers/deepmerge.helper.js";
|
|
8
|
+
import { processFile, processImage } from "./utils/helpers/file-upload.helpers.js";
|
|
9
|
+
import { removeBothSlashes } from "../../utils/helpers/text.helpers.js";
|
|
10
10
|
export class FileUploadService {
|
|
11
11
|
constructor(uploadDir, fileSizeLimit = 1024 * 1024 * 5, allowedFileTypes = /.*/, maxCount = 30) {
|
|
12
12
|
this.fileFilter = (req, file, cb) => {
|
|
@@ -2,9 +2,9 @@ import fs from "fs";
|
|
|
2
2
|
import path from "path";
|
|
3
3
|
import sharp from "sharp";
|
|
4
4
|
import { promisify } from "util";
|
|
5
|
-
import { getArkosConfig } from "../../../../server";
|
|
5
|
+
import { getArkosConfig } from "../../../../server.js";
|
|
6
6
|
import mimetype from "mimetype";
|
|
7
|
-
import { fullCleanCwd } from "../../../../utils/helpers/fs.helpers";
|
|
7
|
+
import { fullCleanCwd } from "../../../../utils/helpers/fs.helpers.js";
|
|
8
8
|
export function extractRequestInfo(req) {
|
|
9
9
|
const { fileUpload } = getArkosConfig();
|
|
10
10
|
const protocol = req.headers["x-forwarded-proto"] === "https" ? "https" : "http";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Router } from "express";
|
|
2
2
|
import swaggerUi from "swagger-ui-express";
|
|
3
3
|
import swaggerJsdoc from "swagger-jsdoc";
|
|
4
|
-
import deepmerge from "../../utils/helpers/deepmerge.helper";
|
|
5
|
-
import { generatePathsForModels, getOpenAPIJsonSchemasByConfigMode, } from "./utils/helpers/swagger.router.helpers";
|
|
4
|
+
import deepmerge from "../../utils/helpers/deepmerge.helper.js";
|
|
5
|
+
import { generatePathsForModels, getOpenAPIJsonSchemasByConfigMode, } from "./utils/helpers/swagger.router.helpers.js";
|
|
6
6
|
const swaggerRouter = Router();
|
|
7
7
|
export async function getSwaggerRouter(arkosConfig) {
|
|
8
8
|
const defaultJsonSchemas = await getOpenAPIJsonSchemasByConfigMode(arkosConfig.swagger);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { getSchemaRef } from "./swagger.router.helpers";
|
|
2
|
-
import { getArkosConfig } from "../../../../server";
|
|
1
|
+
import { getSchemaRef } from "./swagger.router.helpers.js";
|
|
2
|
+
import { getArkosConfig } from "../../../../server.js";
|
|
3
3
|
export function getAuthenticationJsonSchemaPaths() {
|
|
4
4
|
const mode = getArkosConfig().swagger?.mode;
|
|
5
5
|
const paths = {};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { validationMetadatasToSchemas } from "class-validator-jsonschema";
|
|
2
|
-
import { importModule } from "../../../../../utils/helpers/global.helpers";
|
|
2
|
+
import { importModule } from "../../../../../utils/helpers/global.helpers.js";
|
|
3
3
|
import { getMetadataStorage } from "class-validator";
|
|
4
|
-
import { getModelModules, getModels, } from "../../../../../utils/helpers/models.helpers";
|
|
5
|
-
import { getCorrectJsonSchemaName } from "../swagger.router.helpers";
|
|
4
|
+
import { getModelModules, getModels, } from "../../../../../utils/helpers/models.helpers.js";
|
|
5
|
+
import { getCorrectJsonSchemaName } from "../swagger.router.helpers.js";
|
|
6
6
|
export async function generateClassValidatorJsonSchemas() {
|
|
7
7
|
const models = getModels();
|
|
8
8
|
const schemas = {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { pascalCase } from "../../../../../exports/utils";
|
|
2
|
-
import { getModels, getPrismaSchemasContent, } from "../../../../../utils/helpers/models.helpers";
|
|
1
|
+
import { pascalCase } from "../../../../../exports/utils/index.js";
|
|
2
|
+
import { getModels, getPrismaSchemasContent, } from "../../../../../utils/helpers/models.helpers.js";
|
|
3
3
|
export async function generatePrismaJsonSchemas() {
|
|
4
4
|
const schemas = {};
|
|
5
5
|
const prismaContent = getPrismaSchemasContent();
|
package/dist/esm/modules/swagger/utils/helpers/json-schema-generators/generate-zod-json-schema.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { getModelModules, getModels, } from "../../../../../utils/helpers/models.helpers";
|
|
1
|
+
import { getModelModules, getModels, } from "../../../../../utils/helpers/models.helpers.js";
|
|
2
2
|
import zodToJsonSchema from "zod-to-json-schema";
|
|
3
|
-
import { getCorrectJsonSchemaName } from "../swagger.router.helpers";
|
|
3
|
+
import { getCorrectJsonSchemaName } from "../swagger.router.helpers.js";
|
|
4
4
|
export async function generateZodJsonSchemas() {
|
|
5
5
|
const models = [...getModels(), "file-upload", "auth"];
|
|
6
6
|
const schemas = {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { getSchemaRef } from "../../swagger.router.helpers";
|
|
1
|
+
import { getSchemaRef } from "../../swagger.router.helpers.js";
|
|
2
2
|
import pluralize from "pluralize";
|
|
3
|
-
import { isEndpointDisabled } from "../../../../../base/utils/helpers/base.router.helpers";
|
|
3
|
+
import { isEndpointDisabled } from "../../../../../base/utils/helpers/base.router.helpers.js";
|
|
4
4
|
export async function generatePrismaModelMainRoutesPaths(paths, routeName, pascalModelName, humanReadableName, humanReadableNamePlural, routerConfig, mode) {
|
|
5
5
|
if (!isEndpointDisabled(routerConfig, "createOne")) {
|
|
6
6
|
if (!paths[`/api/${routeName}`])
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import pluralize from "pluralize";
|
|
2
|
-
import { kebabCase, pascalCase } from "../../../../../../exports/utils";
|
|
3
|
-
import { getSchemaRef, kebabToHuman } from "../../swagger.router.helpers";
|
|
4
|
-
import { isParentEndpointAllowed } from "../../../../../base/utils/helpers/base.router.helpers";
|
|
2
|
+
import { kebabCase, pascalCase } from "../../../../../../exports/utils/index.js";
|
|
3
|
+
import { getSchemaRef, kebabToHuman } from "../../swagger.router.helpers.js";
|
|
4
|
+
import { isParentEndpointAllowed } from "../../../../../base/utils/helpers/base.router.helpers.js";
|
|
5
5
|
export async function generatePrismaModelParentRoutePaths(paths, routeName, pascalModelName, humanReadableName, humanReadableNamePlural, routerConfig, mode) {
|
|
6
6
|
const parentModel = routerConfig.parent.model;
|
|
7
7
|
const parentRouteName = pluralize.plural(kebabCase(parentModel));
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { getModels, importPrismaModelModules, } from "../../../../utils/helpers/models.helpers";
|
|
2
|
-
import { kebabCase, pascalCase } from "../../../../exports/utils";
|
|
1
|
+
import { getModels, importPrismaModelModules, } from "../../../../utils/helpers/models.helpers.js";
|
|
2
|
+
import { kebabCase, pascalCase } from "../../../../exports/utils/index.js";
|
|
3
3
|
import pluralize from "pluralize";
|
|
4
|
-
import { getSystemJsonSchemaPaths } from "./get-system-json-schema-paths";
|
|
5
|
-
import { getAuthenticationJsonSchemaPaths } from "./get-authentication-json-schema-paths";
|
|
6
|
-
import { generateZodJsonSchemas } from "./json-schema-generators/generate-zod-json-schema";
|
|
7
|
-
import { generateClassValidatorJsonSchemas } from "./json-schema-generators/generate-class-validator-json-schemas";
|
|
8
|
-
import { generatePrismaJsonSchemas } from "./json-schema-generators/generate-prisma-json-schemas";
|
|
9
|
-
import { generatePrismaModelMainRoutesPaths } from "./json-schema-generators/prisma-models/generate-prisma-model-main-routes";
|
|
10
|
-
import { generatePrismaModelParentRoutePaths } from "./json-schema-generators/prisma-models/generate-prisma-model-parent-routes";
|
|
4
|
+
import { getSystemJsonSchemaPaths } from "./get-system-json-schema-paths.js";
|
|
5
|
+
import { getAuthenticationJsonSchemaPaths } from "./get-authentication-json-schema-paths.js";
|
|
6
|
+
import { generateZodJsonSchemas } from "./json-schema-generators/generate-zod-json-schema.js";
|
|
7
|
+
import { generateClassValidatorJsonSchemas } from "./json-schema-generators/generate-class-validator-json-schemas.js";
|
|
8
|
+
import { generatePrismaJsonSchemas } from "./json-schema-generators/generate-prisma-json-schemas.js";
|
|
9
|
+
import { generatePrismaModelMainRoutesPaths } from "./json-schema-generators/prisma-models/generate-prisma-model-main-routes.js";
|
|
10
|
+
import { generatePrismaModelParentRoutePaths } from "./json-schema-generators/prisma-models/generate-prisma-model-parent-routes.js";
|
|
11
11
|
export async function getOpenAPIJsonSchemasByConfigMode(swaggerConfig) {
|
|
12
12
|
switch (swaggerConfig.mode) {
|
|
13
13
|
case "prisma":
|
package/dist/esm/server.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";import{bootstrap as a}from"./app";import p from"./utils/helpers/deepmerge.helper";import c from"http";import s from"./utils/sheu";import{initializePrismaModels as l}from"./utils/helpers/models.helpers";process.on("uncaughtException",o=>{o.message.includes("EPIPE")||(console.error(`
|
|
1
|
+
"use strict";import{bootstrap as a}from"./app.js";import p from"./utils/helpers/deepmerge.helper.js";import c from"http";import s from"./utils/sheu.js";import{initializePrismaModels as l}from"./utils/helpers/models.helpers.js";process.on("uncaughtException",o=>{o.message.includes("EPIPE")||(console.error(`
|
|
2
2
|
UNCAUGHT EXCEPTION! SHUTTING DOWN...
|
|
3
3
|
`),console.error(o.name,o.message),console.error(o),process.exit(1))});let r,t,e={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 u(o={}){l(),e.available=!0,e=p(e,o);const n=process.env.CLI_PORT||e.port||process.env.PORT||"port"in e?e.port:8e3;t=await a(e);const i=new Date().toTimeString().split(" ")[0];return n?(r=c.createServer(t),e?.configureServer&&await e.configureServer(r),r.listen(Number(n),e.host,()=>{s.ready(`${s.gray(i)} server waiting on http://${e.host||"localhost"}:${n}`)})):s.warn(`${s.gray(i)} port set to undefined, hence no internal http server was setup.`),t}process.on("unhandledRejection",o=>{console.error("UNHANDLED REJECTION! SHUTTING DOWN..."),console.error(o.name,o.message),console.error(o),r?.close(()=>{process.exit(1)})});export function terminateApplicationRunningProcessAndServer(){r?.close(()=>{process.exit(1)})}export function getArkosConfig(){return e}export function getExpressApp(){return t}export{r as server,u as initApp};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import path from "path";
|
|
2
2
|
import fs from "fs";
|
|
3
3
|
import { execSync } from "child_process";
|
|
4
|
-
import { fullCleanCwd, getUserFileExtension } from "../helpers/fs.helpers";
|
|
5
|
-
import { loadEnvironmentVariables } from "../dotenv.helpers";
|
|
6
|
-
import { getVersion } from "./utils/cli.helpers";
|
|
7
|
-
import { detectPackageManagerFromUserAgent } from "../helpers/global.helpers";
|
|
4
|
+
import { fullCleanCwd, getUserFileExtension } from "../helpers/fs.helpers.js";
|
|
5
|
+
import { loadEnvironmentVariables } from "../dotenv.helpers.js";
|
|
6
|
+
import { getVersion } from "./utils/cli.helpers.js";
|
|
7
|
+
import { detectPackageManagerFromUserAgent } from "../helpers/global.helpers.js";
|
|
8
8
|
const BUILD_DIR = ".build";
|
|
9
9
|
const MODULE_TYPES = ["cjs", "esm"];
|
|
10
10
|
export function buildCommand(options = {}) {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { spawn } from "child_process";
|
|
2
2
|
import { watch } from "chokidar";
|
|
3
|
-
import { fullCleanCwd, getUserFileExtension } from "../helpers/fs.helpers";
|
|
4
|
-
import { getVersion } from "./utils/cli.helpers";
|
|
5
|
-
import { loadEnvironmentVariables } from "../dotenv.helpers";
|
|
6
|
-
import { importModule } from "../helpers/global.helpers";
|
|
3
|
+
import { fullCleanCwd, getUserFileExtension } from "../helpers/fs.helpers.js";
|
|
4
|
+
import { getVersion } from "./utils/cli.helpers.js";
|
|
5
|
+
import { loadEnvironmentVariables } from "../dotenv.helpers.js";
|
|
6
|
+
import { importModule } from "../helpers/global.helpers.js";
|
|
7
7
|
import fs from "fs";
|
|
8
8
|
import path from "path";
|
|
9
|
-
import sheu from "../sheu";
|
|
9
|
+
import sheu from "../sheu.js";
|
|
10
10
|
let child = null;
|
|
11
11
|
let envFiles;
|
|
12
12
|
export async function devCommand(options = {}) {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import fs from "fs";
|
|
2
2
|
import path from "path";
|
|
3
|
-
import { generateTemplate } from "./utils/template-generators";
|
|
4
|
-
import { ensureDirectoryExists } from "./utils/cli.helpers";
|
|
5
|
-
import { camelCase, kebabCase, pascalCase, } from "../helpers/change-case.helpers";
|
|
6
|
-
import { getUserFileExtension } from "../helpers/fs.helpers";
|
|
3
|
+
import { generateTemplate } from "./utils/template-generators.js";
|
|
4
|
+
import { ensureDirectoryExists } from "./utils/cli.helpers.js";
|
|
5
|
+
import { camelCase, kebabCase, pascalCase, } from "../helpers/change-case.helpers.js";
|
|
6
|
+
import { getUserFileExtension } from "../helpers/fs.helpers.js";
|
|
7
7
|
export const generateCommand = {
|
|
8
8
|
controller: async (options) => {
|
|
9
9
|
const modelName = options.model;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Command } from "commander";
|
|
2
|
-
import { buildCommand } from "./build";
|
|
3
|
-
import { devCommand } from "./dev";
|
|
4
|
-
import { startCommand } from "./start";
|
|
5
|
-
import { generateCommand } from "./generate";
|
|
6
|
-
import { getVersion } from "./utils/cli.helpers";
|
|
2
|
+
import { buildCommand } from "./build.js";
|
|
3
|
+
import { devCommand } from "./dev.js";
|
|
4
|
+
import { startCommand } from "./start.js";
|
|
5
|
+
import { generateCommand } from "./generate.js";
|
|
6
|
+
import { getVersion } from "./utils/cli.helpers.js";
|
|
7
7
|
const program = new Command();
|
|
8
8
|
program.name("arkos").description("Arkos.js CLI").version(getVersion());
|
|
9
9
|
program
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import path from "path";
|
|
2
2
|
import fs from "fs";
|
|
3
3
|
import { spawn } from "child_process";
|
|
4
|
-
import { getVersion } from "./utils/cli.helpers";
|
|
5
|
-
import { loadEnvironmentVariables } from "../dotenv.helpers";
|
|
6
|
-
import { importModule } from "../helpers/global.helpers";
|
|
7
|
-
import { fullCleanCwd } from "../helpers/fs.helpers";
|
|
4
|
+
import { getVersion } from "./utils/cli.helpers.js";
|
|
5
|
+
import { loadEnvironmentVariables } from "../dotenv.helpers.js";
|
|
6
|
+
import { importModule } from "../helpers/global.helpers.js";
|
|
7
|
+
import { fullCleanCwd } from "../helpers/fs.helpers.js";
|
|
8
8
|
let child = null;
|
|
9
9
|
let envFiles;
|
|
10
10
|
export async function startCommand(options = {}) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import fs from "fs";
|
|
2
|
-
import { killDevelopmentServerChildProcess } from "../dev";
|
|
3
|
-
import { killProductionServerChildProcess } from "../start";
|
|
2
|
+
import { killDevelopmentServerChildProcess } from "../dev.js";
|
|
3
|
+
import { killProductionServerChildProcess } from "../start.js";
|
|
4
4
|
import path from "path";
|
|
5
5
|
export function ensureDirectoryExists(dirPath) {
|
|
6
6
|
if (!fs.existsSync(dirPath)) {
|
package/dist/esm/utils/cli/utils/template-generator/templates/generate-auth-configs-template.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getUserFileExtension } from "../../../../helpers/fs.helpers";
|
|
1
|
+
import { getUserFileExtension } from "../../../../helpers/fs.helpers.js";
|
|
2
2
|
export function generateAuthConfigsTemplate(options) {
|
|
3
3
|
const { modelName } = options;
|
|
4
4
|
const ext = getUserFileExtension();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getUserFileExtension } from "../../../../helpers/fs.helpers";
|
|
1
|
+
import { getUserFileExtension } from "../../../../helpers/fs.helpers.js";
|
|
2
2
|
export function generateMiddlewaresTemplate(options) {
|
|
3
3
|
const { modelName } = options;
|
|
4
4
|
const ext = getUserFileExtension();
|
package/dist/esm/utils/cli/utils/template-generator/templates/generate-prisma-query-options.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getUserFileExtension } from "../../../../helpers/fs.helpers";
|
|
1
|
+
import { getUserFileExtension } from "../../../../helpers/fs.helpers.js";
|
|
2
2
|
export function generateQueryOptionsTemplate(options) {
|
|
3
3
|
const { modelName } = options;
|
|
4
4
|
const isAuth = modelName?.camel === "auth";
|
|
@@ -15,7 +15,7 @@ export function generateQueryOptionsTemplate(options) {
|
|
|
15
15
|
: `: PrismaQueryOptions<typeof prisma.${modelName.camel}>`
|
|
16
16
|
: "";
|
|
17
17
|
const prismaImport = isTypeScript
|
|
18
|
-
? `import { prisma } from "../../utils/prisma";\n`
|
|
18
|
+
? `import { prisma } from "../../utils/prisma.js";\n`
|
|
19
19
|
: "";
|
|
20
20
|
if (isAuth) {
|
|
21
21
|
return `${prismaImport}${imports};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import pluralize from "pluralize";
|
|
2
|
-
import { checkFileExists, getUserFileExtension, } from "../../../../helpers/fs.helpers";
|
|
2
|
+
import { checkFileExists, getUserFileExtension, } from "../../../../helpers/fs.helpers.js";
|
|
3
3
|
export function generateRouterTemplate(options) {
|
|
4
4
|
const { modelName, imports } = options;
|
|
5
5
|
if (!modelName)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getUserFileExtension } from "../../../../helpers/fs.helpers";
|
|
1
|
+
import { getUserFileExtension } from "../../../../helpers/fs.helpers.js";
|
|
2
2
|
export function generateServiceTemplate(options) {
|
|
3
3
|
const { modelName, imports } = options;
|
|
4
4
|
const ext = getUserFileExtension();
|
|
@@ -6,7 +6,7 @@ export function generateServiceTemplate(options) {
|
|
|
6
6
|
if (!modelName)
|
|
7
7
|
throw new Error("Model name is required for service template");
|
|
8
8
|
const prismaImport = isTypeScript
|
|
9
|
-
? `import { prisma } from "../../utils/prisma";\n`
|
|
9
|
+
? `import { prisma } from "../../utils/prisma.js";\n`
|
|
10
10
|
: "";
|
|
11
11
|
const baseServiceImport = isTypeScript
|
|
12
12
|
? `import { BaseService } from "${imports?.baseService || "arkos/services"}";`
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { generateControllerTemplate } from "./template-generator/templates/generate-controller-template";
|
|
2
|
-
import { generateAuthConfigsTemplate } from "./template-generator/templates/generate-auth-configs-template";
|
|
3
|
-
import { generateMiddlewaresTemplate } from "./template-generator/templates/generate-middlewares";
|
|
4
|
-
import { generateQueryOptionsTemplate } from "./template-generator/templates/generate-prisma-query-options";
|
|
5
|
-
import { generateRouterTemplate } from "./template-generator/templates/generate-router-template";
|
|
6
|
-
import { generateServiceTemplate } from "./template-generator/templates/generate-service-template";
|
|
1
|
+
import { generateControllerTemplate } from "./template-generator/templates/generate-controller-template.js";
|
|
2
|
+
import { generateAuthConfigsTemplate } from "./template-generator/templates/generate-auth-configs-template.js";
|
|
3
|
+
import { generateMiddlewaresTemplate } from "./template-generator/templates/generate-middlewares.js";
|
|
4
|
+
import { generateQueryOptionsTemplate } from "./template-generator/templates/generate-prisma-query-options.js";
|
|
5
|
+
import { generateRouterTemplate } from "./template-generator/templates/generate-router-template.js";
|
|
6
|
+
import { generateServiceTemplate } from "./template-generator/templates/generate-service-template.js";
|
|
7
7
|
export function generateTemplate(type, options) {
|
|
8
8
|
switch (type) {
|
|
9
9
|
case "controller":
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import deepmerge from "../helpers/deepmerge.helper";
|
|
2
|
-
import { parseQueryParamsWithModifiers } from "../helpers/api.features.helpers";
|
|
3
|
-
import AppError from "../../modules/error-handler/utils/app-error";
|
|
4
|
-
import { getPrismaInstance } from "../helpers/prisma.helpers";
|
|
1
|
+
import deepmerge from "../helpers/deepmerge.helper.js";
|
|
2
|
+
import { parseQueryParamsWithModifiers } from "../helpers/api.features.helpers.js";
|
|
3
|
+
import AppError from "../../modules/error-handler/utils/app-error.js";
|
|
4
|
+
import { getPrismaInstance } from "../helpers/prisma.helpers.js";
|
|
5
5
|
export default class APIFeatures {
|
|
6
6
|
constructor(req, modelName) {
|
|
7
7
|
this.filters = {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as changeCase from "../helpers/change-case.helpers";
|
|
1
|
+
import * as changeCase from "../helpers/change-case.helpers.js";
|
|
2
2
|
const isObject = (object) => object !== null && typeof object === "object";
|
|
3
3
|
function changeKeysFactory(changeCase) {
|
|
4
4
|
return function changeKeys(object, depth = 1, options) {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import path from "path";
|
|
2
2
|
import fs from "fs";
|
|
3
|
-
import { camelCase, kebabCase, pascalCase, } from "../../utils/helpers/change-case.helpers";
|
|
4
|
-
import { crd, getUserFileExtension } from "./fs.helpers";
|
|
5
|
-
import { importModule } from "./global.helpers";
|
|
6
|
-
import { killServerChildProcess } from "../cli/utils/cli.helpers";
|
|
3
|
+
import { camelCase, kebabCase, pascalCase, } from "../../utils/helpers/change-case.helpers.js";
|
|
4
|
+
import { crd, getUserFileExtension } from "./fs.helpers.js";
|
|
5
|
+
import { importModule } from "./global.helpers.js";
|
|
6
|
+
import { killServerChildProcess } from "../cli/utils/cli.helpers.js";
|
|
7
7
|
let prismaModelsModules = {};
|
|
8
8
|
export function getModelModules(modelName) {
|
|
9
9
|
return prismaModelsModules[kebabCase(modelName)];
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import fs from "fs";
|
|
2
|
-
import catchAsync from "../../modules/error-handler/utils/catch-async";
|
|
3
|
-
import AppError from "../../modules/error-handler/utils/app-error";
|
|
4
|
-
import { crd, getUserFileExtension as ext } from "./fs.helpers";
|
|
5
|
-
import { importModule } from "./global.helpers";
|
|
2
|
+
import catchAsync from "../../modules/error-handler/utils/catch-async.js";
|
|
3
|
+
import AppError from "../../modules/error-handler/utils/app-error.js";
|
|
4
|
+
import { crd, getUserFileExtension as ext } from "./fs.helpers.js";
|
|
5
|
+
import { importModule } from "./global.helpers.js";
|
|
6
6
|
export let prismaInstance = null;
|
|
7
7
|
export async function loadPrismaModule() {
|
|
8
8
|
if (!prismaInstance) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { plainToInstance } from "class-transformer";
|
|
2
2
|
import { validate } from "class-validator";
|
|
3
|
-
import AppError from "../modules/error-handler/utils/app-error";
|
|
3
|
+
import AppError from "../modules/error-handler/utils/app-error.js";
|
|
4
4
|
export default async function validateDto(DtoClass, data, validationOptions) {
|
|
5
5
|
const dataDto = plainToInstance(DtoClass, data);
|
|
6
6
|
const errors = await validate(dataDto, validationOptions);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "arkos",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.21-test",
|
|
4
4
|
"description": "The Express & Prisma Framework For RESTful API",
|
|
5
5
|
"main": "dist/cjs/exports/index.js",
|
|
6
6
|
"module": "dist/esm/exports/index.js",
|
|
@@ -94,6 +94,7 @@
|
|
|
94
94
|
"test:create": "ts-node src/scripts/create-test.ts",
|
|
95
95
|
"publish:test": "npm publish --tag test",
|
|
96
96
|
"publish:beta": "npm publish --tag beta",
|
|
97
|
+
"publish:betaAsLatest": "npm publish --tag latest",
|
|
97
98
|
"publish": "npm publish"
|
|
98
99
|
},
|
|
99
100
|
"keywords": [
|