'use strict';

const Boom = require('@hapi/boom');
const Rfr = require('rfr');

const knownMethods = ['GET', 'POST'];

module.exports = [
    ...Rfr('/server/sections/calls').routes,
    ...Rfr('/server/recording').routes,
    ...Rfr('/server/fe').routes,
    ...Rfr('/server/originate').routes,

    {
        method: '*',
        path: '/{p*}',
        handler: (request, h) => {
            if (knownMethods.includes(request.method.toUpperCase())) {
                return Boom.notFound();
            } else {
                return Boom.methodNotAllowed(undefined, undefined, knownMethods);
            }
        }
    }
];
