Explicit routes configuration

This commit is contained in:
Daniel García Aubert 2019-10-01 17:45:12 +02:00
parent 3dee09a5c5
commit 1d55de3e43
5 changed files with 69 additions and 61 deletions

View File

@ -62,21 +62,21 @@ module.exports = function serverFactory (statsClient) {
app.dataIngestionLogger = dataIngestionLogger;
// FIXME: health controller should be atached to the main entry point: "/"
// instead of "/api/v1/"
// instead of "/api/v1/" or "/user/:user/api/:version"
const healthCheckController = new HealthCheckController({
routes: global.settings.routes
routes: global.settings.routes.api
});
healthCheckController.route(app);
// FIXME: version controller should be atached to the main entry point: "/"
// instead of "/api/v1/"
// instead of "/api/:version" or "/user/:user/api/:version"
const versionController = new VersionController({
routes: global.settings.routes
routes: global.settings.routes.api
});
versionController.route(app);
const apiRouter = new ApiRouter({
routes: global.settings.routes,
routes: global.settings.routes.api,
redisPool,
metadataBackend,
statsClient,

View File

@ -2,21 +2,23 @@
// Disable by using <=0 value.
module.exports.gc_interval = 10000;
module.exports.routes = {
paths: [
// In case the base_url has a :user param the username will be the one specified in the URL,
// otherwise it will fallback to extract the username from the host header.
'/api/:version',
'/user/:user/api/:version',
],
// Attach middlewares at the begining of the req/res cycle
// to perform custom operations.
middlewares: [
function noop () {
return function noopMiddleware (req, res, next) {
next();
api: {
paths: [
// In case the base_url has a :user param the username will be the one specified in the URL,
// otherwise it will fallback to extract the username from the host header.
'/api/:version',
'/user/:user/api/:version',
],
// Attach middlewares at the begining of the req/res cycle
// to perform custom operations.
middlewares: [
function noop () {
return function noopMiddleware (req, res, next) {
next();
}
}
}
]
]
}
};
// If useProfiler is true every response will be served with an
// X-SQLAPI-Profile header containing elapsed timing for various

View File

@ -2,21 +2,23 @@
// Disable by using <=0 value.
module.exports.gc_interval = 10000;
module.exports.routes = {
paths: [
// In case the base_url has a :user param the username will be the one specified in the URL,
// otherwise it will fallback to extract the username from the host header.
'/api/:version',
'/user/:user/api/:version',
],
// Attach middlewares at the begining of the req/res cycle
// to perform custom operations.
middlewares: [
function noop () {
return function noopMiddleware (req, res, next) {
next();
api: {
paths: [
// In case the base_url has a :user param the username will be the one specified in the URL,
// otherwise it will fallback to extract the username from the host header.
'/api/:version',
'/user/:user/api/:version',
],
// Attach middlewares at the begining of the req/res cycle
// to perform custom operations.
middlewares: [
function noop () {
return function noopMiddleware (req, res, next) {
next();
}
}
}
]
]
}
};
// If useProfiler is true every response will be served with an
// X-SQLAPI-Profile header containing elapsed timing for various

View File

@ -2,21 +2,23 @@
// Disable by using <=0 value.
module.exports.gc_interval = 10000;
module.exports.routes = {
paths: [
// In case the base_url has a :user param the username will be the one specified in the URL,
// otherwise it will fallback to extract the username from the host header.
'/api/:version',
'/user/:user/api/:version',
],
// Attach middlewares at the begining of the req/res cycle
// to perform custom operations.
middlewares: [
function noop () {
return function noopMiddleware (req, res, next) {
next();
api: {
paths: [
// In case the base_url has a :user param the username will be the one specified in the URL,
// otherwise it will fallback to extract the username from the host header.
'/api/:version',
'/user/:user/api/:version',
],
// Attach middlewares at the begining of the req/res cycle
// to perform custom operations.
middlewares: [
function noop () {
return function noopMiddleware (req, res, next) {
next();
}
}
}
]
]
}
};
// If useProfiler is true every response will be served with an
// X-SQLAPI-Profile header containing elapsed timing for various

View File

@ -2,21 +2,23 @@
// Disable by using <=0 value.
module.exports.gc_interval = 10000;
module.exports.routes = {
paths: [
// In case the base_url has a :user param the username will be the one specified in the URL,
// otherwise it will fallback to extract the username from the host header.
'/api/:version',
'/user/:user/api/:version',
],
// Attach middlewares at the begining of the req/res cycle
// to perform custom operations.
middlewares: [
function noop () {
return function noopMiddleware (req, res, next) {
next();
api: {
paths: [
// In case the base_url has a :user param the username will be the one specified in the URL,
// otherwise it will fallback to extract the username from the host header.
'/api/:version',
'/user/:user/api/:version',
],
// Attach middlewares at the begining of the req/res cycle
// to perform custom operations.
middlewares: [
function noop () {
return function noopMiddleware (req, res, next) {
next();
}
}
}
]
]
}
};
// If useProfiler is true every response will be served with an
// X-SQLAPI-Profile header containing elapsed timing for various