Maybe I am just referring to Sails which uses express.js under the covers. In the stuff I have done, all the routes and configured in a JSON (and do require a restart when changed):
For example:
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) *
* *
***************************************************************************/
//'/': {
// view: 'homepage'
//}
// Passport control
'get /homepage': 'AuthController.homepage',
'get /dashboard': 'AuthController.dashboard',
'get /logout': 'AuthController.logout',
'get /register': 'AuthController.register',
'post /auth/local': 'AuthController.callback',
'post /auth/local/:action': 'AuthController.callback',
'get /auth/:provider': 'AuthController.provider',
'get /auth/:provider/callback': 'AuthController.callback',
// Normal processing
'get /': 'PageController.validateRequest',
// Profiles
'get /profile': 'AuthController.profile',
'post /updateprofile': 'AuthController.updateProfile',
'get /reset': {view:'reset'},
'post /auth/passwordreset': 'AuthController.passwordReset',
// Bookings
'get /booking' : 'BookingController.prepareBooking',
'get /booking/:action': 'BookingController.prepareBooking',
'get /mybookings': 'BookingController.myBookings',
'get /allmybookings/:filter?': 'BookingController.allMyBookings', // the ? in :filter? means that the filter part or the URL is optional
'get /eventbookings': 'BookingController.eventBookings',
'get /alleventbookings/:filter?': 'BookingController.allEventBookings',
'get /userbookings': 'BookingController.userBookings',
'get /alluserbookings/:filter?': 'BookingController.allUserBookings',
'post /makebooking': 'BookingController.makeBooking',
'post /makebooking/:action?': 'BookingController.makeBooking',
'get /linkedbooking/:bookingid': 'LinkedBookingController.linkedBookings',
'post /validateadditions': 'BookingController.validateAdditions',
'post /updatebooking/:action': 'BookingController.updateBooking',
// Users
'get /users': 'UserController.users',
'get /allusers/:filter?': 'UserController.allUsers', // the ? in :filter? means that the filter part or the URL is optional
'get /usermaint/:action': 'UserController.prepareUser',
'post /updateuser/:action': 'UserController.updateUser',
'get /organisers': 'UserController.organisers',
// Events
'get /events': 'EventController.events',
'get /openevents': 'EventController.openEvents',
'get /allevents/:filter?': 'EventController.allEvents', // the ? in :filter? means that the filter part or the URL is optional
'get /event/:action': 'EventController.prepareEvent',
'post /updateevent/:action': 'EventController.updateEvent',
/***************************************************************************
* *
* 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. *
* *
***************************************************************************/
};
-----Original Message-----
From: WEB400 [mailto:web400-bounces@xxxxxxxxxxxx] On Behalf Of Nathan Andelin
Sent: 14 October 2015 13:46
To: Web Enabling the IBM i (AS/400 and iSeries) <web400@xxxxxxxxxxxx>
Subject: Re: [WEB400] Hosting a Large Number of Node Apps on the IBM i
This is by you would probably go for a library like express.js - which
will already have this problem cracked. I can't describe how as I
have only just started using it, but I know you would have a rather
large routing config file.
IIRC, all the Express.js examples I've seen use inline JavaScript to perform routing as opposed to a "large routing config file". For example:
var express = require('express');var app = express();
app.get('/', function(req, res){
res.send('hello world');});
app.listen(3000);
In that example, it appears that any "GET" request to the ROOT URL "/" is routed to a JavaScript function which sends "hello world".
How would you manage 20,000+ URLs? Restart your "service" each time you add a new route to inline code?
--
This is the Web Enabling the IBM i (AS/400 and iSeries) (WEB400) mailing list To post a message email: WEB400@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options,
visit:
http://lists.midrange.com/mailman/listinfo/web400
or email: WEB400-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives at
http://archive.midrange.com/web400.
___________________________________________
This email has been scanned by iomartcloud.
http://www.iomartcloud.com/
________________________________
NOTICE: The information in this electronic mail transmission is intended by CoralTree Systems Ltd for the use of the named individuals or entity to which it is directed and may contain information that is privileged or otherwise confidential. If you have received this electronic mail transmission in error, please delete it from your system without copying or forwarding it, and notify the sender of the error by reply email or by telephone, so that the sender's address records can be corrected.
--------------------------------------------------------------------------------
CoralTree Systems Limited
25 Barnes Wallis Road
Segensworth East, Fareham
PO15 5TT
Company Registration Number 5021022.
Registered Office:
12-14 Carlton Place
Southampton, UK
SO15 2EA
VAT Registration Number 834 1020 74.
As an Amazon Associate we earn from qualifying purchases.