1
0
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:
ivaosthu 2014-10-20 13:03:43 +02:00 committed by Ivar Conradi Østhus
parent 67d51ae82c
commit 4a84149b63
11 changed files with 141 additions and 1 deletions

4
.gitignore vendored
View File

@ -26,3 +26,7 @@ node_modules
# Users Environment Variables
.lock-wscript
# Idea stuff
.idea
*.iml

View File

@ -11,7 +11,6 @@
"after" : false,
"beforeEach": false,
"afterEach" : false,
"assert" : false,
"contain" : false
},

View File

@ -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
```

View File

@ -0,0 +1,5 @@
module.exports = function (app) {
app.get('/features', function (req, res) {
res.send('some nice json features here!');
});
};

View File

@ -0,0 +1,6 @@
var log4js = require('log4js');
log4js.clearAppenders();
log4js.addAppender(log4js.appenders.console());
module.exports = log4js.getLogger('unleash');

View File

@ -0,0 +1,7 @@
module.exports = function (app) {
app.get('/health', function (req, res) {
res.json({health: 'GOOD'});
});
};

View 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"
}
}

View File

@ -0,0 +1 @@
<h1>Hello World</h1>

View File

@ -0,0 +1 @@
//hello world

44
unleash-server/server.js Normal file
View 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
};

View File

@ -0,0 +1,12 @@
var assert = require('assert');
describe('The api', function () {
beforeEach(function () {
//
});
it('returns all toggles', function (done) {
done();
assert(true);
});
});