@misterzik/espressojs 3.1.15 → 3.1.17
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 +3 -6
- package/README.md +30 -15
- package/cli.js +2 -1
- package/config.json +20 -1
- package/index.js +47 -37
- package/package.json +12 -12
- package/routes/api/index.js +15 -14
- package/routes/db/index.js +9 -14
- package/routes/index.js +11 -9
- package/server/config/development.js +36 -0
- package/server/config/global.js +35 -0
- package/server/config/production.js +35 -0
- package/server/controllers/client/client.controller.js +33 -46
- package/server/index.js +10 -13
- package/server/models/client.model.js +6 -5
- package/server/utils/config.utils.js +23 -0
- package/server/utils/espresso-cli.js +60 -59
- package/server/utils/global.message.js +10 -32
- package/server/config/config.development.js +0 -35
- package/server/config/config.global.js +0 -35
- package/server/config/config.production.js +0 -35
package/.env
CHANGED
package/README.md
CHANGED
|
@@ -2,11 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
## EspressoJS / Espresso
|
|
4
4
|
|
|
5
|
-
###
|
|
5
|
+
### 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.
|
|
6
|
+
|
|
7
|
+
### Whether you're a beginner or an experienced developer, EspressoJS will have you up and running with an Express instance in a matter of seconds. Say goodbye to tedious setup and hello to streamlined development with EspressoJS.
|
|
6
8
|
|
|
7
9
|
## Getting Started
|
|
8
10
|
|
|
9
|
-
- Download [latest release](https://github.com/misterzik/Espresso.js/
|
|
11
|
+
- Download [latest release](https://github.com/misterzik/Espresso.js/releases)
|
|
10
12
|
|
|
11
13
|
`npm install --save @misterzik/espressojs`
|
|
12
14
|
|
|
@@ -14,20 +16,32 @@
|
|
|
14
16
|
|
|
15
17
|
```
|
|
16
18
|
{
|
|
17
|
-
"instance":"
|
|
18
|
-
"port":8080
|
|
19
|
+
"instance": "development",
|
|
20
|
+
"port": 8080,
|
|
21
|
+
"hostname": "",
|
|
22
|
+
"mongoDB": {
|
|
23
|
+
"enabled": false,
|
|
24
|
+
"uri": "",
|
|
25
|
+
"instance": "database"
|
|
26
|
+
},
|
|
27
|
+
"api": {
|
|
28
|
+
"enabled": false,
|
|
29
|
+
"uri": "https://swapi.dev/api/people/",
|
|
30
|
+
"url": "",
|
|
31
|
+
"method": "GET",
|
|
32
|
+
"headers": {
|
|
33
|
+
"Content-Type": "application/json"
|
|
34
|
+
}
|
|
35
|
+
}
|
|
19
36
|
}
|
|
20
37
|
```
|
|
21
38
|
|
|
22
39
|
- Create `.env` if you don't want to use config. A mix is possible.
|
|
23
40
|
|
|
24
41
|
```
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
API_URI_ON=FALSE
|
|
29
|
-
API_URI=
|
|
30
|
-
PORT=8080
|
|
42
|
+
MONGO_USER=USER
|
|
43
|
+
MONGO_TOKEN=PASSWORD
|
|
44
|
+
API_TOKEN=APITOKEN
|
|
31
45
|
```
|
|
32
46
|
|
|
33
47
|
- Create `espresso.js` and add the following requirements to call the packages.
|
|
@@ -47,14 +61,13 @@
|
|
|
47
61
|
node cli run
|
|
48
62
|
```
|
|
49
63
|
|
|
50
|
-
|
|
51
64
|
### Structured Files
|
|
52
65
|
|
|
53
|
-
|
|
66
|
+
Pre-made Configurations:
|
|
54
67
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
68
|
+
- `server/config/config.global.js`
|
|
69
|
+
- `server/config/config.production.js`
|
|
70
|
+
- `server/config/config.development.js`
|
|
58
71
|
|
|
59
72
|
### Commands
|
|
60
73
|
|
|
@@ -62,5 +75,7 @@
|
|
|
62
75
|
|
|
63
76
|
### Requirements
|
|
64
77
|
|
|
78
|
+
Installed prior using Espresso.JS
|
|
79
|
+
|
|
65
80
|
- NodeJS
|
|
66
81
|
- NPM
|
package/cli.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
require("./server/utils/espresso-cli");
|
|
1
|
+
const cli = require("./server/utils/espresso-cli");
|
|
2
|
+
module.exports = cli;
|
package/config.json
CHANGED
|
@@ -1 +1,20 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"instance": "development",
|
|
3
|
+
"port": 8080,
|
|
4
|
+
"hostname": "",
|
|
5
|
+
"mongoDB": {
|
|
6
|
+
"enabled": false,
|
|
7
|
+
"port": null,
|
|
8
|
+
"uri": "",
|
|
9
|
+
"instance": "database"
|
|
10
|
+
},
|
|
11
|
+
"api": {
|
|
12
|
+
"enabled": false,
|
|
13
|
+
"uri": "https://swapi.dev/api/people/",
|
|
14
|
+
"url": "",
|
|
15
|
+
"method": "GET",
|
|
16
|
+
"headers": {
|
|
17
|
+
"Content-Type": "application/json"
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
package/index.js
CHANGED
|
@@ -1,49 +1,50 @@
|
|
|
1
|
-
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
1
|
+
/*
|
|
2
|
+
* _| _| _| _| _|_|_|
|
|
3
|
+
* _| _| _|_| _|_| _| _|
|
|
4
|
+
* _| _| _| _| _| _| _|
|
|
5
|
+
* _| _| _| _| _| _|
|
|
6
|
+
* _| _| _| _|_|_|
|
|
7
|
+
* EspressoJS - EspressoJS / Espresso
|
|
5
8
|
* Express Plug & Play Server
|
|
6
9
|
* -----------------
|
|
7
10
|
* @param {*} app - EspressoJS by Vimedev.com Labs
|
|
8
11
|
*/
|
|
9
|
-
|
|
10
|
-
const fs = require("fs");
|
|
11
12
|
require("dotenv").config();
|
|
12
13
|
const express = require("express");
|
|
13
14
|
const app = express();
|
|
14
15
|
const cfg = require("./server");
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
configData = JSON.parse(configJSON);
|
|
18
|
-
|
|
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");
|
|
16
|
+
const { readConfigFile } = require("./server/utils/config.utils");
|
|
17
|
+
const configData = readConfigFile();
|
|
26
18
|
|
|
19
|
+
const Path = require("path");
|
|
20
|
+
const Cors = require("cors");
|
|
21
|
+
const Compression = require("compression");
|
|
22
|
+
const Favicon = require("serve-favicon");
|
|
23
|
+
const Static = require("serve-static");
|
|
27
24
|
const mongoose = require("mongoose");
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
25
|
+
const Routes = require("./routes/index");
|
|
26
|
+
|
|
27
|
+
const Port = configData.port || cfg.port;
|
|
28
|
+
const mongoConfig = configData.mongo;
|
|
29
|
+
|
|
30
|
+
if (configData.mongo_isEnabled) {
|
|
31
|
+
const {
|
|
32
|
+
uri: mongoUri = configData.mongo.uri || "",
|
|
33
|
+
port: mongoPort = configData.mongo.port || "",
|
|
34
|
+
db: mongoDb = configData.mongo.db || "",
|
|
35
|
+
} = mongoConfig;
|
|
36
|
+
const hasPort = mongoPort ? `:${mongoPort}/` : "/";
|
|
37
|
+
const url = `mongodb+srv://${
|
|
38
|
+
process.env.MONGO_USER +
|
|
39
|
+
":" +
|
|
40
|
+
process.env.MONGO_TOKEN +
|
|
41
|
+
"@" +
|
|
42
|
+
mongoUri
|
|
43
|
+
+
|
|
44
|
+
hasPort +
|
|
45
|
+
mongoDb
|
|
46
|
+
}`;
|
|
33
47
|
|
|
34
|
-
if (cfg.mongo_isEnabled == true) {
|
|
35
|
-
let hasPort, hasUri;
|
|
36
|
-
if (cfg.mongo.port == "") {
|
|
37
|
-
hasPort = "/";
|
|
38
|
-
} else {
|
|
39
|
-
hasPort = ":" + cfg.mongo.port + "/";
|
|
40
|
-
}
|
|
41
|
-
if (cfg.mongo.uri == "") {
|
|
42
|
-
hasUri = process.env.MONGO_URI;
|
|
43
|
-
} else {
|
|
44
|
-
hasUri = cfg.mongo.uri;
|
|
45
|
-
}
|
|
46
|
-
const url = `mongodb+srv://${hasUri + hasPort + cfg.mongo.db}`;
|
|
47
48
|
mongoose.Promise = global.Promise;
|
|
48
49
|
mongoose
|
|
49
50
|
.connect(url, {
|
|
@@ -51,10 +52,16 @@ if (cfg.mongo_isEnabled == true) {
|
|
|
51
52
|
useNewUrlParser: true,
|
|
52
53
|
promiseLibrary: require("bluebird"),
|
|
53
54
|
})
|
|
54
|
-
.then(() => console.log(":: DB Connection
|
|
55
|
+
.then(() => console.log(":: DB Connection successful ::"))
|
|
55
56
|
.catch((err) => console.error(err));
|
|
56
57
|
}
|
|
57
58
|
|
|
59
|
+
const setCustomCacheControl = (res, path) => {
|
|
60
|
+
if (Static.mime.lookup(path) === "text/html") {
|
|
61
|
+
res.setHeader("Cache-Control", "public, max-age=0");
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
|
|
58
65
|
app.use(Compression());
|
|
59
66
|
app.use(Cors());
|
|
60
67
|
app.use(express.urlencoded({ extended: false }));
|
|
@@ -70,5 +77,8 @@ app.use(
|
|
|
70
77
|
);
|
|
71
78
|
|
|
72
79
|
Routes(app);
|
|
73
|
-
app.listen(Port)
|
|
80
|
+
app.listen(Port, () => {
|
|
81
|
+
console.log(`Server is running on port ${Port}`);
|
|
82
|
+
});
|
|
83
|
+
|
|
74
84
|
module.exports = app;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@misterzik/espressojs",
|
|
3
|
-
"version": "3.1.
|
|
4
|
-
"description": "EspressoJS
|
|
3
|
+
"version": "3.1.17",
|
|
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": {
|
|
7
7
|
"test": "echo \"Error: no test specified\"",
|
|
@@ -36,24 +36,24 @@
|
|
|
36
36
|
},
|
|
37
37
|
"homepage": "https://github.com/misterzik/Espresso.js#readme",
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"axios": "^
|
|
39
|
+
"axios": "^1.4.0",
|
|
40
40
|
"bluebird": "^3.7.2",
|
|
41
41
|
"cross-env": "^7.0.3",
|
|
42
|
-
"express": "^4.
|
|
43
|
-
"mongoose": "^
|
|
44
|
-
"dotenv": "^
|
|
42
|
+
"express": "^4.18.2",
|
|
43
|
+
"mongoose": "^7.3.0",
|
|
44
|
+
"dotenv": "^16.3.1",
|
|
45
45
|
"cors": "^2.8.5",
|
|
46
|
-
"finalhandler": "^1.
|
|
46
|
+
"finalhandler": "^1.2.0",
|
|
47
47
|
"compression": "^1.7.4",
|
|
48
|
-
"serve-static": "^1.
|
|
48
|
+
"serve-static": "^1.15.0",
|
|
49
49
|
"serve-favicon": "^2.5.0",
|
|
50
|
-
"yargs": "^17.2
|
|
50
|
+
"yargs": "^17.7.2"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"debug": "^4.
|
|
54
|
-
"@babel/core": "^7.
|
|
53
|
+
"debug": "^4.3.4",
|
|
54
|
+
"@babel/core": "^7.22.5",
|
|
55
55
|
"amd-define-factory-patcher-loader": "^1.0.0",
|
|
56
|
-
"babel-loader": "^
|
|
56
|
+
"babel-loader": "^9.1.2",
|
|
57
57
|
"babel-preset-env": "^1.7.0"
|
|
58
58
|
},
|
|
59
59
|
"engines": {
|
package/routes/api/index.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
1
|
+
/*
|
|
2
|
+
* _| _| _| _| _|_|_|
|
|
3
|
+
* _| _| _|_| _|_| _| _|
|
|
4
|
+
* _| _| _| _| _| _| _|
|
|
5
|
+
* _| _| _| _| _| _|
|
|
6
|
+
* _| _| _| _|_|_|
|
|
7
|
+
* EspressoJS - API Routers
|
|
7
8
|
*/
|
|
8
9
|
|
|
9
10
|
const express = require("express");
|
|
@@ -13,7 +14,7 @@ const configuration = require("../../server");
|
|
|
13
14
|
|
|
14
15
|
const getAPI = (req, res) => {
|
|
15
16
|
axios
|
|
16
|
-
.get(configuration.
|
|
17
|
+
.get(configuration.api.uri, configuration.api.configs)
|
|
17
18
|
.then(function (response) {
|
|
18
19
|
if (response.status == 200) {
|
|
19
20
|
res.json(response.data);
|
|
@@ -26,11 +27,11 @@ const getAPI = (req, res) => {
|
|
|
26
27
|
|
|
27
28
|
const getItem = (req, res, params) => {
|
|
28
29
|
axios
|
|
29
|
-
.get(configuration.
|
|
30
|
+
.get(configuration.api.uri + "/" + params, configuration.api.configs)
|
|
30
31
|
.then(function (response) {
|
|
31
|
-
if (response.status
|
|
32
|
+
if (response.status === 200) {
|
|
32
33
|
res.json(response.data);
|
|
33
|
-
} else if (response.status
|
|
34
|
+
} else if (response.status === 400) {
|
|
34
35
|
res.json({ message: "400" });
|
|
35
36
|
}
|
|
36
37
|
})
|
|
@@ -40,13 +41,13 @@ const getItem = (req, res, params) => {
|
|
|
40
41
|
const getItemId = (req, res, params, paramsId) => {
|
|
41
42
|
axios
|
|
42
43
|
.get(
|
|
43
|
-
configuration.
|
|
44
|
-
configuration.
|
|
44
|
+
configuration.api.uri + params + "/" + paramsId + "/",
|
|
45
|
+
configuration.api.configs
|
|
45
46
|
)
|
|
46
47
|
.then(function (response) {
|
|
47
|
-
if (response.status
|
|
48
|
+
if (response.status === 200) {
|
|
48
49
|
res.json(response.data);
|
|
49
|
-
} else if (response.status
|
|
50
|
+
} else if (response.status === 400) {
|
|
50
51
|
res.json({ message: "400" });
|
|
51
52
|
}
|
|
52
53
|
})
|
package/routes/db/index.js
CHANGED
|
@@ -1,39 +1,34 @@
|
|
|
1
|
-
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
1
|
+
/*
|
|
2
|
+
* _| _| _| _| _|_|_|
|
|
3
|
+
* _| _| _|_| _|_| _| _|
|
|
4
|
+
* _| _| _| _| _| _| _|
|
|
5
|
+
* _| _| _| _| _| _|
|
|
6
|
+
* _| _| _| _|_|_|
|
|
7
|
+
* EspressoJS - Client Model
|
|
8
|
+
* --
|
|
7
9
|
* Basic Clients Collection - API CRUD
|
|
8
|
-
* ---
|
|
9
10
|
* @param {*} app - Vimedev.com Labs
|
|
10
11
|
*/
|
|
11
12
|
|
|
12
13
|
module.exports = (app) => {
|
|
13
14
|
const clientRouter = require("../../server/controllers/client/client.controller.js");
|
|
14
|
-
const
|
|
15
|
-
url = preFix;
|
|
16
|
-
|
|
15
|
+
const url = "/api/clients/";
|
|
17
16
|
/**
|
|
18
17
|
* Create
|
|
19
18
|
*/
|
|
20
19
|
app.post(url, clientRouter.create);
|
|
21
|
-
|
|
22
20
|
/**
|
|
23
21
|
* Get All
|
|
24
22
|
*/
|
|
25
23
|
app.get(url, clientRouter.findAll);
|
|
26
|
-
|
|
27
24
|
/**
|
|
28
25
|
* Retrieve a single Note with clientId
|
|
29
26
|
*/
|
|
30
27
|
app.get(url + ":clientId", clientRouter.findOne);
|
|
31
|
-
|
|
32
28
|
/**
|
|
33
29
|
* Update a Note with clientId
|
|
34
30
|
*/
|
|
35
31
|
app.put(url + ":clientId", clientRouter.update);
|
|
36
|
-
|
|
37
32
|
/**
|
|
38
33
|
* Delete a Note with clientId
|
|
39
34
|
*/
|
package/routes/index.js
CHANGED
|
@@ -1,20 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
1
|
+
/*
|
|
2
|
+
* _| _| _| _| _|_|_|
|
|
3
|
+
* _| _| _|_| _|_| _| _|
|
|
4
|
+
* _| _| _| _| _| _| _|
|
|
5
|
+
* _| _| _| _| _| _|
|
|
6
|
+
* _| _| _| _|_|_|
|
|
7
|
+
* EspressoJS - Routes Control
|
|
6
8
|
* ----
|
|
7
9
|
* @param {*} app - Vimedev.com Labs
|
|
8
10
|
*/
|
|
9
11
|
|
|
10
12
|
module.exports = (app) => {
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
const Path = require("path");
|
|
14
|
+
const configuration = require("../server");
|
|
15
|
+
const api = require("./api");
|
|
14
16
|
app.get("/", function (res) {
|
|
15
17
|
res.sendFile("index.html", { root: Path.join("./public") });
|
|
16
18
|
});
|
|
17
|
-
if (configuration.
|
|
19
|
+
if (configuration.api_isEnabled === true) {
|
|
18
20
|
app.use("/api", api);
|
|
19
21
|
}
|
|
20
22
|
require("./db")(app);
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* _| _| _| _| _|_|_|
|
|
3
|
+
* _| _| _|_| _|_| _| _|
|
|
4
|
+
* _| _| _| _| _| _| _|
|
|
5
|
+
* _| _| _| _| _| _|
|
|
6
|
+
* _| _| _| _|_|_|
|
|
7
|
+
* EspressoJS - EspressoJS / Espresso
|
|
8
|
+
* Dev Template
|
|
9
|
+
*/
|
|
10
|
+
require("dotenv").config();
|
|
11
|
+
const { readConfigFile } = require("../utils/config.utils");
|
|
12
|
+
const data = readConfigFile();
|
|
13
|
+
|
|
14
|
+
const config = {
|
|
15
|
+
env: data.instance || "development",
|
|
16
|
+
hostname: data.hostname || "dev.example.com",
|
|
17
|
+
port: data.port || "8080",
|
|
18
|
+
mongo_isEnabled:
|
|
19
|
+
data.mongoDB.enabled !== undefined ? data.mongoDB.enabled : true,
|
|
20
|
+
mongo: {
|
|
21
|
+
uri: data.mongoDB.uri || "localhost",
|
|
22
|
+
port: data.mongoDB.port || "27017",
|
|
23
|
+
db: data.mongoDB.instance || "myFirstDatabase",
|
|
24
|
+
},
|
|
25
|
+
api_isEnabled: data.api.enabled !== undefined ? data.api.enabled : true,
|
|
26
|
+
api: {
|
|
27
|
+
uri: data.api.uri || "https://swapi.dev/api/people/",
|
|
28
|
+
configs: {
|
|
29
|
+
method: data.api.method || "GET",
|
|
30
|
+
url: data.api.url || "",
|
|
31
|
+
headers: data.api.headers,
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
module.exports = config;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* _| _| _| _| _|_|_|
|
|
3
|
+
* _| _| _|_| _|_| _| _|
|
|
4
|
+
* _| _| _| _| _| _| _|
|
|
5
|
+
* _| _| _| _| _| _|
|
|
6
|
+
* _| _| _| _|_|_|
|
|
7
|
+
* EspressoJS - EspressoJS / Espresso
|
|
8
|
+
* Global Template w/ API
|
|
9
|
+
*/
|
|
10
|
+
require("dotenv").config();
|
|
11
|
+
const { readConfigFile } = require("../utils/config.utils");
|
|
12
|
+
const data = readConfigFile();
|
|
13
|
+
|
|
14
|
+
const config = {
|
|
15
|
+
env: data.instance || "global",
|
|
16
|
+
hostname: data.hostname || "example.com",
|
|
17
|
+
port: data.port || "8080",
|
|
18
|
+
mongo_isEnabled:
|
|
19
|
+
data.mongoDB.enabled !== undefined ? data.mongoDB.enabled : false,
|
|
20
|
+
mongo: {
|
|
21
|
+
uri: data.mongoDB.uri || "localhost",
|
|
22
|
+
port: data.mongoDB.port || "27017",
|
|
23
|
+
db: data.mongoDB.instance || "myFirstDatabase",
|
|
24
|
+
},
|
|
25
|
+
api_isEnabled: data.api.enabled !== undefined ? data.api.enabled : false,
|
|
26
|
+
api: {
|
|
27
|
+
uri: data.api.uri || "https://swapi.dev/api/people/",
|
|
28
|
+
configs: {
|
|
29
|
+
method: data.api.method || "GET",
|
|
30
|
+
url: data.api.url || "",
|
|
31
|
+
headers: data.api.headers,
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
module.exports = config;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* _| _| _| _| _|_|_|
|
|
3
|
+
* _| _| _|_| _|_| _| _|
|
|
4
|
+
* _| _| _| _| _| _| _|
|
|
5
|
+
* _| _| _| _| _| _|
|
|
6
|
+
* _| _| _| _|_|_|
|
|
7
|
+
* EspressoJS - EspressoJS / Espresso
|
|
8
|
+
* Production Template
|
|
9
|
+
*/
|
|
10
|
+
require("dotenv").config();
|
|
11
|
+
const { readConfigFile } = require("../utils/config.utils");
|
|
12
|
+
const data = readConfigFile();
|
|
13
|
+
|
|
14
|
+
const config = {
|
|
15
|
+
env: data.instance || "production",
|
|
16
|
+
hostname: data.hostname,
|
|
17
|
+
port: data.port || "80",
|
|
18
|
+
mongo_isEnabled:
|
|
19
|
+
data.mongoDB.enabled !== undefined ? data.mongoDB.enabled : false,
|
|
20
|
+
mongo: {
|
|
21
|
+
uri: data.mongoDB.uri || "localhost",
|
|
22
|
+
port: data.mongoDB.port || "27017",
|
|
23
|
+
db: data.mongoDB.instance || "myFirstDatabase",
|
|
24
|
+
},
|
|
25
|
+
api_isEnabled: data.api.enabled !== undefined ? data.api.enabled : false,
|
|
26
|
+
api: {
|
|
27
|
+
uri: data.api.uri || "https://swapi.dev/api/people/",
|
|
28
|
+
configs: {
|
|
29
|
+
method: data.api.method || "GET",
|
|
30
|
+
url: data.api.url || "",
|
|
31
|
+
headers: data.api.headers,
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
module.exports = config;
|
|
@@ -1,18 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
1
|
+
/*
|
|
2
|
+
* _| _| _| _| _|_|_|
|
|
3
|
+
* _| _| _|_| _|_| _| _|
|
|
4
|
+
* _| _| _| _| _| _| _|
|
|
5
|
+
* _| _| _| _| _| _|
|
|
6
|
+
* _| _| _| _|_|_|
|
|
7
|
+
* EspressoJS - EspressoJS / Espresso is your one-stop
|
|
8
|
+
* Express Configuration starting point
|
|
6
9
|
*/
|
|
7
10
|
|
|
8
11
|
const Client = require("../../models/client.model.js");
|
|
9
12
|
|
|
10
13
|
/**
|
|
11
|
-
* Retrieve and return all
|
|
12
|
-
* @param {*} req - Request data
|
|
13
|
-
* @param {*} res - Response
|
|
14
|
+
* Retrieve and return all clients from the collection.
|
|
15
|
+
* @param {*} req - Request data
|
|
16
|
+
* @param {*} res - Response data
|
|
14
17
|
*/
|
|
15
|
-
|
|
16
18
|
exports.findAll = (req, res) => {
|
|
17
19
|
Client.find()
|
|
18
20
|
.then((clients) => {
|
|
@@ -20,38 +22,29 @@ exports.findAll = (req, res) => {
|
|
|
20
22
|
})
|
|
21
23
|
.catch((err) => {
|
|
22
24
|
res.status(500).send({
|
|
23
|
-
message:
|
|
24
|
-
err.message || "Error occurred while retrieving your collections.",
|
|
25
|
+
message: err.message || "Error occurred while retrieving clients.",
|
|
25
26
|
});
|
|
26
27
|
});
|
|
27
28
|
};
|
|
28
29
|
|
|
29
30
|
/**
|
|
30
|
-
* Create and
|
|
31
|
-
* @param {*} req
|
|
32
|
-
* @param {*} res
|
|
31
|
+
* Create and save a new client to the collection.
|
|
32
|
+
* @param {*} req - Request data
|
|
33
|
+
* @param {*} res - Response data
|
|
33
34
|
*/
|
|
34
|
-
|
|
35
35
|
exports.create = (req, res) => {
|
|
36
36
|
if (!req.body.email) {
|
|
37
37
|
return res.status(400).send({
|
|
38
|
-
message: "
|
|
38
|
+
message: "Email cannot be an empty field.",
|
|
39
39
|
});
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
/**
|
|
43
|
-
* Client Body to be created after
|
|
44
|
-
* Request byPass of cannot be null
|
|
45
|
-
*/
|
|
46
42
|
const client = new Client({
|
|
47
43
|
name: req.body.name || "John Doe",
|
|
48
44
|
email: req.body.email,
|
|
49
45
|
location: req.body.location,
|
|
50
46
|
});
|
|
51
47
|
|
|
52
|
-
/**
|
|
53
|
-
* Save Client in the document collection
|
|
54
|
-
*/
|
|
55
48
|
client
|
|
56
49
|
.save()
|
|
57
50
|
.then((data) => {
|
|
@@ -59,23 +52,22 @@ exports.create = (req, res) => {
|
|
|
59
52
|
})
|
|
60
53
|
.catch((err) => {
|
|
61
54
|
res.status(500).send({
|
|
62
|
-
message: err.message || "Error occurred while creating the
|
|
55
|
+
message: err.message || "Error occurred while creating the client.",
|
|
63
56
|
});
|
|
64
57
|
});
|
|
65
58
|
};
|
|
66
59
|
|
|
67
60
|
/**
|
|
68
|
-
* Find a single client
|
|
69
|
-
* @param {*} req
|
|
70
|
-
* @param {*} res
|
|
61
|
+
* Find a single client by clientId.
|
|
62
|
+
* @param {*} req - Request data
|
|
63
|
+
* @param {*} res - Response data
|
|
71
64
|
*/
|
|
72
65
|
exports.findOne = (req, res) => {
|
|
73
66
|
Client.findById(req.params.clientId)
|
|
74
67
|
.then((client) => {
|
|
75
68
|
if (!client) {
|
|
76
69
|
return res.status(404).send({
|
|
77
|
-
message:
|
|
78
|
-
"Client not found with the following id " + req.params.clientId,
|
|
70
|
+
message: "Client not found with id " + req.params.clientId,
|
|
79
71
|
});
|
|
80
72
|
}
|
|
81
73
|
res.send(client);
|
|
@@ -93,10 +85,9 @@ exports.findOne = (req, res) => {
|
|
|
93
85
|
};
|
|
94
86
|
|
|
95
87
|
/**
|
|
96
|
-
* Update a client
|
|
97
|
-
*
|
|
98
|
-
* @param {*}
|
|
99
|
-
* @param {*} res
|
|
88
|
+
* Update a client identified by clientId.
|
|
89
|
+
* @param {*} req - Request data
|
|
90
|
+
* @param {*} res - Response data
|
|
100
91
|
*/
|
|
101
92
|
exports.update = (req, res) => {
|
|
102
93
|
if (!req.body.email) {
|
|
@@ -105,10 +96,6 @@ exports.update = (req, res) => {
|
|
|
105
96
|
});
|
|
106
97
|
}
|
|
107
98
|
|
|
108
|
-
/**
|
|
109
|
-
* Find client and update it with the request body
|
|
110
|
-
* depending on _id
|
|
111
|
-
*/
|
|
112
99
|
Client.findByIdAndUpdate(
|
|
113
100
|
req.params.clientId,
|
|
114
101
|
{
|
|
@@ -118,13 +105,13 @@ exports.update = (req, res) => {
|
|
|
118
105
|
},
|
|
119
106
|
{ new: true }
|
|
120
107
|
)
|
|
121
|
-
.then((
|
|
122
|
-
if (!
|
|
108
|
+
.then((client) => {
|
|
109
|
+
if (!client) {
|
|
123
110
|
return res.status(404).send({
|
|
124
111
|
message: "Client not found with id " + req.params.clientId,
|
|
125
112
|
});
|
|
126
113
|
}
|
|
127
|
-
res.send(
|
|
114
|
+
res.send(client);
|
|
128
115
|
})
|
|
129
116
|
.catch((err) => {
|
|
130
117
|
if (err.kind === "ObjectId") {
|
|
@@ -139,14 +126,14 @@ exports.update = (req, res) => {
|
|
|
139
126
|
};
|
|
140
127
|
|
|
141
128
|
/**
|
|
142
|
-
* Delete a client
|
|
143
|
-
* @param {*} req
|
|
144
|
-
* @param {*} res
|
|
129
|
+
* Delete a client by clientId.
|
|
130
|
+
* @param {*} req - Request data
|
|
131
|
+
* @param {*} res - Response data
|
|
145
132
|
*/
|
|
146
133
|
exports.delete = (req, res) => {
|
|
147
134
|
Client.findByIdAndRemove(req.params.clientId)
|
|
148
|
-
.then((
|
|
149
|
-
if (!
|
|
135
|
+
.then((client) => {
|
|
136
|
+
if (!client) {
|
|
150
137
|
return res.status(404).send({
|
|
151
138
|
message: "Client not found with id " + req.params.clientId,
|
|
152
139
|
});
|
|
@@ -160,7 +147,7 @@ exports.delete = (req, res) => {
|
|
|
160
147
|
});
|
|
161
148
|
}
|
|
162
149
|
return res.status(500).send({
|
|
163
|
-
message: "Could not delete
|
|
150
|
+
message: "Could not delete client with id " + req.params.clientId,
|
|
164
151
|
});
|
|
165
152
|
});
|
|
166
153
|
};
|
package/server/index.js
CHANGED
|
@@ -1,17 +1,14 @@
|
|
|
1
1
|
/*
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
2
|
+
* _| _| _| _| _|_|_|
|
|
3
|
+
* _| _| _|_| _|_| _| _|
|
|
4
|
+
* _| _| _| _| _| _| _|
|
|
5
|
+
* _| _| _| _| _| _|
|
|
6
|
+
* _| _| _| _|_|_|
|
|
7
|
+
* EspressoJS
|
|
6
8
|
*/
|
|
7
|
-
const fs = require("fs");
|
|
8
|
-
|
|
9
9
|
require("dotenv").config();
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const env = data.instance || process.env.NODE_ENV || "development";
|
|
15
|
-
const cfg = require("./config/config." + env);
|
|
16
|
-
|
|
10
|
+
const { readConfigFile } = require("./utils/config.utils");
|
|
11
|
+
const data = readConfigFile();
|
|
12
|
+
const env = data.instance || "development";
|
|
13
|
+
const cfg = require("./config/" + env);
|
|
17
14
|
module.exports = cfg;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
1
|
+
/*
|
|
2
|
+
* _| _| _| _| _|_|_|
|
|
3
|
+
* _| _| _|_| _|_| _| _|
|
|
4
|
+
* _| _| _| _| _| _| _|
|
|
5
|
+
* _| _| _| _| _| _|
|
|
6
|
+
* _| _| _| _|_|_|
|
|
5
7
|
* MongoDB Schema Example
|
|
6
8
|
*/
|
|
7
|
-
|
|
8
9
|
const mongoose = require("mongoose");
|
|
9
10
|
const clientSchema = mongoose.Schema(
|
|
10
11
|
{
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
const fs = require("fs");
|
|
2
|
+
|
|
3
|
+
function readConfigFile() {
|
|
4
|
+
const cfgBuffer = fs.readFileSync("./config.json");
|
|
5
|
+
const cfgBuJSON = cfgBuffer.toString();
|
|
6
|
+
return JSON.parse(cfgBuJSON);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
function writeConfigFile(cfg) {
|
|
10
|
+
const instUpdate = JSON.stringify(cfg);
|
|
11
|
+
fs.writeFileSync("config.json", instUpdate);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const vmdLogo = `
|
|
15
|
+
( (
|
|
16
|
+
) )
|
|
17
|
+
........
|
|
18
|
+
| .VMD |]
|
|
19
|
+
| /
|
|
20
|
+
'----'/.ZI|<..
|
|
21
|
+
`;
|
|
22
|
+
|
|
23
|
+
module.exports = { readConfigFile, writeConfigFile, vmdLogo };
|
|
@@ -1,60 +1,76 @@
|
|
|
1
1
|
/*
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
2
|
+
* _| _| _| _| _|_|_|
|
|
3
|
+
* _| _| _|_| _|_| _| _|
|
|
4
|
+
* _| _| _| _| _| _| _|
|
|
5
|
+
* _| _| _| _| _| _|
|
|
6
|
+
* _| _| _| _|_|_|
|
|
7
|
+
* EspressoJS - CLI
|
|
6
8
|
*/
|
|
7
9
|
|
|
8
|
-
const fs = require("fs");
|
|
9
10
|
const { exec } = require("child_process");
|
|
10
11
|
const { string, number } = require("yargs");
|
|
11
12
|
const yargs = require("yargs");
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
const cfgB =
|
|
13
|
+
const { readConfigFile, writeConfigFile, vmdLogo } = require("./config.utils");
|
|
14
|
+
|
|
15
|
+
const cfgB = readConfigFile();
|
|
16
|
+
function showCommand() {
|
|
17
|
+
console.log(cfgB);
|
|
18
|
+
}
|
|
19
|
+
function runCommand() {
|
|
20
|
+
if (cfgB !== undefined) {
|
|
21
|
+
const cmd_ct = vmdLogo;
|
|
22
|
+
console.warn(`${cmd_ct}`);
|
|
23
|
+
console.warn(
|
|
24
|
+
`Espresso CLI
|
|
25
|
+
--------------
|
|
26
|
+
Warming Up Configs..
|
|
27
|
+
Running ....
|
|
28
|
+
|
|
29
|
+
Instance Config:
|
|
30
|
+
Configuration: ${cfgB.instance}
|
|
31
|
+
Endpoint: localhost:${cfgB.port}
|
|
32
|
+
JSON:`,
|
|
33
|
+
cfgB,
|
|
34
|
+
`\n\nTo stop process press CTRL+C`
|
|
35
|
+
);
|
|
36
|
+
exec(
|
|
37
|
+
`node ./node_modules/cross-env/src/bin/cross-env NODE_ENV=${cfgB.instance} PORT=${cfgB.port} node index.js`,
|
|
38
|
+
(error, stdout, stderr) => {
|
|
39
|
+
if (error) {
|
|
40
|
+
console.log(`error: ${error.message}`);
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
if (stderr) {
|
|
44
|
+
console.log(`stderr: ${stderr}`);
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
console.log(`stdout: ${stdout}`);
|
|
48
|
+
}
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
function envCommand(argv) {
|
|
53
|
+
if (argv.instance !== undefined) {
|
|
54
|
+
cfgB.instance = argv.instance;
|
|
55
|
+
}
|
|
56
|
+
if (cfgB.port !== argv.port) {
|
|
57
|
+
cfgB.port = argv.port;
|
|
58
|
+
console.warn("New config saved...");
|
|
59
|
+
} else {
|
|
60
|
+
console.warn("Config already saved...");
|
|
61
|
+
}
|
|
62
|
+
writeConfigFile(cfgB)
|
|
63
|
+
}
|
|
15
64
|
|
|
16
65
|
yargs.command({
|
|
17
66
|
command: "show",
|
|
18
67
|
describe: "Show pre-compiled Instance",
|
|
19
|
-
handler:
|
|
20
|
-
console.log(cfgB);
|
|
21
|
-
},
|
|
68
|
+
handler: showCommand,
|
|
22
69
|
});
|
|
23
70
|
yargs.command({
|
|
24
71
|
command: "run",
|
|
25
72
|
describe: "Run pre-compiled Instance",
|
|
26
|
-
handler:
|
|
27
|
-
if (cfgB !== undefined) {
|
|
28
|
-
const cmd_ct = `
|
|
29
|
-
( (
|
|
30
|
-
) )
|
|
31
|
-
........
|
|
32
|
-
| .VMD |]
|
|
33
|
-
| /
|
|
34
|
-
'----'/_zik...
|
|
35
|
-
`;
|
|
36
|
-
console.warn(`${cmd_ct}`);
|
|
37
|
-
console.warn(
|
|
38
|
-
`Espresso CLI\n--------------\nWarming Up Configs..\nRunning ....\n\nInstance Config:\nConfiguration: ${cfgB.instance}\nEndpoint: localhost:${cfgB.port}\nJSON:`,
|
|
39
|
-
cfgB,
|
|
40
|
-
`\n\nTo stop process press CTRL+C`
|
|
41
|
-
);
|
|
42
|
-
exec(
|
|
43
|
-
`node ./node_modules/cross-env/src/bin/cross-env NODE_ENV=${cfgB.instance} PORT=${cfgB.port} node espresso.js`,
|
|
44
|
-
(error, stdout, stderr) => {
|
|
45
|
-
if (error) {
|
|
46
|
-
console.log(`error: ${error.message}`);
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
if (stderr) {
|
|
50
|
-
console.log(`stderr: ${stderr}`);
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
console.log(`stdout: ${stdout}`);
|
|
54
|
-
}
|
|
55
|
-
);
|
|
56
|
-
}
|
|
57
|
-
},
|
|
73
|
+
handler: runCommand,
|
|
58
74
|
});
|
|
59
75
|
yargs.command({
|
|
60
76
|
command: "env",
|
|
@@ -71,21 +87,6 @@ yargs.command({
|
|
|
71
87
|
type: number,
|
|
72
88
|
},
|
|
73
89
|
},
|
|
74
|
-
handler:
|
|
75
|
-
if (argv.instance === undefined) {
|
|
76
|
-
cfgB.instance = cfgB.instance;
|
|
77
|
-
} else if (argv.instance !== cfgB.instance) {
|
|
78
|
-
cfgB.instance = argv.instance;
|
|
79
|
-
}
|
|
80
|
-
if (cfgB.port !== argv.port) {
|
|
81
|
-
cfgB.port = argv.port;
|
|
82
|
-
console.warn("New config saved...");
|
|
83
|
-
} else {
|
|
84
|
-
cfgB.port = cfgB.port;
|
|
85
|
-
console.warn("Config already saved...");
|
|
86
|
-
}
|
|
87
|
-
const instUpdate = JSON.stringify(cfgB);
|
|
88
|
-
fs.writeFileSync("config.json", instUpdate);
|
|
89
|
-
},
|
|
90
|
+
handler: envCommand,
|
|
90
91
|
});
|
|
91
92
|
yargs.parse();
|
|
@@ -1,41 +1,19 @@
|
|
|
1
1
|
/*
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
2
|
+
* _| _| _| _| _|_|_|
|
|
3
|
+
* _| _| _|_| _|_| _| _|
|
|
4
|
+
* _| _| _| _| _| _| _|
|
|
5
|
+
* _| _| _| _| _| _|
|
|
6
|
+
* _| _| _| _|_|_|
|
|
7
|
+
* EspressoJS - Init
|
|
6
8
|
*/
|
|
7
|
-
|
|
8
9
|
module.exports = (app) => {
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const cfgBuffer = fs.readFileSync("./config.json");
|
|
12
|
-
const cfgBuJSON = cfgBuffer.toString();
|
|
13
|
-
const cfgB = JSON.parse(cfgBuJSON);
|
|
14
|
-
|
|
10
|
+
const { readConfigFile, vmdLogo } = require("config.utils");
|
|
11
|
+
const cfgB = readConfigFile();
|
|
15
12
|
const cmd_header = "We are brewing your Espresso";
|
|
16
|
-
const
|
|
17
|
-
const cmd_ct = `
|
|
18
|
-
( (
|
|
19
|
-
) )
|
|
20
|
-
........
|
|
21
|
-
| .VMD |]
|
|
22
|
-
| /
|
|
23
|
-
'----'/_zik...
|
|
24
|
-
`;
|
|
13
|
+
const cmd_ct = vmdLogo;
|
|
25
14
|
const cmd_ready = "Your Espresso is ready!";
|
|
26
15
|
const cmd_port = `Instance Config\nLive Preview: http://localhost:${
|
|
27
16
|
cfgB.port || process.env.PORT || cfg.port
|
|
28
17
|
}`;
|
|
29
|
-
console.warn(
|
|
30
|
-
`${
|
|
31
|
-
cmd_header +
|
|
32
|
-
cmd_nl +
|
|
33
|
-
cmd_ct +
|
|
34
|
-
cmd_nl +
|
|
35
|
-
cmd_ready +
|
|
36
|
-
cmd_nl +
|
|
37
|
-
cmd_port +
|
|
38
|
-
cmd_nl
|
|
39
|
-
} \n\nTo stop process press CTRL+C`
|
|
40
|
-
);
|
|
18
|
+
console.warn(`${cmd_header}\n${cmd_ct}\n${cmd_ready}\n${cmd_port}\n\nTo stop the process, press CTRL+C`);
|
|
41
19
|
};
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* EspressoJS - Hippie's Fav Server Plate
|
|
3
|
-
* Powered by Vimedev.com Labs
|
|
4
|
-
* ----------------
|
|
5
|
-
*
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
var config = (module.exports = {});
|
|
9
|
-
|
|
10
|
-
// Settings :: General's
|
|
11
|
-
|
|
12
|
-
config.env = "development";
|
|
13
|
-
config.hostname = "dev.example.com";
|
|
14
|
-
config.port = "8080";
|
|
15
|
-
|
|
16
|
-
// Settings :: MongoDB
|
|
17
|
-
|
|
18
|
-
config.mongo_isEnabled = true;
|
|
19
|
-
config.mongo = {};
|
|
20
|
-
config.mongo.uri = process.env.MONGO_URI || "localhost";
|
|
21
|
-
config.mongo.port = process.env.MONGO_URI_PORT || "27017";
|
|
22
|
-
config.mongo.db = process.env.MONGO_URI_DB || "myFirstDatabase";
|
|
23
|
-
|
|
24
|
-
// Settings :: SWAPI Sample
|
|
25
|
-
|
|
26
|
-
config.swapi_isEnabled = true;
|
|
27
|
-
config.swapi = {};
|
|
28
|
-
config.swapi.uri = process.env.API_URI || "https://swapi.dev/api/people/";
|
|
29
|
-
config.swapi.configs = {
|
|
30
|
-
method: "GET",
|
|
31
|
-
url: "",
|
|
32
|
-
headers: {
|
|
33
|
-
"Content-Type": "application/json",
|
|
34
|
-
},
|
|
35
|
-
};
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* EspressoJS - Hippie's Fav Server Plate
|
|
3
|
-
* Powered by Vimedev.com Labs
|
|
4
|
-
* ----------------
|
|
5
|
-
*
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
var config = (module.exports = {});
|
|
9
|
-
|
|
10
|
-
// Settings :: General's
|
|
11
|
-
|
|
12
|
-
config.env = "development";
|
|
13
|
-
config.hostname = "global.example.com";
|
|
14
|
-
config.port = "8080";
|
|
15
|
-
|
|
16
|
-
// Settings :: MongoDB
|
|
17
|
-
|
|
18
|
-
config.mongo_isEnabled = false;
|
|
19
|
-
config.mongo = {};
|
|
20
|
-
config.mongo.uri = process.env.MONGO_URI || "localhost";
|
|
21
|
-
config.mongo.port = process.env.MONGO_URI_PORT ||"";
|
|
22
|
-
config.mongo.db = process.env.MONGO_URI_DB ||"";
|
|
23
|
-
|
|
24
|
-
// Settings :: SWAPI Sample
|
|
25
|
-
|
|
26
|
-
config.swapi_isEnabled = true;
|
|
27
|
-
config.swapi = {};
|
|
28
|
-
config.swapi.uri = process.env.API_URI || "https://swapi.dev/api/";
|
|
29
|
-
config.swapi.configs = {
|
|
30
|
-
method: "GET",
|
|
31
|
-
url: "",
|
|
32
|
-
headers: {
|
|
33
|
-
"Content-Type": "application/json",
|
|
34
|
-
},
|
|
35
|
-
};
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* EspressoJS - Hippie's Fav Server Plate
|
|
3
|
-
* Powered by Vimedev.com Labs
|
|
4
|
-
* ----------------
|
|
5
|
-
*
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
var config = (module.exports = {});
|
|
9
|
-
|
|
10
|
-
// Settings :: General's
|
|
11
|
-
|
|
12
|
-
config.env = "production";
|
|
13
|
-
config.hostname = "www.example.com";
|
|
14
|
-
config.port = "80";
|
|
15
|
-
|
|
16
|
-
// Settings :: MongoDB
|
|
17
|
-
|
|
18
|
-
config.mongo_isEnabled = false;
|
|
19
|
-
config.mongo = {};
|
|
20
|
-
config.mongo.uri = process.env.MONGO_URI || "localhost";
|
|
21
|
-
config.mongo.port = process.env.MONGO_URI_PORT ||"27017";
|
|
22
|
-
config.mongo.db = process.env.MONGO_URI_DB ||"clients";
|
|
23
|
-
|
|
24
|
-
// Settings :: SWAPI Sample
|
|
25
|
-
|
|
26
|
-
config.swapi_isEnabled = false;
|
|
27
|
-
config.swapi = {};
|
|
28
|
-
config.swapi.uri = process.env.API_URI || "https://swapi.dev/api/people/";
|
|
29
|
-
config.swapi.configs = {
|
|
30
|
-
method: "GET",
|
|
31
|
-
url: "",
|
|
32
|
-
headers: {
|
|
33
|
-
"Content-Type": "application/json",
|
|
34
|
-
},
|
|
35
|
-
};
|