@misterzik/espressojs 3.1.17 → 3.1.18

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@misterzik/espressojs",
3
- "version": "3.1.17",
3
+ "version": "3.1.18",
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": {
@@ -8,51 +8,8 @@
8
8
  */
9
9
 
10
10
  const express = require("express");
11
- const axios = require("axios");
12
11
  const router = express.Router();
13
- const configuration = require("../../server");
14
-
15
- const getAPI = (req, res) => {
16
- axios
17
- .get(configuration.api.uri, configuration.api.configs)
18
- .then(function (response) {
19
- if (response.status == 200) {
20
- res.json(response.data);
21
- } else if (response.status == 400) {
22
- res.json({ message: "400" });
23
- }
24
- })
25
- .catch((err) => res.send(err));
26
- };
27
-
28
- const getItem = (req, res, params) => {
29
- axios
30
- .get(configuration.api.uri + "/" + params, configuration.api.configs)
31
- .then(function (response) {
32
- if (response.status === 200) {
33
- res.json(response.data);
34
- } else if (response.status === 400) {
35
- res.json({ message: "400" });
36
- }
37
- })
38
- .catch((err) => res.send(err));
39
- };
40
-
41
- const getItemId = (req, res, params, paramsId) => {
42
- axios
43
- .get(
44
- configuration.api.uri + params + "/" + paramsId + "/",
45
- configuration.api.configs
46
- )
47
- .then(function (response) {
48
- if (response.status === 200) {
49
- res.json(response.data);
50
- } else if (response.status === 400) {
51
- res.json({ message: "400" });
52
- }
53
- })
54
- .catch((err) => res.send(err));
55
- };
12
+ const { getAPI, getItem, getItemId } = require("../utils");
56
13
  router.get("/v1/", (req, res) => {
57
14
  getAPI(req, res);
58
15
  });
@@ -10,27 +10,19 @@
10
10
  * @param {*} app - Vimedev.com Labs
11
11
  */
12
12
 
13
+ const clientController = require("../../server/controllers/client/client.controller.js");
14
+ const { create, findAll, findOne, update } = clientController;
15
+ const url = "/api/clients/";
16
+
13
17
  module.exports = (app) => {
14
- const clientRouter = require("../../server/controllers/client/client.controller.js");
15
- const url = "/api/clients/";
16
- /**
17
- * Create
18
- */
19
- app.post(url, clientRouter.create);
20
- /**
21
- * Get All
22
- */
23
- app.get(url, clientRouter.findAll);
24
- /**
25
- * Retrieve a single Note with clientId
26
- */
27
- app.get(url + ":clientId", clientRouter.findOne);
28
- /**
29
- * Update a Note with clientId
30
- */
31
- app.put(url + ":clientId", clientRouter.update);
32
- /**
33
- * Delete a Note with clientId
34
- */
35
- app.delete(url + ":clientId", clientRouter.delete);
18
+ /* Create */
19
+ app.post(url, create);
20
+ /* Get All */
21
+ app.get(url, findAll);
22
+ /* Retrieve a single Note with clientId */
23
+ app.get(url + ":clientId", findOne);
24
+ /** Update a Note with clientId */
25
+ app.put(url + ":clientId", update);
26
+ /* Delete a Note with clientId */
27
+ app.delete(url + ":clientId", clientController.delete);
36
28
  };
package/routes/index.js CHANGED
@@ -9,10 +9,11 @@
9
9
  * @param {*} app - Vimedev.com Labs
10
10
  */
11
11
 
12
+ const Path = require("path");
13
+ const configuration = require("../server");
14
+ const api = require("./api");
15
+
12
16
  module.exports = (app) => {
13
- const Path = require("path");
14
- const configuration = require("../server");
15
- const api = require("./api");
16
17
  app.get("/", function (res) {
17
18
  res.sendFile("index.html", { root: Path.join("./public") });
18
19
  });
@@ -0,0 +1,42 @@
1
+ const axios = require("axios");
2
+ const configuration = require("../../server");
3
+
4
+ const handleResponse = (res, response) => {
5
+ if (response.status === 200) {
6
+ res.json(response.data);
7
+ } else if (response.status === 400) {
8
+ res.json({ message: "400" });
9
+ }
10
+ };
11
+
12
+ const getAPI = (req, res) => {
13
+ axios
14
+ .get(configuration.api.uri, configuration.api.configs)
15
+ .then(function (response) {
16
+ handleResponse(res, response);
17
+ })
18
+ .catch((err) => res.send(err));
19
+ };
20
+
21
+ const getItem = (req, res, params) => {
22
+ axios
23
+ .get(configuration.api.uri + "/" + params, configuration.api.configs)
24
+ .then(function (response) {
25
+ handleResponse(res, response);
26
+ })
27
+ .catch((err) => res.send(err));
28
+ };
29
+
30
+ const getItemId = (req, res, params, paramsId) => {
31
+ axios
32
+ .get(
33
+ configuration.api.uri + params + "/" + paramsId + "/",
34
+ configuration.api.configs
35
+ )
36
+ .then(function (response) {
37
+ handleResponse(res, response);
38
+ })
39
+ .catch((err) => res.send(err));
40
+ };
41
+
42
+ module.exports = { getAPI, getItem, getItemId };
@@ -28,7 +28,7 @@ Running ....
28
28
 
29
29
  Instance Config:
30
30
  Configuration: ${cfgB.instance}
31
- Endpoint: localhost:${cfgB.port}
31
+ Endpoint: http://localhost:${cfgB.port}
32
32
  JSON:`,
33
33
  cfgB,
34
34
  `\n\nTo stop process press CTRL+C`
@@ -59,7 +59,7 @@ function envCommand(argv) {
59
59
  } else {
60
60
  console.warn("Config already saved...");
61
61
  }
62
- writeConfigFile(cfgB)
62
+ writeConfigFile(cfgB);
63
63
  }
64
64
 
65
65
  yargs.command({