-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathversion.js
32 lines (25 loc) · 995 Bytes
/
version.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
'use strict';
const Boom = require('@hapi/boom')
const Config = require('../config')
const Cors = require('../utils/cors')
const VersionController = require('../controllers/version');
const versionRedirect = {
name: 'version-redirect-route',
version: '1.0.0',
register: async function (server, options) {
const controller = new VersionController();
server.bind(controller);
server.route({
method: '*',
path: '/{any*}',
handler: controller.redirect,
options: {
description: "Redirects or 404s",
notes: 'Redirects the request to the newest available version of the endpoint as well as serving the 404 page as a fallback',
// tags: ['api'], not intended to be part of swagger - mainly because the plugin that generates this fails to handle this route definition.
cors: Cors
}
});
}
};
module.exports = versionRedirect;