app2-api/core/router.js
2019-07-09 22:13:41 +02:00

36 lines
746 B
JavaScript

'use strict';
const express = require('express');
const glob = require('glob');
const path = require('path');
const modulesDir = path.resolve(__dirname + '/../modules/')
const globOptions = {
cwd: modulesDir,
nocase: true,
nodir: true,
absolute: true,
}
module.exports = function () {
const router = express.Router({ mergeParams: true });
router.get('/_health', (req, res, next) => {
res.json({
code: 200,
message: 'success',
description: 'Welcome, this is the API for the application.'
});
});
glob.sync("**/*.routes.js", globOptions)
.forEach(function (file) {
router.use('/v2', require(file));
});
return router;
}