@ccci/micro-server 1.0.40 → 1.0.42

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