/**
* @module libflitter/templates/router
*/
/**
* Get the contents of a new router definition file with the specified object name.
* @param {string} name - the name of the router definition object
* @returns {string}
*/
module.exports = exports = (name) => {
return `/*
* ${name} Routes
* -------------------------------------------------------------
* Put some description here!
*/
const ${name} = {
/*
* Define the prefix applied to each of these routes.
* For example, if prefix is '/auth':
* '/' becomes '/auth'
* '/login' becomes '/auth/login'
*/
prefix: '/${name.toLowerCase()}',
/*
* Define middleware that should be applied to all
* routes defined in this file. Middleware should be
* included using Flitter's global mw() function, but
* it can also be added directly using require().
*/
middleware: [
// 'Middleware Name',
],
/*
* Define GET routes.
* These routes are registered as GET methods.
* Handlers for these routes should be specified as
* an array of functions that are applied in order.
*
* You should refer to middleware and controller methods
* by their fully-qualified canonical names. For example:
*
* controller::auth:Forms.login_get
* middleware::auth:UserOnly
*/
get: {
// '/': ['controller::Controller_Name.handler_name'],
},
/*
* Define POST routes.
* These routes are registered as POST methods.
* Handlers for these routes should be specified as
* an array of functions that are applied in order.
*
* mw() calls apply Flitter middleware
* controller() calls get methods in Flitter controllers
*/
post: {
},
// Supports get, post, patch, put, delete, &c.
}
module.exports = exports = ${name}`
}