@misterzik/espressojs 3.2.0 → 3.2.2

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/index.js CHANGED
@@ -26,6 +26,7 @@ const Routes = require("./routes/index");
26
26
 
27
27
  const Port = configData.port || cfg.port;
28
28
  const mongoConfig = configData.mongo;
29
+ const rootDir = process.cwd();
29
30
 
30
31
  if (configData.mongo_isEnabled) {
31
32
  const {
@@ -66,9 +67,9 @@ app.use(Compression());
66
67
  app.use(Cors());
67
68
  app.use(express.urlencoded({ extended: false }));
68
69
  app.use(express.json());
69
- app.use(Favicon(Path.join("./public", "favicon.ico")));
70
+ app.use(Favicon(Path.join(rootDir, "public", "favicon.ico")));
70
71
  app.use(
71
- Static(Path.join("./public"), {
72
+ Static(Path.join(rootDir, "public"), {
72
73
  maxAge: "1d",
73
74
  setHeaders: setCustomCacheControl,
74
75
  etag: true,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@misterzik/espressojs",
3
- "version": "3.2.0",
3
+ "version": "3.2.2",
4
4
  "description": "EspressoJS Introducing Espresso.JS, your ultimate Express configuration starting point and boilerplate. With its simplicity and lack of opinionation, EspressoJS offers plug-and-play configurations built on top of Express.",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/routes/index.js CHANGED
@@ -9,20 +9,22 @@
9
9
  * @param {*} app - Vimedev.com Labs
10
10
  */
11
11
 
12
- const Path = require("path");
12
+ const path = require("path");
13
13
  const configuration = require("../server");
14
- const api = require("./api");
15
- const db = require("./db");
14
+ const rootDir = process.cwd();
15
+ const api = require(path.join(rootDir, "routes", "api.js"));
16
+ const db = require(path.join(rootDir, "routes", "db.js"));
16
17
 
17
18
  module.exports = (app) => {
18
- app.get("/", function (res) {
19
- res.sendFile("index.html", { root: Path.join("./public") });
19
+ app.get("/*", function (req, res) {
20
+ const filePath = path.join(rootDir, "public", "index.html");
21
+ res.sendFile(filePath);
20
22
  });
21
23
  if (configuration.api_isEnabled === true) {
22
24
  app.use("/api", api);
23
25
  }
24
26
  if (configuration.mongo_isEnabled === true) {
25
- db(app);
27
+ app.use("/api", db);
26
28
  }
27
29
  app.use(function (req, res, next) {
28
30
  res.status(404).send("404 - Sorry can't find that!");
@@ -1,25 +0,0 @@
1
- /*
2
- * _| _| _| _| _|_|_|
3
- * _| _| _|_| _|_| _| _|
4
- * _| _| _| _| _| _| _|
5
- * _| _| _| _| _| _|
6
- * _| _| _| _|_|_|
7
- * EspressoJS - API Routers
8
- */
9
-
10
- const express = require("express");
11
- const router = express.Router();
12
- const configuration = require("../../server");
13
-
14
- // const { getAPI, getItem, getItemId } = require("../utils");
15
- // router.get("/v1/", (req, res) => {
16
- // getAPI(req, res);
17
- // });
18
- // router.get("/v1/:item", (req, res, next) => {
19
- // getItem(req, res, req.params.item);
20
- // });
21
- // router.get("/v1/:item/:itemId", (req, res, next) => {
22
- // getItemId(req, res, req.params.item, req.params.itemId);
23
- // });
24
-
25
- module.exports = { router, configuration };
@@ -1,37 +0,0 @@
1
- /*
2
- * _| _| _| _| _|_|_|
3
- * _| _| _|_| _|_| _| _|
4
- * _| _| _| _| _| _| _|
5
- * _| _| _| _| _| _|
6
- * _| _| _| _|_|_|
7
- * EspressoJS - Client Model
8
- * --
9
- * Basic Clients Collection - API CRUD
10
- * @param {*} app - Vimedev.com Labs
11
- */
12
-
13
- const clientController = require("../../server/controllers");
14
- const url = "/api/clients/";
15
-
16
- module.exports = (app) => {
17
- /* Get All */
18
- app.get(url, (req, res) => {
19
- clientController.findAll("client", req, res);
20
- });
21
- /* Create */
22
- app.post(url, (req, res) => {
23
- clientController.create("client", req, res);
24
- });
25
- /* Retrieve a single Note with clientId */
26
- app.get(url + ":clientId", (req, res) => {
27
- clientController.findOne("client", req, res);
28
- });
29
- /** Update a Note with clientId */
30
- app.put(url + ":clientId", (req, res) => {
31
- clientController.update("client", req, res);
32
- });
33
- /* Delete a Note with clientId */
34
- app.delete(url + ":clientId", (req, res) => {
35
- clientController.delete("client", req, res);
36
- });
37
- };