@misterzik/espressojs 3.1.12 → 3.1.13

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
@@ -8,25 +8,28 @@
8
8
  */
9
9
 
10
10
  const fs = require("fs");
11
+ require("dotenv").config();
11
12
  const express = require("express");
12
13
  const app = express();
13
14
  const cfg = require("./server");
14
-
15
- require("dotenv").config();
16
-
17
15
  const configBuffer = fs.readFileSync("./config.json"),
18
16
  configJSON = configBuffer.toString(),
19
17
  configData = JSON.parse(configJSON);
20
18
 
21
- const _path = require("path"),
22
- _cors = require("cors"),
23
- _compr = require("compression"),
24
- _favicon = require("serve-favicon"),
25
- _static = require("serve-static"),
26
- _port = configData.port || process.env.PORT || cfg.port,
27
- _routes = require("./server/routes/index");
19
+ const Path = require("path"),
20
+ Cors = require("cors"),
21
+ Compression = require("compression"),
22
+ Favicon = require("serve-favicon"),
23
+ Static = require("serve-static"),
24
+ Port = configData.port || process.env.PORT || cfg.port,
25
+ Routes = require("./routes/index");
28
26
 
29
27
  const mongoose = require("mongoose");
28
+ const setCustomCacheControl = (res, path) => {
29
+ if (Static.mime.lookup(path) === "text/html") {
30
+ res.setHeader("Cache-Control", "public, max-age=0");
31
+ }
32
+ };
30
33
 
31
34
  if (cfg.mongo_isEnabled == true) {
32
35
  let hasPort, hasUri;
@@ -40,7 +43,6 @@ if (cfg.mongo_isEnabled == true) {
40
43
  } else {
41
44
  hasUri = cfg.mongo.uri;
42
45
  }
43
-
44
46
  const url = `mongodb+srv://${hasUri + hasPort + cfg.mongo.db}`;
45
47
  mongoose.Promise = global.Promise;
46
48
  mongoose
@@ -53,14 +55,13 @@ if (cfg.mongo_isEnabled == true) {
53
55
  .catch((err) => console.error(err));
54
56
  }
55
57
 
56
- app.use(_compr());
57
- app.use(_cors());
58
+ app.use(Compression());
59
+ app.use(Cors());
58
60
  app.use(express.urlencoded({ extended: false }));
59
61
  app.use(express.json());
60
- app.use(_favicon(_path.join(__dirname, "./public", "favicon.ico")));
61
-
62
+ app.use(Favicon(Path.join("./public", "favicon.ico")));
62
63
  app.use(
63
- _static(_path.join("./public"), {
64
+ Static(Path.join("./public"), {
64
65
  maxAge: "1d",
65
66
  setHeaders: setCustomCacheControl,
66
67
  etag: true,
@@ -68,13 +69,6 @@ app.use(
68
69
  })
69
70
  );
70
71
 
71
- function setCustomCacheControl(res, path) {
72
- if (_static.mime.lookup(path) === "text/html") {
73
- res.setHeader("Cache-Control", "public, max-age=0");
74
- }
75
- }
76
-
77
- _routes(app);
78
- app.listen(_port);
79
-
72
+ Routes(app);
73
+ app.listen(Port);
80
74
  module.exports = app;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@misterzik/espressojs",
3
- "version": "3.1.12",
3
+ "version": "3.1.13",
4
4
  "description": "EspressoJS / Espresso It's your one-stop Express Configuration Boiler-Plate, plug-and-play configuration to get you started with hosting your front-end projects. This is a barebones configuration with the option to scale up using MongoDB.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -7,13 +7,13 @@
7
7
  */
8
8
 
9
9
  const express = require("express");
10
- const cfg = require("./../../../server");
11
- const router = express.Router();
12
10
  const axios = require("axios");
11
+ const router = express.Router();
12
+ const configuration = require("../../server");
13
13
 
14
14
  const getAPI = (req, res) => {
15
15
  axios
16
- .get(cfg.swapi.uri, cfg.swapi.configs)
16
+ .get(configuration.swapi.uri, configuration.swapi.configs)
17
17
  .then(function (response) {
18
18
  if (response.status == 200) {
19
19
  res.json(response.data);
@@ -26,7 +26,7 @@ const getAPI = (req, res) => {
26
26
 
27
27
  const getItem = (req, res, params) => {
28
28
  axios
29
- .get(cfg.swapi.uri + "/" + params, cfg.swapi.configs)
29
+ .get(configuration.swapi.uri + "/" + params, configuration.swapi.configs)
30
30
  .then(function (response) {
31
31
  if (response.status == 200) {
32
32
  res.json(response.data);
@@ -39,7 +39,10 @@ const getItem = (req, res, params) => {
39
39
 
40
40
  const getItemId = (req, res, params, paramsId) => {
41
41
  axios
42
- .get(cfg.swapi.uri + params + "/" + paramsId + "/", cfg.swapi.configs)
42
+ .get(
43
+ configuration.swapi.uri + params + "/" + paramsId + "/",
44
+ configuration.swapi.configs
45
+ )
43
46
  .then(function (response) {
44
47
  if (response.status == 200) {
45
48
  res.json(response.data);
@@ -49,15 +52,12 @@ const getItemId = (req, res, params, paramsId) => {
49
52
  })
50
53
  .catch((err) => res.send(err));
51
54
  };
52
-
53
55
  router.get("/v1/", (req, res) => {
54
56
  getAPI(req, res);
55
57
  });
56
-
57
58
  router.get("/v1/:item", (req, res, next) => {
58
59
  getItem(req, res, req.params.item);
59
60
  });
60
-
61
61
  router.get("/v1/:item/:itemId", (req, res, next) => {
62
62
  getItemId(req, res, req.params.item, req.params.itemId);
63
63
  });
@@ -2,13 +2,15 @@
2
2
  * EspressoJS - Hippie's Fav Server Plate
3
3
  * Powered by Vimedev.com Labs
4
4
  * ---
5
- * Client Model -- Basic Clients Collection - API CRUD
5
+ * Client Model - WIP
6
+ * --
7
+ * Basic Clients Collection - API CRUD
6
8
  * ---
7
9
  * @param {*} app - Vimedev.com Labs
8
10
  */
9
11
 
10
12
  module.exports = (app) => {
11
- const clientRouter = require("../../controllers/client/client.controller.js");
13
+ const clientRouter = require("../../server/controllers/client/client.controller.js");
12
14
  const preFix = "/api/clients/",
13
15
  url = preFix;
14
16
 
@@ -8,20 +8,20 @@
8
8
  */
9
9
 
10
10
  module.exports = (app) => {
11
- const cfg = require("./../../server"),
12
- path = require("path"),
11
+ const configuration = require("../server"),
12
+ Path = require("path"),
13
13
  api = require("./api");
14
14
 
15
15
  app.get("/", function (res) {
16
- res.sendFile("index.html", { root: path.join("./public") });
16
+ res.sendFile("index.html", { root: Path.join("./public") });
17
17
  });
18
18
 
19
- if (cfg.swapi_isEnabled == true) {
19
+ if (configuration.swapi_isEnabled == true) {
20
20
  app.use("/api", api);
21
21
  }
22
22
 
23
23
  require("./db")(app);
24
- require("./../utils/global.message")(app);
24
+ require("../server/utils/global.message")(app);
25
25
 
26
26
  app.use(function (req, res, next) {
27
27
  res.status(404).send("404 - Sorry can't find that!");
@@ -2,7 +2,7 @@
2
2
  * EspressoJS - Hippie's Fav Server Plate
3
3
  * Powered by Vimedev.com Labs
4
4
  * ---
5
- * MongoDB Client Controller
5
+ * MongoDB Client Controller - WIP
6
6
  */
7
7
 
8
8
  const Client = require("../../models/client.model.js");
package/webpack.config.js DELETED
@@ -1,51 +0,0 @@
1
- /**
2
- * EspressoJS - Powered by Vimedev.com Labs
3
- * ---
4
- * Basic Web-Pack Configuration Declarations
5
- * ---
6
- *
7
- */
8
-
9
- const webpack = require("webpack");
10
- const path = require("path");
11
- const TerserPlugin = require("terser-webpack-plugin");
12
-
13
- /**
14
- * EspressoJS - Powered by Vimedev.com Labs
15
- * ---
16
- * Configuration Usage
17
- */
18
- const config = {
19
- context: path.resolve(__dirname, "./public/assets/js/jQuery"),
20
- entry: {
21
- app: "./index.js",
22
- vendor: "./other-file.js",
23
- },
24
- output: {
25
- filename: "[name].bundle.js",
26
- path: path.resolve(__dirname, "./public/assets/src"),
27
- },
28
- plugins: [
29
- new webpack.ProvidePlugin({
30
- $: "jquery",
31
- jquery: "jQuery",
32
- "window.jQuery": "jquery",
33
- }),
34
- ],
35
- module: {
36
- rules: [
37
- {
38
- test: /jquery[\\\/]src[\\\/]selector\.js$/,
39
- loader: "amd-define-factory-patcher-loader",
40
- },
41
- {
42
- test: /\.js$/,
43
- exclude: /(node_modules|bower_components)/,
44
- use: {
45
- loader: "babel-loader",
46
- },
47
- },
48
- ],
49
- },
50
- };
51
- module.exports = config;