-
Notifications
You must be signed in to change notification settings - Fork 695
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #307 from KunalKapadia/develop
Develop to Master
- Loading branch information
Showing
16 changed files
with
73 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
NODE_ENV=development | ||
PORT=4040 | ||
JWT_SECRET=0a6b944d-d2fb-46fc-a85e-0295c986cd9f | ||
MONGO_HOST=mongodb://localhost/express-mongoose-es6-rest-api-development | ||
MONGO_PORT=27017 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,3 +46,6 @@ node_modules | |
|
||
# Optional REPL history | ||
.node_repl_history | ||
|
||
# .env | ||
.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import Joi from 'joi'; | ||
|
||
// require and configure dotenv, will load vars in .env in PROCESS.ENV | ||
require('dotenv').config(); | ||
|
||
// define validation for all the env vars | ||
const envVarsSchema = Joi.object({ | ||
NODE_ENV: Joi.string() | ||
.allow(['development', 'production', 'test', 'provision']) | ||
.default('development'), | ||
PORT: Joi.number() | ||
.default(4040), | ||
MONGOOSE_DEBUG: Joi.boolean() | ||
.when('NODE_ENV', { | ||
is: Joi.string().equal('development'), | ||
then: Joi.boolean().default(true), | ||
otherwise: Joi.boolean().default(false) | ||
}), | ||
JWT_SECRET: Joi.string().required() | ||
.description('JWT Secret required to sign'), | ||
MONGO_HOST: Joi.string().required() | ||
.description('Mongo DB host url'), | ||
MONGO_PORT: Joi.number() | ||
.default(27017) | ||
}).unknown() | ||
.required(); | ||
|
||
const { error, value: envVars } = Joi.validate(process.env, envVarsSchema); | ||
if (error) { | ||
throw new Error(`Config validation error: ${error.message}`); | ||
} | ||
|
||
const config = { | ||
env: envVars.NODE_ENV, | ||
port: envVars.PORT, | ||
mongooseDebug: envVars.MONGOOSE_DEBUG, | ||
jwtSecret: envVars.JWT_SECRET, | ||
mongo: { | ||
host: envVars.MONGO_HOST, | ||
port: envVars.MONGO_PORT | ||
} | ||
}; | ||
|
||
export default config; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "express-mongoose-es6-rest-api", | ||
"version": "1.0.0", | ||
"version": "2.0.0", | ||
"description": "A Boilerplate application for building REST APIs using express, mongoose in ES6 with code coverage", | ||
"author": "Kunal Kapadia <[email protected]>", | ||
"main": "index.js", | ||
|
@@ -17,9 +17,9 @@ | |
"lint": "esw *.js server config --color", | ||
"lint:watch": "yarn lint -- --watch", | ||
"precommit": "yarn lint && yarn test", | ||
"test": "cross-env NODE_ENV=test ./node_modules/.bin/mocha --ui bdd --reporter spec --colors --compilers js:babel-core/register ./server/**/*.test.js", | ||
"test": "cross-env NODE_ENV=test ./node_modules/.bin/mocha --ui bdd --reporter spec --colors --compilers js:babel-core/register server/tests --recursive", | ||
"test:watch": "yarn test -- --watch", | ||
"test:coverage": "cross-env NODE_ENV=test ./node_modules/.bin/istanbul cover _mocha -- --ui bdd --reporter spec --colors --compilers js:babel-core/register ./server/**/*.test.js", | ||
"test:coverage": "cross-env NODE_ENV=test ./node_modules/.bin/istanbul cover _mocha -- --ui bdd --reporter spec --colors --compilers js:babel-core/register server/tests --recursive", | ||
"test:check-coverage": "yarn test:coverage && istanbul check-coverage", | ||
"report-coverage": "coveralls < ./coverage/lcov.info" | ||
}, | ||
|
@@ -47,6 +47,7 @@ | |
"cookie-parser": "1.4.3", | ||
"cors": "2.8.1", | ||
"debug": "^2.4.5", | ||
"dotenv": "^4.0.0", | ||
"express": "4.14.0", | ||
"express-jwt": "5.1.0", | ||
"express-validation": "1.0.1", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1397,6 +1397,10 @@ [email protected]: | |
version "1.0.0" | ||
resolved "https://registry.yarnpkg.com/dont-sniff-mimetype/-/dont-sniff-mimetype-1.0.0.tgz#5932890dc9f4e2f19e5eb02a20026e5e5efc8f58" | ||
|
||
dotenv@^4.0.0: | ||
version "4.0.0" | ||
resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-4.0.0.tgz#864ef1379aced55ce6f95debecdce179f7a0cd1d" | ||
|
||
[email protected]: | ||
version "0.0.2" | ||
resolved "https://registry.yarnpkg.com/duplexer2/-/duplexer2-0.0.2.tgz#c614dcf67e2fb14995a91711e5a617e8a60a31db" | ||
|