expresso-macchiato 0.3.5 → 0.3.7
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/index.js +9 -9
- package/dist/index.mjs +9 -9
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -50,7 +50,7 @@ var _DbConnector = class _DbConnector {
|
|
|
50
50
|
constructor(projectConfig) {
|
|
51
51
|
this.connect = async (entities, migrations, sync) => {
|
|
52
52
|
try {
|
|
53
|
-
if (!this.projectConfig.DB_DIALECT || !this.projectConfig.DB_NAME) throw new Error("[DB-CONNECTOR]
|
|
53
|
+
if (!this.projectConfig.DB_DIALECT || !this.projectConfig.DB_NAME) throw new Error("[DB-CONNECTOR] Missing configs => DB_DIALECT || DB_NAME");
|
|
54
54
|
const AppDataSource = new (0, _typeorm.DataSource)({
|
|
55
55
|
type: this.projectConfig.DB_DIALECT,
|
|
56
56
|
host: this.projectConfig.DB_HOST,
|
|
@@ -83,7 +83,7 @@ var _DbConnector = class _DbConnector {
|
|
|
83
83
|
_DbConnector.DataSource = AppDataSource;
|
|
84
84
|
log.magenta(`[DB-CONNECTOR] ORM CONNECTED`);
|
|
85
85
|
} catch (err) {
|
|
86
|
-
log.
|
|
86
|
+
log.error(err);
|
|
87
87
|
}
|
|
88
88
|
};
|
|
89
89
|
this.projectConfig = projectConfig;
|
|
@@ -420,7 +420,7 @@ _DynamicDbRouter.createDbRouter = (options) => {
|
|
|
420
420
|
});
|
|
421
421
|
res.send(entities);
|
|
422
422
|
} catch (err) {
|
|
423
|
-
errorCatcher(res, err, void 0, `[GET]
|
|
423
|
+
errorCatcher(res, err, void 0, `[GET] ${options.basePath}/ => ${_nullishCoalesce(err.message, () => ( err))}`);
|
|
424
424
|
}
|
|
425
425
|
});
|
|
426
426
|
if (!avoidList.includes("GET")) options.router.get("/:id", async (req, res) => {
|
|
@@ -438,7 +438,7 @@ _DynamicDbRouter.createDbRouter = (options) => {
|
|
|
438
438
|
});
|
|
439
439
|
res.send(singleEntity);
|
|
440
440
|
} catch (err) {
|
|
441
|
-
errorCatcher(res, err, void 0, `[GET]
|
|
441
|
+
errorCatcher(res, err, void 0, `[GET] ${options.basePath}/:id => ${_nullishCoalesce(err.message, () => ( err))}`);
|
|
442
442
|
}
|
|
443
443
|
});
|
|
444
444
|
if (!avoidList.includes("POST")) options.router.post("/", async (req, res) => {
|
|
@@ -466,7 +466,7 @@ _DynamicDbRouter.createDbRouter = (options) => {
|
|
|
466
466
|
}
|
|
467
467
|
res.send(result);
|
|
468
468
|
} catch (err) {
|
|
469
|
-
errorCatcher(res, err, void 0, `[POST]
|
|
469
|
+
errorCatcher(res, err, void 0, `[POST] ${options.basePath}/ => ${_nullishCoalesce(err.message, () => ( err))}`);
|
|
470
470
|
}
|
|
471
471
|
});
|
|
472
472
|
if (!avoidList.includes("PUT")) options.router.put("/:id", async (req, res) => {
|
|
@@ -498,7 +498,7 @@ _DynamicDbRouter.createDbRouter = (options) => {
|
|
|
498
498
|
}
|
|
499
499
|
res.send(result);
|
|
500
500
|
} catch (err) {
|
|
501
|
-
errorCatcher(res, err, void 0, `[PUT]
|
|
501
|
+
errorCatcher(res, err, void 0, `[PUT] ${options.basePath}/:id => ${_nullishCoalesce(err.message, () => ( err))}`);
|
|
502
502
|
}
|
|
503
503
|
});
|
|
504
504
|
if (!avoidList.includes("DELETE")) options.router.delete("/:id", async (req, res) => {
|
|
@@ -519,7 +519,7 @@ _DynamicDbRouter.createDbRouter = (options) => {
|
|
|
519
519
|
}
|
|
520
520
|
res.send(singleEntity);
|
|
521
521
|
} catch (err) {
|
|
522
|
-
errorCatcher(res, err, void 0, `[DELETE]
|
|
522
|
+
errorCatcher(res, err, void 0, `[DELETE] ${options.basePath}/:id => ${_nullishCoalesce(err.message, () => ( err))}`);
|
|
523
523
|
}
|
|
524
524
|
});
|
|
525
525
|
return options.router;
|
|
@@ -552,7 +552,7 @@ _DynamicDbRouter.addDbRouterSwagger = (options) => {
|
|
|
552
552
|
}
|
|
553
553
|
} catch (err) {
|
|
554
554
|
if (err instanceof _typeorm.EntityMetadataNotFoundError)
|
|
555
|
-
log.error(`[${options.entity.name}]
|
|
555
|
+
log.error(`[${options.entity.name}] Metadata required for db routing but not connected on the database`);
|
|
556
556
|
}
|
|
557
557
|
if (!avoidList.includes("LIST")) {
|
|
558
558
|
const listOptions = { page: 0, pageSize: 10, order: "ASC", orderBy: options.primaryKey };
|
|
@@ -649,7 +649,7 @@ var RouterWrapper = class {
|
|
|
649
649
|
} else if (typeof handlerRes.result === "object") res.status(handlerRes.status).json(handlerRes.result);
|
|
650
650
|
else res.status(handlerRes.status).send(handlerRes.result);
|
|
651
651
|
} catch (err) {
|
|
652
|
-
fullLogNok("api", `[${method}]
|
|
652
|
+
fullLogNok("api", `[${method}] ${this.data.basePath}${path3} => ${_nullishCoalesce(err.message, () => ( err))}`);
|
|
653
653
|
res.status(500).send(_nullishCoalesce(_optionalChain([err, 'optionalAccess', _40 => _40.message]), () => ( err)));
|
|
654
654
|
}
|
|
655
655
|
};
|
package/dist/index.mjs
CHANGED
|
@@ -50,7 +50,7 @@ var _DbConnector = class _DbConnector {
|
|
|
50
50
|
constructor(projectConfig) {
|
|
51
51
|
this.connect = async (entities, migrations, sync) => {
|
|
52
52
|
try {
|
|
53
|
-
if (!this.projectConfig.DB_DIALECT || !this.projectConfig.DB_NAME) throw new Error("[DB-CONNECTOR]
|
|
53
|
+
if (!this.projectConfig.DB_DIALECT || !this.projectConfig.DB_NAME) throw new Error("[DB-CONNECTOR] Missing configs => DB_DIALECT || DB_NAME");
|
|
54
54
|
const AppDataSource = new DataSource({
|
|
55
55
|
type: this.projectConfig.DB_DIALECT,
|
|
56
56
|
host: this.projectConfig.DB_HOST,
|
|
@@ -83,7 +83,7 @@ var _DbConnector = class _DbConnector {
|
|
|
83
83
|
_DbConnector.DataSource = AppDataSource;
|
|
84
84
|
log.magenta(`[DB-CONNECTOR] ORM CONNECTED`);
|
|
85
85
|
} catch (err) {
|
|
86
|
-
log.
|
|
86
|
+
log.error(err);
|
|
87
87
|
}
|
|
88
88
|
};
|
|
89
89
|
this.projectConfig = projectConfig;
|
|
@@ -420,7 +420,7 @@ _DynamicDbRouter.createDbRouter = (options) => {
|
|
|
420
420
|
});
|
|
421
421
|
res.send(entities);
|
|
422
422
|
} catch (err) {
|
|
423
|
-
errorCatcher(res, err, void 0, `[GET]
|
|
423
|
+
errorCatcher(res, err, void 0, `[GET] ${options.basePath}/ => ${err.message ?? err}`);
|
|
424
424
|
}
|
|
425
425
|
});
|
|
426
426
|
if (!avoidList.includes("GET")) options.router.get("/:id", async (req, res) => {
|
|
@@ -438,7 +438,7 @@ _DynamicDbRouter.createDbRouter = (options) => {
|
|
|
438
438
|
});
|
|
439
439
|
res.send(singleEntity);
|
|
440
440
|
} catch (err) {
|
|
441
|
-
errorCatcher(res, err, void 0, `[GET]
|
|
441
|
+
errorCatcher(res, err, void 0, `[GET] ${options.basePath}/:id => ${err.message ?? err}`);
|
|
442
442
|
}
|
|
443
443
|
});
|
|
444
444
|
if (!avoidList.includes("POST")) options.router.post("/", async (req, res) => {
|
|
@@ -466,7 +466,7 @@ _DynamicDbRouter.createDbRouter = (options) => {
|
|
|
466
466
|
}
|
|
467
467
|
res.send(result);
|
|
468
468
|
} catch (err) {
|
|
469
|
-
errorCatcher(res, err, void 0, `[POST]
|
|
469
|
+
errorCatcher(res, err, void 0, `[POST] ${options.basePath}/ => ${err.message ?? err}`);
|
|
470
470
|
}
|
|
471
471
|
});
|
|
472
472
|
if (!avoidList.includes("PUT")) options.router.put("/:id", async (req, res) => {
|
|
@@ -498,7 +498,7 @@ _DynamicDbRouter.createDbRouter = (options) => {
|
|
|
498
498
|
}
|
|
499
499
|
res.send(result);
|
|
500
500
|
} catch (err) {
|
|
501
|
-
errorCatcher(res, err, void 0, `[PUT]
|
|
501
|
+
errorCatcher(res, err, void 0, `[PUT] ${options.basePath}/:id => ${err.message ?? err}`);
|
|
502
502
|
}
|
|
503
503
|
});
|
|
504
504
|
if (!avoidList.includes("DELETE")) options.router.delete("/:id", async (req, res) => {
|
|
@@ -519,7 +519,7 @@ _DynamicDbRouter.createDbRouter = (options) => {
|
|
|
519
519
|
}
|
|
520
520
|
res.send(singleEntity);
|
|
521
521
|
} catch (err) {
|
|
522
|
-
errorCatcher(res, err, void 0, `[DELETE]
|
|
522
|
+
errorCatcher(res, err, void 0, `[DELETE] ${options.basePath}/:id => ${err.message ?? err}`);
|
|
523
523
|
}
|
|
524
524
|
});
|
|
525
525
|
return options.router;
|
|
@@ -552,7 +552,7 @@ _DynamicDbRouter.addDbRouterSwagger = (options) => {
|
|
|
552
552
|
}
|
|
553
553
|
} catch (err) {
|
|
554
554
|
if (err instanceof EntityMetadataNotFoundError)
|
|
555
|
-
log.error(`[${options.entity.name}]
|
|
555
|
+
log.error(`[${options.entity.name}] Metadata required for db routing but not connected on the database`);
|
|
556
556
|
}
|
|
557
557
|
if (!avoidList.includes("LIST")) {
|
|
558
558
|
const listOptions = { page: 0, pageSize: 10, order: "ASC", orderBy: options.primaryKey };
|
|
@@ -649,7 +649,7 @@ var RouterWrapper = class {
|
|
|
649
649
|
} else if (typeof handlerRes.result === "object") res.status(handlerRes.status).json(handlerRes.result);
|
|
650
650
|
else res.status(handlerRes.status).send(handlerRes.result);
|
|
651
651
|
} catch (err) {
|
|
652
|
-
fullLogNok("api", `[${method}]
|
|
652
|
+
fullLogNok("api", `[${method}] ${this.data.basePath}${path3} => ${err.message ?? err}`);
|
|
653
653
|
res.status(500).send(err?.message ?? err);
|
|
654
654
|
}
|
|
655
655
|
};
|