sails-application-generator
Version:
command line tool
150 lines (146 loc) • 5.15 kB
JavaScript
/**
* Route Mappings
* (sails.config.routes)
*
* Your routes map URLs to views and controllers.
*
* If Sails receives a URL that doesn't match any of the routes below,
* it will check for matching files (images, scripts, stylesheets, etc.)
* in your assets directory. e.g. `http://localhost:1337/images/foo.jpg`
* might match an image file: `/assets/images/foo.jpg`
*
* Finally, if those don't match either, the default 404 handler is triggered.
* See `api/responses/notFound.js` to adjust your app's 404 logic.
*
* Note: Sails doesn't ACTUALLY serve stuff from `assets`-- the default Gruntfile in Sails copies
* flat files from `assets` to `.tmp/public`. This allows you to do things like compile LESS or
* CoffeeScript for the front-end.
*
* For more information on configuring custom routes, check out:
* http://sailsjs.org/#/documentation/concepts/Routes/RouteTargetSyntax.html
*/
var _ = require('lodash');
module.exports.routes = {
/***************************************************************************
* *
* Make the view located at `views/homepage.ejs` (or `views/homepage.jade`, *
* etc. depending on your default view engine) your home page. *
* *
* (Alternatively, remove this and add an `index.html` file in your *
* `assets` directory) *
* *
***************************************************************************/
'post /login' : {
controller: 'AuthController',
action: 'login'
},
// For Testing
'get /users_list': {
controller: 'UserdetailsController',
action: 'get_users',
skipAssets: 'true',
//swagger path object
swagger: {
methods: ['GET'],
summary: ' Get Users',
description: 'Get user list',
produces: [
'application/json'
],
responses: {
'200': {
type: 'array'
}
},
parameters: 'id'
}
},
'post /create_user' : {
controller: 'UserdetailsController',
action: 'create_user',
skipAssets: 'true',
//swagger path object
swagger: {
methods: ['POST'],
produces: [
'application/json'
],
responses: {
'201': {
type: 'object'
}
},
parameters: 'id'
}
},
'put /update_user/:id' : {
controller: 'UserdetailsController',
action: 'update_user',
skipAssets: 'true',
//swagger path object
swagger: {
methods: ['PUT'],
produces: [
'application/json'
],
responses: {
'200': {
type: 'array'
}
},
parameters: 'id'
}
},
'delete /delete_user/:id' : {
controller: 'UserdetailsController',
action: 'delete_user',
skipAssets: 'true',
//swagger path object
swagger: {
methods: ['DELETE'],
produces: [
'application/json'
],
responses: {
'200': {
type: 'array'
}
},
parameters: 'id'
}
},
'post /createJob' : {
controller: 'JobScheduleController',
action: 'createJob',
skipAssets: 'true',
//swagger path object
swagger: {
methods: ['POST', 'GET', 'PUT'],
produces: [
'application/json'
],
responses: {
'200': {
type: 'array'
}
},
parameters: 'id'
}
}
/***************************************************************************
* *
* Custom routes here... *
* *
* If a request to a URL doesn't match any of the custom routes above, it *
* is matched against Sails route blueprints. See `config/blueprints.js` *
* for configuration options and examples. *
* *
***************************************************************************/
};
const authRoutes = require('./otherRoutes');
_.each(authRoutes, function (target, address) {
if (module.exports.routes[address]) {
throw new Error('Consistency violation: Looks like we ended up with a duplicate route (`'+address+'`) somehow!');
}
module.exports.routes[address] = target;
});