Skip to content

Commit ccb509a

Browse files
committed
Updated to [email protected] = DOCKER READY + simplified settings
1 parent fdcffe9 commit ccb509a

File tree

16 files changed

+85
-128
lines changed

16 files changed

+85
-128
lines changed

config/commonSettings.js

Lines changed: 0 additions & 6 deletions
This file was deleted.

config/devSettings.js

Lines changed: 0 additions & 2 deletions
This file was deleted.

config/localSettings.js.in

Lines changed: 0 additions & 34 deletions
This file was deleted.

config/prodSettings.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

config/refSettings.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

config/secretSettings.js

Lines changed: 0 additions & 29 deletions
This file was deleted.

config/serverSettings.js

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/**
2+
*
3+
* Server specific settings
4+
*
5+
* *************************************************
6+
* * WARNING! Secrets should be read from env-vars *
7+
* *************************************************
8+
*
9+
*/
10+
const { getEnv, unpackMongodbConfig } = require('kth-node-configuration')
11+
const { safeGet } = require('safe-utils')
12+
13+
// DEFAULT SETTINGS used for dev, if you want to override these for you local environment, use env-vars in .env
14+
const devPrefixPath = '/api/node'
15+
const devSsl = false
16+
const devPort = 3001
17+
const devMongodb = 'mongodb://localhost:27017/node'
18+
// END DEFAULT SETTINGS
19+
20+
module.exports = {
21+
// The proxy prefix path if the application is proxied. E.g /places
22+
proxyPrefixPath: {
23+
uri: getEnv('SERVICE_PUBLISH', devPrefixPath)
24+
},
25+
useSsl: safeGet(() => getEnv('SERVER_SSL', devSsl + '').toLowerCase() == 'true'),
26+
port: getEnv('SERVER_PORT', devPort),
27+
28+
ssl: {
29+
// In development we don't have SSL feature enabled
30+
pfx: getEnv('SERVER_CERT_FILE', ''),
31+
passphrase: getEnv('SERVER_CERT_PASSPHRASE', '')
32+
},
33+
34+
// API keys
35+
api_keys: [{
36+
name: 'devClient',
37+
apikey: getEnv('NODE_API_KEY', '1234'),
38+
scope: ['write', 'read']
39+
}],
40+
41+
// Services
42+
db: unpackMongodbConfig('MONGODB_URI', devMongodb),
43+
44+
// Logging
45+
logging: {
46+
log: {
47+
level: getEnv('LOGGING_LEVEL', 'debug')
48+
}
49+
}
50+
51+
// Custom app settings
52+
}

package.json

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,26 @@
11
{
22
"//": "The production flag is added in the jenkins build script.",
33
"name": "node-api",
4-
"version": "1.0.0",
4+
"version": "2.0.0",
55
"description": "Node.js based API template application.",
66
"main": "app.js",
77
"private": true,
88
"scripts": {
9-
"test": "tape \"test/**/*.js\" | tap-spec",
10-
"test:coverage": "istanbul cover tape -- \"test/**/*.js\"",
11-
"codecheck": "standard",
12-
"codefix": "standard --fix",
13-
"preversion": "npm run codecheck && npm run test",
14-
"postversion": "git push && git push --tags",
15-
"nodeInspector": "node-inspector --web-port 8890",
16-
"openDebugBrowser": "sleep 2s && open http://127.0.0.1:8890/\\?port\\=5858 &2>/dev/null",
17-
"installAndStart": "npm install && npm start",
18-
"start": "cross-env NODE_ENV=development nodemon app.js",
19-
"startDebug": "node --debug-brk app.js",
20-
"startMock": "NODE_MOCK=1 npm start",
21-
"debug": "cross-env NODE_ENV=development concurrently --kill-others \"npm run startDebug\" \"npm run nodeInspector\" \"npm run openDebugBrowser\""
9+
"test": "echo \"ok\"",
10+
"start": "cross-env NODE_ENV=development nodemon app.js"
2211
},
2312
"dependencies": {
2413
"bluebird": "^3.4.6",
2514
"body-parser": "^1.15.2",
2615
"co": "^4.6.0",
2716
"component-registry": "^0.2.0",
2817
"cookie-parser": "^1.4.3",
18+
"dotenv": "^4.0.0",
2919
"express": "^4.14.0",
3020
"express-handlebars": "^3.0.0",
3121
"kth-node-access-log": "KTH/kth-node-access-log.git#v1.0.0",
3222
"kth-node-api-key-strategy": "KTH/kth-node-api-key-strategy.git#v1.0.2",
33-
"kth-node-configuration": "KTH/kth-node-configuration.git#v1.0.1",
23+
"kth-node-configuration": "KTH/kth-node-configuration.git#v1.3.1",
3424
"kth-node-log": "KTH/kth-node-log.git#v1.0.1",
3525
"kth-node-mongo": "KTH/kth-node-mongo.git#v1.0.3",
3626
"kth-node-monitor": "https://github.com/KTH/kth-node-monitor.git#v0.1.2",
@@ -45,16 +35,13 @@
4535
"concurrently": "^2.2.0",
4636
"cross-env": "^2.0.0",
4737
"istanbul": "^0.4.4",
38+
"nodemon": "^1.10.0",
4839
"proxyquire": "^1.7.10",
4940
"standard": "^7.1.2",
5041
"tap-spec": "^4.1.1",
5142
"tape": "^4.6.0"
5243
},
53-
"optionalDependencies": {
54-
"node-inspector": "^0.12.8",
55-
"nodemon": "^1.10.0"
56-
},
5744
"engines": {
58-
"node": "4.3.1"
45+
"node": "6.9.1"
5946
}
6047
}

server/controllers/systemCtrl.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict'
22

33
const packageFile = require('../../package.json')
4-
const config = require('../init/configuration').full
4+
const config = require('../init/configuration').server
55
const paths = require('../init/routing/paths')
66
const db = require('kth-node-mongo')
77

server/init/authentication/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
'use strict'
22

33
const log = require('kth-node-log')
4-
const config = require('../configuration')
4+
const config = require('../configuration').server
55
const passport = require('passport')
66
const server = require('../../server')
77
const apiKey = require('kth-node-api-key-strategy')
88

99
const ApiKeyStrategy = apiKey.Strategy
1010
const options = { log: log }
1111
const verify = (req, apikey, done) => {
12-
apiKey.verifyApiKey(req, apikey, config.secure.api_keys, done)
12+
apiKey.verifyApiKey(req, apikey, config.api_keys, done)
1313
}
1414
const strategy = new ApiKeyStrategy(options, verify)
1515

0 commit comments

Comments
 (0)