Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 'use strict';
- var routes = [
- {
- method: 'GET',
- path: '/route1',
- handler: function (req, reply) {
- reply('route1');
- }
- }, {
- method: 'GET',
- path: '/route2',
- handler: function (req, reply) {
- reply('route2');
- }
- }, {
- method: 'GET',
- path: '/route3',
- function (req, reply) {
- reply('route3');
- }
- }
- ];
- var extend = require('lodash/object/extend');
- var flatten = require('lodash/array/flatten');
- var locales = ['/fr', '/cn', '/uk'];
- var prefixRoutes = function prefixRoutes() {
- var newRoutes = routes.map(function (rte) {
- return locales.map(function (loc) {
- var newRte = extend({}, rte);
- newRte.path = loc + newRte.path;
- return newRte;
- });
- });
- return flatten(newRoutes);
- };
- module.exports = prefixRoutes();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement