mirror of
https://github.com/Unleash/unleash.git
synced 2024-12-22 19:07:54 +01:00
Closes #16 - Initial express based server setup.
To start server locally: npm run start-dev To execute tests: npm test
This commit is contained in:
parent
67d51ae82c
commit
4a84149b63
4
.gitignore
vendored
4
.gitignore
vendored
@ -26,3 +26,7 @@ node_modules
|
||||
|
||||
# Users Environment Variables
|
||||
.lock-wscript
|
||||
|
||||
# Idea stuff
|
||||
.idea
|
||||
*.iml
|
||||
|
@ -11,7 +11,6 @@
|
||||
"after" : false,
|
||||
"beforeEach": false,
|
||||
"afterEach" : false,
|
||||
"assert" : false,
|
||||
"contain" : false
|
||||
},
|
||||
|
||||
|
@ -1,2 +1,20 @@
|
||||
# unleash-server
|
||||
unleash-server is a place to ask for the status of features.
|
||||
|
||||
|
||||
# Important commands:
|
||||
|
||||
```
|
||||
//Start server in dev-mode:
|
||||
npm run start-dev
|
||||
|
||||
//Admin dashboard
|
||||
http://localhost:4242
|
||||
|
||||
//Feature API:
|
||||
http://localhost:4242/features
|
||||
|
||||
|
||||
//Execute tests:
|
||||
npm test
|
||||
```
|
5
unleash-server/lib/api.js
Normal file
5
unleash-server/lib/api.js
Normal file
@ -0,0 +1,5 @@
|
||||
module.exports = function (app) {
|
||||
app.get('/features', function (req, res) {
|
||||
res.send('some nice json features here!');
|
||||
});
|
||||
};
|
6
unleash-server/lib/logger.js
Normal file
6
unleash-server/lib/logger.js
Normal file
@ -0,0 +1,6 @@
|
||||
var log4js = require('log4js');
|
||||
|
||||
log4js.clearAppenders();
|
||||
log4js.addAppender(log4js.appenders.console());
|
||||
|
||||
module.exports = log4js.getLogger('unleash');
|
7
unleash-server/lib/routes.js
Normal file
7
unleash-server/lib/routes.js
Normal file
@ -0,0 +1,7 @@
|
||||
module.exports = function (app) {
|
||||
|
||||
app.get('/health', function (req, res) {
|
||||
res.json({health: 'GOOD'});
|
||||
});
|
||||
|
||||
};
|
43
unleash-server/package.json
Normal file
43
unleash-server/package.json
Normal file
@ -0,0 +1,43 @@
|
||||
{
|
||||
"name": "unleash-server",
|
||||
"description": "unleash your features",
|
||||
"version": "0.0.1",
|
||||
"keywords": [
|
||||
"unleash",
|
||||
"feature toggle",
|
||||
"feature",
|
||||
"toggle"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "ssh://git@github.com:finn-no/unleash.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/finn-no/unleash/issues"
|
||||
},
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"start": "node server.js",
|
||||
"start-dev": "NODE_ENV=local supervisor --ignore ./node_modules/ server.js",
|
||||
"test": "jshint server.js lib public/scripts test && mocha test test/*",
|
||||
"tdd": "mocha --watch test test/*",
|
||||
"test-bamboo-ci": "mocha test test/*"
|
||||
},
|
||||
"dependencies": {
|
||||
"bluebird": "2.2.2",
|
||||
"body-parser": "1.4.3",
|
||||
"errorhandler": "1.1.1",
|
||||
"express": "4.9.8",
|
||||
"express-validator": "2.6.0",
|
||||
"ini": "1.3.0",
|
||||
"log4js": "0.6.21",
|
||||
"nconf": "0.6.9"
|
||||
},
|
||||
"devDependencies": {
|
||||
"chai": "1.9.1",
|
||||
"jshint": "2.5.2",
|
||||
"mocha": "1.20.1",
|
||||
"supertest": "0.13.0",
|
||||
"supervisor": "~0.6.0"
|
||||
}
|
||||
}
|
1
unleash-server/public/index.html
Normal file
1
unleash-server/public/index.html
Normal file
@ -0,0 +1 @@
|
||||
<h1>Hello World</h1>
|
1
unleash-server/public/scripts/hello.js
Normal file
1
unleash-server/public/scripts/hello.js
Normal file
@ -0,0 +1 @@
|
||||
//hello world
|
44
unleash-server/server.js
Normal file
44
unleash-server/server.js
Normal file
@ -0,0 +1,44 @@
|
||||
var express = require('express'),
|
||||
bodyParser = require('body-parser'),
|
||||
log4js = require('log4js'),
|
||||
logger = require('./lib/logger'),
|
||||
routes = require('./lib/routes'),
|
||||
api = require('./lib/api'),
|
||||
validator = require('express-validator'),
|
||||
app = express(),
|
||||
router = express.Router(),
|
||||
baseUriPath = process.env.BASE_URI_PATH || '';
|
||||
|
||||
if(app.get('env') === 'development') {
|
||||
app.use(require('errorhandler')());
|
||||
}
|
||||
|
||||
app.use(validator([]));
|
||||
|
||||
app.set('trust proxy');
|
||||
app.locals.baseUriPath = baseUriPath;
|
||||
|
||||
app.use(log4js.connectLogger(logger, {format: ':remote-addr :status :method :url :response-timems'}));
|
||||
app.set('port', process.env.HTTP_PORT || 4242);
|
||||
|
||||
app.use(baseUriPath, express.static(__dirname + '/public'));
|
||||
app.use(bodyParser.json({strict: false}));
|
||||
|
||||
api(router);
|
||||
routes(router);
|
||||
app.use(baseUriPath, router);
|
||||
|
||||
var server = app.listen(app.get('port'), function() {
|
||||
logger.info('unleash started on ' + app.get('port'));
|
||||
});
|
||||
|
||||
process.on('uncaughtException', function(err) {
|
||||
logger.error('Uncaught Exception:', err.message);
|
||||
logger.error(err.stack);
|
||||
});
|
||||
|
||||
|
||||
module.exports = {
|
||||
app: app,
|
||||
server: server
|
||||
};
|
12
unleash-server/test/api.js
Normal file
12
unleash-server/test/api.js
Normal file
@ -0,0 +1,12 @@
|
||||
var assert = require('assert');
|
||||
|
||||
describe('The api', function () {
|
||||
beforeEach(function () {
|
||||
//
|
||||
});
|
||||
|
||||
it('returns all toggles', function (done) {
|
||||
done();
|
||||
assert(true);
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue
Block a user