@ccci/micro-server 1.0.41 → 1.0.43

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.
Files changed (2) hide show
  1. package/dist/index.js +12 -6
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -87519,10 +87519,15 @@ import fs from "fs";
87519
87519
 
87520
87520
  // src/utils/Logger.ts
87521
87521
  var import_winston = __toESM(require_winston(), 1);
87522
- var { combine, timestamp, errors, cli, splat } = import_winston.default.format;
87522
+ var { combine, timestamp, errors, cli, splat, printf } = import_winston.default.format;
87523
87523
  var logger = import_winston.default.createLogger({
87524
87524
  level: "info",
87525
- format: combine(errors({ stack: true }), timestamp(), cli(), splat()),
87525
+ format: combine(errors({ stack: true }), timestamp(), cli(), splat(), printf((info) => {
87526
+ if (typeof info.message === "object") {
87527
+ info.message = JSON.stringify(info.message, null, 3);
87528
+ }
87529
+ return info.message;
87530
+ })),
87526
87531
  transports: [new import_winston.default.transports.Console]
87527
87532
  });
87528
87533
 
@@ -87552,6 +87557,7 @@ class DatabaseConnector {
87552
87557
  DatabaseConnector.rootDir = path;
87553
87558
  }
87554
87559
  static async init() {
87560
+ Logger.info("Initializing DB Connection...\n");
87555
87561
  return new Promise((resolve, reject) => {
87556
87562
  let connections = [];
87557
87563
  try {
@@ -87561,7 +87567,9 @@ class DatabaseConnector {
87561
87567
  const config = configs.default[env];
87562
87568
  const connection = new Sequelize(config);
87563
87569
  DatabaseConnector.connection = connection;
87570
+ Logger.info("Connecting to:", connection);
87564
87571
  connections.push(connection);
87572
+ Logger.info("Connecting to database:", connection);
87565
87573
  resolve(connections);
87566
87574
  });
87567
87575
  } catch (error) {
@@ -87630,6 +87638,7 @@ var UNSECURED_DIR = ["dev", "public"];
87630
87638
  class RouterFactory {
87631
87639
  constructor(app, pathName, folderName = "routes", context = "api") {
87632
87640
  try {
87641
+ Logger.info("Create API Routes...\n");
87633
87642
  fs2.readdirSync(folderName).forEach((dir) => {
87634
87643
  let isUnsecure = UNSECURED_DIR.findIndex((x) => x === dir) > -1;
87635
87644
  var routerDir = path.join(folderName, dir);
@@ -87642,7 +87651,7 @@ class RouterFactory {
87642
87651
  import(routeFile).then((routerClass) => {
87643
87652
  let router = new routerClass.default;
87644
87653
  app.use(endpoint, (req, res, next) => this.authenticate(req, res, next, isUnsecure || router.grantPublicAccess), router.getRoutes());
87645
- Logger.info(`Initializing endpoint: ${endpoint}`);
87654
+ Logger.info("Initializing endpoint:", endpoint);
87646
87655
  });
87647
87656
  }
87648
87657
  });
@@ -87736,16 +87745,13 @@ class ApplicationServer {
87736
87745
  ApplicationServer.app.use(helmet());
87737
87746
  ApplicationServer.app.use(import_express.default.json());
87738
87747
  ApplicationServer.app.use(import_express_fileupload.default());
87739
- Logger.info("Initializing DB Connection...\n");
87740
87748
  const db = new DatabaseConnector(process.cwd());
87741
87749
  const conn = await DatabaseConnector.init();
87742
87750
  await db.initializeModels();
87743
87751
  ApplicationServer.app.get("/", (req, resp) => {
87744
87752
  return resp.sendFile(path3.resolve("index.html"));
87745
87753
  });
87746
- Logger.info("Create API Routes...\n");
87747
87754
  new RouterFactory(ApplicationServer.app, process.cwd(), "routes");
87748
- Logger.info("Starting Server...\n");
87749
87755
  const server = ApplicationServer.app.listen(port, () => {
87750
87756
  Logger.info(`API Sever ready at: http://127.0.0.1:${port}\n`);
87751
87757
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ccci/micro-server",
3
- "version": "1.0.41",
3
+ "version": "1.0.43",
4
4
  "module": "index.ts",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",