@misterzik/espressojs 3.1.11 → 3.1.14

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/.env CHANGED
@@ -1 +1,6 @@
1
1
  MONGO_URI=USER:PASSWORD@DOMAIN.mongodb.net
2
+ MONGO_URI_PORT=27017
3
+ MONGO_URI_DB=clients
4
+ API_URI_ON=FALSE
5
+ API_URI=
6
+ PORT=8080
package/README.md CHANGED
@@ -1,56 +1,66 @@
1
-
2
- ![Espresso](Espresso-Logo.png)
1
+ ![Espresso](https://raw.githubusercontent.com/misterzik/Espresso.js/main/espresso-logo.png)
3
2
 
4
3
  ## EspressoJS / Espresso
5
-
6
-
7
- ### 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. Barebones configuration with the option to scale up using MongoDB.
8
4
 
9
- #### Express Server boiler-plate with some beans for fiber. This ain't Goya!. (mongoDB Ready)
5
+ ### EspressoJS / Espresso is your one-stop Express Configuration starting point or boilerplate. Simple, and unopinionated, EspressoJS plug-and-play configurations are based on Express. Espresso will get you started with an Express instance in seconds.
10
6
 
11
- ### Getting Started
7
+ ## Getting Started
12
8
 
9
+ - Download [latest release](https://github.com/misterzik/Espresso.js/packages/364567)
13
10
 
14
- * Download [latest release](https://github.com/misterzik/Espresso.js/tags) or in your bash of choice; $ git clone Espresso.js
11
+ `npm install --save @misterzik/espressojs`
15
12
 
16
-
13
+ - Create `config.json` to handle the instances
17
14
 
18
- `git clone https://github.com/misterzik/Espresso.js.git`
15
+ ```
16
+ {
17
+ "instance":"global",
18
+ "port":8080
19
+ }
20
+ ```
19
21
 
20
-
22
+ - Create `.env` if you don't want to use config. A mix is possible.
21
23
 
22
- * Change directory to new cloned repository by using your command line of choice. (NodeJS is Require to be installed.)
24
+ ```
25
+ MONGO_URI=USER:PASSWORD@DOMAIN.mongodb.net
26
+ MONGO_URI_PORT=27017
27
+ MONGO_URI_DB=clients
28
+ API_URI_ON=FALSE
29
+ API_URI=
30
+ PORT=8080
31
+ ```
23
32
 
24
- `cd "YOUR-PATH"/Espresso.js`
33
+ - Create `espresso.js` and add the following requirements to call the packages.
25
34
 
26
- * Once in Espresso.js folder, Install project dependencies by typing;
35
+ ```
36
+ require("@misterzik/espressojs");
37
+ ```
27
38
 
28
- `npm install`
39
+ - Create `cli.js` and add the following requirements to call the packages.
29
40
 
30
-
41
+ ```
42
+ require('@misterzik/espressojs/cli');
43
+ ```
31
44
 
32
- * After installing all dependencies from Espresso, You are ready to run it, before hand I left you three files that can/should be modified to your liking;
45
+ - And you are all set to start, To run the instance, use:
46
+ ```
47
+ node cli run
48
+ ```
33
49
 
34
- Pre-made Configurations:
35
- * `server/config/config.global.js`
36
- * `server/config/config.production.js`
37
- * `server/config/config.development.js`
38
50
 
39
- Let's run the demo from the files included, we can start by bundling the demo JavaScript located `/public/assets/js/` by typing on your terminal `npm run webpack-dev`this will bundle the JavaScript needed for the `index.html`.
40
-
41
- * Run project Without MongoDB, by running `npm start`, If you would like to run instance with MongoDB run `npm run dev` or `npm run prod` .
42
-
43
- Note: If you use MongoDB you have to edit the following file with your MongoDB instance credentials;
44
- `server/config/config.production.js` or `server/config/config.development.js`
51
+ ### Structured Files
45
52
 
53
+ Pre-made Configurations:
46
54
 
47
- * Stop server by pressing `CTRL + C` to terminated the Espresso process.
55
+ - `server/config/config.global.js`
56
+ - `server/config/config.production.js`
57
+ - `server/config/config.development.js`
48
58
 
49
-
59
+ ### Commands
50
60
 
51
- ### Requirements
61
+ - Stop server by pressing `CTRL + C` to terminated the Espresso process.
52
62
 
53
- * NodeJS
54
- * NPM
63
+ ### Requirements
55
64
 
56
- Make sure you already have NodeJS/NPM installed. MongoDB installed on your system in the case you desired to use the Express MongoDB Integration provided.s
65
+ - NodeJS
66
+ - NPM
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(__dirname, "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.11",
3
+ "version": "3.1.14",
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": {
@@ -54,11 +54,7 @@
54
54
  "@babel/core": "^7.16.0",
55
55
  "amd-define-factory-patcher-loader": "^1.0.0",
56
56
  "babel-loader": "^8.2.3",
57
- "babel-preset-env": "^1.7.0",
58
- "jquery": "^3.6.0",
59
- "terser-webpack-plugin": "^4.2.3",
60
- "webpack": "^5.64.0",
61
- "webpack-cli": "^4.9.1"
57
+ "babel-preset-env": "^1.7.0"
62
58
  },
63
59
  "engines": {
64
60
  "node": ">= 0.10.0"
@@ -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");
@@ -1,10 +0,0 @@
1
- html {
2
- background-image: linear-gradient(to left top, #214780, #23569a, #2366b4, #1f77cf, #1288eb);
3
- }
4
-
5
- .logo {
6
- width: 26px;
7
- margin-top: -1rem;
8
- margin-left: 1rem;
9
- margin-bottom: 1rem;
10
- }
@@ -1,31 +0,0 @@
1
- /*
2
- * Vimedev.com Labs
3
- * ----------------
4
- * jQuery Unminified File
5
- */
6
-
7
- $(document).ready(function () {
8
- console.log("EspressoJS is ready to be modified!");
9
- /*
10
- * Vimedev.com Labs
11
- * ----------------
12
- * Placeholder Code
13
- * /\/\isterzik
14
- */
15
- const _firstName = "Two";
16
- const _lastName = "Way";
17
-
18
- function updateFullName() {
19
- const fullName = $("#firstName").val() + " " + $("#lastName").val();
20
- $("#fullName").text(fullName);
21
- }
22
-
23
- $("#firstName").val(_firstName);
24
- $("#lastName").val(_lastName);
25
-
26
- $("#firstName, #lastName").keyup(() => {
27
- updateFullName();
28
- });
29
-
30
- updateFullName();
31
- });
@@ -1,9 +0,0 @@
1
- /*
2
- * Vimedev.com Labs
3
- * ----------------
4
- * jQuery Unminified File
5
- */
6
-
7
- $(document).ready(function () {
8
- console.log("EspressoJS Second JS Sample!");
9
- });
Binary file
package/public/index.html DELETED
@@ -1,60 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="utf-8" />
5
- <title>Espresso.JS by VMD - Express JS Plug & Play Node Server for DevOps</title>
6
- <meta name="viewport" content="width=device-width, initial-scale=1" />
7
- <!-- Stylesheets -->
8
- <link
9
- href="https://fonts.googleapis.com/icon?family=Material+Icons"
10
- rel="stylesheet"
11
- />
12
- <link
13
- rel="stylesheet"
14
- href="https://cdn.rawgit.com/Chalarangelo/mini.css/v3.0.0/dist/mini-default.min.css"
15
- />
16
- <link rel="stylesheet" href="/assets/css/style.css" />
17
- </head>
18
-
19
- <body>
20
- <h1>
21
- <img src="assets/images/Espresso-Logo.png" alt="Espresso" />
22
- </h1>
23
- <h4>
24
- <b>(Es)</b>presso It's your one-stop Express Configuration Boiler-Plate,
25
- plug-and-play configuration to get you started with hosting your front-end
26
- projects. This is barebones configuration with the option to scale up
27
- using mongoDB.
28
- </h4>
29
- <div class="container">
30
- <div class="row">
31
- <div class="col-sm-6">
32
- <blockquote cite="www.vimedev.com">
33
- <h1>Full Name:</h1>
34
- <h3>
35
- <span id="fullName"></span>
36
- </h3>
37
- </blockquote>
38
- </div>
39
- <div class="col-sm-3">
40
- First Name:
41
- <br />
42
- <input id="firstName" />
43
- <br />
44
- <br />
45
- Last Name:
46
- <br />
47
- <input id="lastName" />
48
- </div>
49
- <div class="col-sm-3"></div>
50
- </div>
51
- </div>
52
- <br />
53
- <a href="https://vimedev.com/" target="_blank">
54
- <img src="/assets/images/vimedev-logo.png" alt="Vimedev" class="logo" />
55
- </a>
56
- <!-- Javascript Bundles - Generated by Webpack -->
57
- <script src="/assets/src/app.bundle.js"></script>
58
- <script src="/assets/src/vendor.bundle.js"></script>
59
- </body>
60
- </html>
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;