app2-api/core/router.js

36 lines
749 B
JavaScript
Raw Normal View History

2019-04-15 10:13:17 +00:00
'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,
}
2019-04-15 15:58:58 +00:00
module.exports = function () {
2019-07-09 20:13:41 +00:00
const router = express.Router({ mergeParams: true });
2019-04-15 10:13:17 +00:00
2019-07-17 12:44:15 +00:00
router.get('/v2/_health', (req, res, next) => {
2019-04-15 10:13:17 +00:00
res.json({
code: 200,
message: 'success',
description: 'Welcome, this is the API for the application.'
});
});
2019-04-15 15:58:58 +00:00
glob.sync("**/*.routes.js", globOptions)
2019-04-15 10:13:17 +00:00
.forEach(function (file) {
router.use('/v2', require(file));
});
2019-04-15 10:13:17 +00:00
return router;
}