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'),
|
||||
logger = require('./lib/logger'),
|
||||
routes = require('./lib/routes'),
|
||||
eventApi = require('./lib/eventApi'),
|
||||
featureApi = require('./lib/featureApi'),
|
||||
featureArchiveApi = require('./lib/featureArchiveApi'),
|
||||
strategyApi = require('./lib/strategyApi'),
|
||||
validator = require('express-validator'),
|
||||
app = express(),
|
||||
router = express.Router(), // eslint-disable-line
|
||||
@ -45,11 +41,8 @@ app.use(bodyParser.json({ strict: false }));
|
||||
|
||||
app.use(cookieParser());
|
||||
|
||||
eventApi(router);
|
||||
featureApi(router);
|
||||
featureArchiveApi(router);
|
||||
strategyApi(router);
|
||||
routes(router);
|
||||
routes.create(router);
|
||||
|
||||
app.use(baseUriPath, router);
|
||||
|
||||
module.exports = app;
|
||||
|
@ -1,4 +1,4 @@
|
||||
var logger = require('./logger');
|
||||
var logger = require('../logger');
|
||||
var nconf = require('nconf');
|
||||
var fs = require('fs');
|
||||
var ini = require('ini');
|
@ -1,8 +1,8 @@
|
||||
var eventStore = require('./eventStore');
|
||||
var eventType = require('./eventType');
|
||||
var logger = require('./logger');
|
||||
var eventStore = require('../eventStore');
|
||||
var eventType = require('../eventType');
|
||||
var logger = require('../logger');
|
||||
var knex = require('./dbPool');
|
||||
var NotFoundError = require('./error/NotFoundError');
|
||||
var NotFoundError = require('../error/NotFoundError');
|
||||
var FEATURE_COLUMNS = ['name', 'description', 'enabled', 'strategy_name', 'parameters'];
|
||||
|
||||
eventStore.on(eventType.featureCreated, function (event) {
|
@ -1,8 +1,8 @@
|
||||
var eventStore = require('./eventStore');
|
||||
var eventType = require('./eventType');
|
||||
var logger = require('./logger');
|
||||
var eventStore = require('../eventStore');
|
||||
var eventType = require('../eventType');
|
||||
var logger = require('../logger');
|
||||
var knex = require('./dbPool');
|
||||
var NotFoundError = require('./error/NotFoundError');
|
||||
var NotFoundError = require('../error/NotFoundError');
|
||||
var STRATEGY_COLUMNS = ['name', 'description', 'parameters_template'];
|
||||
|
||||
eventStore.on(eventType.strategyCreated, function (event) {
|
@ -1,5 +1,5 @@
|
||||
var util = require('util'),
|
||||
eventDb = require('./eventDb'),
|
||||
eventDb = require('./db/event'),
|
||||
EventEmitter = require('events').EventEmitter;
|
||||
|
||||
function EventStore() {
|
||||
|
@ -1,5 +1,5 @@
|
||||
var eventDb = require('./eventDb');
|
||||
var eventDiffer = require('./eventDiffer');
|
||||
var eventDb = require('../db/event');
|
||||
var eventDiffer = require('../eventDiffer');
|
||||
|
||||
module.exports = function (app) {
|
||||
app.get('/events', function (req, res) {
|
@ -1,9 +1,9 @@
|
||||
var logger = require('./logger');
|
||||
var eventStore = require('./eventStore');
|
||||
var eventType = require('./eventType');
|
||||
var featureDb = require('./featureDb');
|
||||
var ValidationError = require('./error/ValidationError');
|
||||
var validateRequest = require('./error/validateRequest');
|
||||
var logger = require('../logger');
|
||||
var eventStore = require('../eventStore');
|
||||
var eventType = require('../eventType');
|
||||
var featureDb = require('../db/feature');
|
||||
var ValidationError = require('../error/ValidationError');
|
||||
var validateRequest = require('../error/validateRequest');
|
||||
|
||||
module.exports = function (app) {
|
||||
app.get('/archive/features', function (req, res) {
|
@ -1,13 +1,13 @@
|
||||
var Promise = require("bluebird");
|
||||
var logger = require('./logger');
|
||||
var eventStore = require('./eventStore');
|
||||
var eventType = require('./eventType');
|
||||
var featureDb = require('./featureDb');
|
||||
var NameExistsError = require('./error/NameExistsError');
|
||||
var NotFoundError = require('./error/NotFoundError');
|
||||
var ValidationError = require('./error/ValidationError');
|
||||
var validateRequest = require('./error/validateRequest');
|
||||
var extractUser = require('./extractUser');
|
||||
var logger = require('../logger');
|
||||
var eventStore = require('../eventStore');
|
||||
var eventType = require('../eventType');
|
||||
var featureDb = require('../db/feature');
|
||||
var NameExistsError = require('../error/NameExistsError');
|
||||
var NotFoundError = require('../error/NotFoundError');
|
||||
var ValidationError = require('../error/ValidationError');
|
||||
var validateRequest = require('../error/validateRequest');
|
||||
var extractUser = require('../extractUser');
|
||||
|
||||
module.exports = function (app) {
|
||||
app.get('/features', function (req, res) {
|
@ -1,5 +1,5 @@
|
||||
var knex = require('./dbPool');
|
||||
var logger = require('./logger');
|
||||
var knex = require('../db/dbPool');
|
||||
var logger = require('../logger');
|
||||
|
||||
module.exports = function (app) {
|
||||
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 eventStore = require('./eventStore');
|
||||
var eventType = require('./eventType');
|
||||
var strategyDb = require('./strategyDb');
|
||||
var logger = require('./logger');
|
||||
var NameExistsError = require('./error/NameExistsError');
|
||||
var ValidationError = require('./error/ValidationError');
|
||||
var NotFoundError = require('./error/NotFoundError');
|
||||
var validateRequest = require('./error/validateRequest');
|
||||
var extractUser = require('./extractUser');
|
||||
var eventStore = require('../eventStore');
|
||||
var eventType = require('../eventType');
|
||||
var strategyDb = require('../db/strategy');
|
||||
var logger = require('../logger');
|
||||
var NameExistsError = require('../error/NameExistsError');
|
||||
var ValidationError = require('../error/ValidationError');
|
||||
var NotFoundError = require('../error/NotFoundError');
|
||||
var validateRequest = require('../error/validateRequest');
|
||||
var extractUser = require('../extractUser');
|
||||
|
||||
module.exports = function (app) {
|
||||
app.get('/strategies', function (req, res) {
|
@ -4,9 +4,9 @@ process.env.NODE_ENV = 'test';
|
||||
var Promise = require('bluebird');
|
||||
var request = require('supertest');
|
||||
var app = require('../app');
|
||||
var knex = require('../lib/dbPool');
|
||||
var featureDb = require('../lib/featureDb');
|
||||
var strategyDb = require('../lib/strategyDb');
|
||||
var knex = require('../lib/db/dbPool');
|
||||
var featureDb = require('../lib/db/feature');
|
||||
var strategyDb = require('../lib/db/strategy');
|
||||
|
||||
Promise.promisifyAll(request);
|
||||
request = request(app);
|
||||
|
Loading…
Reference in New Issue
Block a user