arkos 0.6.0-beta.1 → 0.7.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -14,6 +14,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.checkDatabaseConnection = exports.loadPrismaModule = void 0;
|
|
16
16
|
exports.getPrismaInstance = getPrismaInstance;
|
|
17
|
+
const fs_1 = __importDefault(require("fs"));
|
|
17
18
|
const catch_async_1 = __importDefault(require("../../modules/error-handler/utils/catch-async"));
|
|
18
19
|
const app_error_1 = __importDefault(require("../../modules/error-handler/utils/app-error"));
|
|
19
20
|
const fs_helpers_1 = require("./fs.helpers");
|
|
@@ -21,7 +22,11 @@ let prismaInstance = null;
|
|
|
21
22
|
const loadPrismaModule = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
22
23
|
if (!prismaInstance) {
|
|
23
24
|
try {
|
|
24
|
-
|
|
25
|
+
let prismaPath = `${process.cwd()}/src/utils/prisma/index.${fs_helpers_1.userFileExtension}`;
|
|
26
|
+
if (!fs_1.default.existsSync(prismaPath)) {
|
|
27
|
+
prismaPath = `${process.cwd()}/src/utils/prisma.${fs_helpers_1.userFileExtension}`;
|
|
28
|
+
}
|
|
29
|
+
const prismaModule = yield import(prismaPath);
|
|
25
30
|
prismaInstance = prismaModule.default || prismaModule.prisma;
|
|
26
31
|
}
|
|
27
32
|
catch (error) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prisma.helpers.js","sourceRoot":"","sources":["../../../../src/utils/helpers/prisma.helpers.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"prisma.helpers.js","sourceRoot":"","sources":["../../../../src/utils/helpers/prisma.helpers.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AA2BA,8CAEC;AA7BD,4CAAoB;AAEpB,gGAAuE;AAC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KAAK,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC;IACzC,CAAC;AACH,CAAC,CAAA,CACF,CAAC","sourcesContent":["import fs from \"fs\";\nimport { Request, Response, NextFunction } from \"express\";\nimport catchAsync from \"../../modules/error-handler/utils/catch-async\";\nimport AppError from \"../../modules/error-handler/utils/app-error\";\nimport { userFileExtension } from \"./fs.helpers\";\n\nlet prismaInstance: any = null;\n\nexport const loadPrismaModule = async () => {\n if (!prismaInstance) {\n try {\n let prismaPath = `${process.cwd()}/src/utils/prisma/index.${userFileExtension}`;\n\n if (!fs.existsSync(prismaPath)) {\n prismaPath = `${process.cwd()}/src/utils/prisma.${userFileExtension}`;\n }\n\n const prismaModule = await import(prismaPath);\n prismaInstance = prismaModule.default || prismaModule.prisma;\n } catch (error) {\n console.error(\"Failed to load prisma.ts:\", error);\n throw new Error(\"Could not initialize Prisma module.\");\n }\n }\n return prismaInstance;\n};\n\nexport function getPrismaInstance() {\n return prismaInstance;\n}\n\nexport const checkDatabaseConnection = catchAsync(\n async (req: Request, res: Response, next: NextFunction) => {\n const prisma = await loadPrismaModule();\n try {\n await prisma.$connect();\n next();\n } catch (error: any) {\n console.error(\"Database connection error\", error.message);\n next(new AppError(error.message, 503));\n }\n }\n);\n"]}
|
|
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.checkDatabaseConnection = exports.loadPrismaModule = void 0;
|
|
7
7
|
exports.getPrismaInstance = getPrismaInstance;
|
|
8
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
9
|
const catch_async_1 = __importDefault(require("../../modules/error-handler/utils/catch-async"));
|
|
9
10
|
const app_error_1 = __importDefault(require("../../modules/error-handler/utils/app-error"));
|
|
10
11
|
const fs_helpers_1 = require("./fs.helpers");
|
|
@@ -12,7 +13,11 @@ let prismaInstance = null;
|
|
|
12
13
|
const loadPrismaModule = async () => {
|
|
13
14
|
if (!prismaInstance) {
|
|
14
15
|
try {
|
|
15
|
-
|
|
16
|
+
let prismaPath = `${process.cwd()}/src/utils/prisma/index.${fs_helpers_1.userFileExtension}`;
|
|
17
|
+
if (!fs_1.default.existsSync(prismaPath)) {
|
|
18
|
+
prismaPath = `${process.cwd()}/src/utils/prisma.${fs_helpers_1.userFileExtension}`;
|
|
19
|
+
}
|
|
20
|
+
const prismaModule = await import(prismaPath);
|
|
16
21
|
prismaInstance = prismaModule.default || prismaModule.prisma;
|
|
17
22
|
}
|
|
18
23
|
catch (error) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prisma.helpers.js","sourceRoot":"","sources":["../../../../src/utils/helpers/prisma.helpers.ts"],"names":[],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"prisma.helpers.js","sourceRoot":"","sources":["../../../../src/utils/helpers/prisma.helpers.ts"],"names":[],"mappings":";;;;;;AA2BA,8CAEC;AA7BD,4CAAoB;AAEpB,gGAAuE;AACvE,4FAAmE;AACnE,6CAAiD;AAEjD,IAAI,cAAc,GAAQ,IAAI,CAAC;AAExB,MAAM,gBAAgB,GAAG,KAAK,IAAI,EAAE;IACzC,IAAI,CAAC,cAAc,EAAE,CAAC;QACpB,IAAI,CAAC;YACH,IAAI,UAAU,GAAG,GAAG,OAAO,CAAC,GAAG,EAAE,2BAA2B,8BAAiB,EAAE,CAAC;YAEhF,IAAI,CAAC,YAAE,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;gBAC/B,UAAU,GAAG,GAAG,OAAO,CAAC,GAAG,EAAE,qBAAqB,8BAAiB,EAAE,CAAC;YACxE,CAAC;YAED,MAAM,YAAY,GAAG,MAAM,MAAM,CAAC,UAAU,CAAC,CAAC;YAC9C,cAAc,GAAG,YAAY,CAAC,OAAO,IAAI,YAAY,CAAC,MAAM,CAAC;QAC/D,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,2BAA2B,EAAE,KAAK,CAAC,CAAC;YAClD,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;QACzD,CAAC;IACH,CAAC;IACD,OAAO,cAAc,CAAC;AACxB,CAAC,CAAC;AAjBW,QAAA,gBAAgB,oBAiB3B;AAEF,SAAgB,iBAAiB;IAC/B,OAAO,cAAc,CAAC;AACxB,CAAC;AAEY,QAAA,uBAAuB,GAAG,IAAA,qBAAU,EAC/C,KAAK,EAAE,GAAY,EAAE,GAAa,EAAE,IAAkB,EAAE,EAAE;IACxD,MAAM,MAAM,GAAG,MAAM,IAAA,wBAAgB,GAAE,CAAC;IACxC,IAAI,CAAC;QACH,MAAM,MAAM,CAAC,QAAQ,EAAE,CAAC;QACxB,IAAI,EAAE,CAAC;IACT,CAAC;IAAC,OAAO,KAAU,EAAE,CAAC;QACpB,OAAO,CAAC,KAAK,CAAC,2BAA2B,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;QAC1D,IAAI,CAAC,IAAI,mBAAQ,CAAC,KAAK,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC;IACzC,CAAC;AACH,CAAC,CACF,CAAC","sourcesContent":["import fs from \"fs\";\nimport { Request, Response, NextFunction } from \"express\";\nimport catchAsync from \"../../modules/error-handler/utils/catch-async\";\nimport AppError from \"../../modules/error-handler/utils/app-error\";\nimport { userFileExtension } from \"./fs.helpers\";\n\nlet prismaInstance: any = null;\n\nexport const loadPrismaModule = async () => {\n if (!prismaInstance) {\n try {\n let prismaPath = `${process.cwd()}/src/utils/prisma/index.${userFileExtension}`;\n\n if (!fs.existsSync(prismaPath)) {\n prismaPath = `${process.cwd()}/src/utils/prisma.${userFileExtension}`;\n }\n\n const prismaModule = await import(prismaPath);\n prismaInstance = prismaModule.default || prismaModule.prisma;\n } catch (error) {\n console.error(\"Failed to load prisma.ts:\", error);\n throw new Error(\"Could not initialize Prisma module.\");\n }\n }\n return prismaInstance;\n};\n\nexport function getPrismaInstance() {\n return prismaInstance;\n}\n\nexport const checkDatabaseConnection = catchAsync(\n async (req: Request, res: Response, next: NextFunction) => {\n const prisma = await loadPrismaModule();\n try {\n await prisma.$connect();\n next();\n } catch (error: any) {\n console.error(\"Database connection error\", error.message);\n next(new AppError(error.message, 503));\n }\n }\n);\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "arkos",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0-beta.1",
|
|
4
4
|
"description": "A super customizable TypeScript package for auto-generating API routes with built-in authentication, email service, error handling, file upload routes, image upload optimization, and seamless Prisma integration.",
|
|
5
5
|
"main": "dist/cjs/exports/index.js",
|
|
6
6
|
"module": "dist/cjs/exports/index.js",
|