mirror of
https://github.com/Unleash/unleash.git
synced 2025-01-20 00:08:02 +01:00
Move all routes to a routes folder
This commit is contained in:
parent
e0607f3da1
commit
0325cd92fb
11
app.js
11
app.js
@ -4,10 +4,6 @@ var express = require('express'),
|
|||||||
log4js = require('log4js'),
|
log4js = require('log4js'),
|
||||||
logger = require('./lib/logger'),
|
logger = require('./lib/logger'),
|
||||||
routes = require('./lib/routes'),
|
routes = require('./lib/routes'),
|
||||||
eventApi = require('./lib/eventApi'),
|
|
||||||
featureApi = require('./lib/featureApi'),
|
|
||||||
featureArchiveApi = require('./lib/featureArchiveApi'),
|
|
||||||
strategyApi = require('./lib/strategyApi'),
|
|
||||||
validator = require('express-validator'),
|
validator = require('express-validator'),
|
||||||
app = express(),
|
app = express(),
|
||||||
router = express.Router(), // eslint-disable-line
|
router = express.Router(), // eslint-disable-line
|
||||||
@ -45,11 +41,8 @@ app.use(bodyParser.json({ strict: false }));
|
|||||||
|
|
||||||
app.use(cookieParser());
|
app.use(cookieParser());
|
||||||
|
|
||||||
eventApi(router);
|
routes.create(router);
|
||||||
featureApi(router);
|
|
||||||
featureArchiveApi(router);
|
|
||||||
strategyApi(router);
|
|
||||||
routes(router);
|
|
||||||
app.use(baseUriPath, router);
|
app.use(baseUriPath, router);
|
||||||
|
|
||||||
module.exports = app;
|
module.exports = app;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
var logger = require('./logger');
|
var logger = require('../logger');
|
||||||
var nconf = require('nconf');
|
var nconf = require('nconf');
|
||||||
var fs = require('fs');
|
var fs = require('fs');
|
||||||
var ini = require('ini');
|
var ini = require('ini');
|
@ -1,8 +1,8 @@
|
|||||||
var eventStore = require('./eventStore');
|
var eventStore = require('../eventStore');
|
||||||
var eventType = require('./eventType');
|
var eventType = require('../eventType');
|
||||||
var logger = require('./logger');
|
var logger = require('../logger');
|
||||||
var knex = require('./dbPool');
|
var knex = require('./dbPool');
|
||||||
var NotFoundError = require('./error/NotFoundError');
|
var NotFoundError = require('../error/NotFoundError');
|
||||||
var FEATURE_COLUMNS = ['name', 'description', 'enabled', 'strategy_name', 'parameters'];
|
var FEATURE_COLUMNS = ['name', 'description', 'enabled', 'strategy_name', 'parameters'];
|
||||||
|
|
||||||
eventStore.on(eventType.featureCreated, function (event) {
|
eventStore.on(eventType.featureCreated, function (event) {
|
@ -1,8 +1,8 @@
|
|||||||
var eventStore = require('./eventStore');
|
var eventStore = require('../eventStore');
|
||||||
var eventType = require('./eventType');
|
var eventType = require('../eventType');
|
||||||
var logger = require('./logger');
|
var logger = require('../logger');
|
||||||
var knex = require('./dbPool');
|
var knex = require('./dbPool');
|
||||||
var NotFoundError = require('./error/NotFoundError');
|
var NotFoundError = require('../error/NotFoundError');
|
||||||
var STRATEGY_COLUMNS = ['name', 'description', 'parameters_template'];
|
var STRATEGY_COLUMNS = ['name', 'description', 'parameters_template'];
|
||||||
|
|
||||||
eventStore.on(eventType.strategyCreated, function (event) {
|
eventStore.on(eventType.strategyCreated, function (event) {
|
@ -1,5 +1,5 @@
|
|||||||
var util = require('util'),
|
var util = require('util'),
|
||||||
eventDb = require('./eventDb'),
|
eventDb = require('./db/event'),
|
||||||
EventEmitter = require('events').EventEmitter;
|
EventEmitter = require('events').EventEmitter;
|
||||||
|
|
||||||
function EventStore() {
|
function EventStore() {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
var eventDb = require('./eventDb');
|
var eventDb = require('../db/event');
|
||||||
var eventDiffer = require('./eventDiffer');
|
var eventDiffer = require('../eventDiffer');
|
||||||
|
|
||||||
module.exports = function (app) {
|
module.exports = function (app) {
|
||||||
app.get('/events', function (req, res) {
|
app.get('/events', function (req, res) {
|
@ -1,9 +1,9 @@
|
|||||||
var logger = require('./logger');
|
var logger = require('../logger');
|
||||||
var eventStore = require('./eventStore');
|
var eventStore = require('../eventStore');
|
||||||
var eventType = require('./eventType');
|
var eventType = require('../eventType');
|
||||||
var featureDb = require('./featureDb');
|
var featureDb = require('../db/feature');
|
||||||
var ValidationError = require('./error/ValidationError');
|
var ValidationError = require('../error/ValidationError');
|
||||||
var validateRequest = require('./error/validateRequest');
|
var validateRequest = require('../error/validateRequest');
|
||||||
|
|
||||||
module.exports = function (app) {
|
module.exports = function (app) {
|
||||||
app.get('/archive/features', function (req, res) {
|
app.get('/archive/features', function (req, res) {
|
@ -1,13 +1,13 @@
|
|||||||
var Promise = require("bluebird");
|
var Promise = require("bluebird");
|
||||||
var logger = require('./logger');
|
var logger = require('../logger');
|
||||||
var eventStore = require('./eventStore');
|
var eventStore = require('../eventStore');
|
||||||
var eventType = require('./eventType');
|
var eventType = require('../eventType');
|
||||||
var featureDb = require('./featureDb');
|
var featureDb = require('../db/feature');
|
||||||
var NameExistsError = require('./error/NameExistsError');
|
var NameExistsError = require('../error/NameExistsError');
|
||||||
var NotFoundError = require('./error/NotFoundError');
|
var NotFoundError = require('../error/NotFoundError');
|
||||||
var ValidationError = require('./error/ValidationError');
|
var ValidationError = require('../error/ValidationError');
|
||||||
var validateRequest = require('./error/validateRequest');
|
var validateRequest = require('../error/validateRequest');
|
||||||
var extractUser = require('./extractUser');
|
var extractUser = require('../extractUser');
|
||||||
|
|
||||||
module.exports = function (app) {
|
module.exports = function (app) {
|
||||||
app.get('/features', function (req, res) {
|
app.get('/features', function (req, res) {
|
@ -1,5 +1,5 @@
|
|||||||
var knex = require('./dbPool');
|
var knex = require('../db/dbPool');
|
||||||
var logger = require('./logger');
|
var logger = require('../logger');
|
||||||
|
|
||||||
module.exports = function (app) {
|
module.exports = function (app) {
|
||||||
app.get('/health', function (req, res) {
|
app.get('/health', function (req, res) {
|
11
lib/routes/index.js
Normal file
11
lib/routes/index.js
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
/**
|
||||||
|
* TODO: we should also inject config and
|
||||||
|
* services to the routes to ease testing.
|
||||||
|
**/
|
||||||
|
exports.create = function (app) {
|
||||||
|
require('./event')(app);
|
||||||
|
require('./feature')(app);
|
||||||
|
require('./feature-archive')(app);
|
||||||
|
require('./strategy')(app);
|
||||||
|
require('./health-check')(app);
|
||||||
|
};
|
@ -1,13 +1,13 @@
|
|||||||
var Promise = require("bluebird");
|
var Promise = require("bluebird");
|
||||||
var eventStore = require('./eventStore');
|
var eventStore = require('../eventStore');
|
||||||
var eventType = require('./eventType');
|
var eventType = require('../eventType');
|
||||||
var strategyDb = require('./strategyDb');
|
var strategyDb = require('../db/strategy');
|
||||||
var logger = require('./logger');
|
var logger = require('../logger');
|
||||||
var NameExistsError = require('./error/NameExistsError');
|
var NameExistsError = require('../error/NameExistsError');
|
||||||
var ValidationError = require('./error/ValidationError');
|
var ValidationError = require('../error/ValidationError');
|
||||||
var NotFoundError = require('./error/NotFoundError');
|
var NotFoundError = require('../error/NotFoundError');
|
||||||
var validateRequest = require('./error/validateRequest');
|
var validateRequest = require('../error/validateRequest');
|
||||||
var extractUser = require('./extractUser');
|
var extractUser = require('../extractUser');
|
||||||
|
|
||||||
module.exports = function (app) {
|
module.exports = function (app) {
|
||||||
app.get('/strategies', function (req, res) {
|
app.get('/strategies', function (req, res) {
|
@ -4,9 +4,9 @@ process.env.NODE_ENV = 'test';
|
|||||||
var Promise = require('bluebird');
|
var Promise = require('bluebird');
|
||||||
var request = require('supertest');
|
var request = require('supertest');
|
||||||
var app = require('../app');
|
var app = require('../app');
|
||||||
var knex = require('../lib/dbPool');
|
var knex = require('../lib/db/dbPool');
|
||||||
var featureDb = require('../lib/featureDb');
|
var featureDb = require('../lib/db/feature');
|
||||||
var strategyDb = require('../lib/strategyDb');
|
var strategyDb = require('../lib/db/strategy');
|
||||||
|
|
||||||
Promise.promisifyAll(request);
|
Promise.promisifyAll(request);
|
||||||
request = request(app);
|
request = request(app);
|
||||||
|
Loading…
Reference in New Issue
Block a user