I haven't used express.js on its own, but your suggestion is very easy to implement in Sails. Whether or not that is Sails augmenting Express or simply exposing what it already does I don't know - but you can configure what parts of the endpoint are what in the routing.
For example:
'get /model/:app/:action': 'MyController.handleRequest'
Means that
http://example.com/model/nathansapp/create?foo=bar
Would end up in the handleRequest function of MyController, where you can do this:
var app=req.param("app"); // Returns "nathansapp"
var action=req.param("action"); // Returns "create"
-----Original Message-----
From: WEB400 [mailto:web400-bounces@xxxxxxxxxxxx] On Behalf Of Nathan Andelin
Sent: 02 September 2015 19:10
To: Web Enabling the IBM i (AS/400 and iSeries)
Subject: Re: [WEB400] What is an Express.JS App?
Aaron,
Thanks for the link. It still seems to me the the noun "app" is something of a misnomer for the value returned by express(). I've considered a couple
alternatives:
router = express();
Request "routing" is a primary function of Express.JS. But it also includes additional middleware, so perhaps a non-descriptive word may be more appropriate, such as:
express = express().
I saw from the link you posted various ways to modularize "routing" code.
But it all seems to boil down to calling a function:
express.get("/path/...", callback(request, response) {...});
Given my previous scenario of deploying say 500 "applications" with each scoped to handle 15 "requests" on average, it may take up to 1,500 calls to:
express.get()
with each call comparing the URL "path" from a list of alternatives, in order to resolve the "route" to the appropriate handler. That seems like a lot of function calls and string comparisons.
I'm thinking of an alternative. Say a URL includes both an "application"
and a requested "action", say:
http://example.com/application_id/action_id
Where "application_id" points to a reference in a database table. So that "routing" becomes more of a matter of retrieving some metadata from a table keyed by "application_id"?
On Wed, Sep 2, 2015 at 7:38 AM, Aaron Bartell <aaronbartell@xxxxxxxxx>
wrote:
Using Express.JS, would you deploy 500+ HTTP server instances?
You could, or you could create a /routes folder in your application
structure and create a separate file for each "application".
Further info: http://bit.ly/1Na87Ev
Aaron Bartell
litmis.com - Open Source and IBM i. No Limits.
On Wed, Sep 2, 2015 at 8:35 AM, Nathan Andelin <nandelin@xxxxxxxxx> wrote:
The basis of my question is the "Hello World" example at:
http://expressjs.com/starter/hello-world.html
It's just 10 lines of code. One of the relevant statements is:
var app = express();
Which is followed by:
var server = app.listen(3000, function () {
The app.listen() method appears to be instantiating an HTTP
services. Is that to say that each express.js application includes
its own HTTP
service?
Personally, I tend to scope Web "applications" to handle perhaps
10-15 distinct types of requests. An application for querying and
maintaining Purchase Orders would be distinct from one which queries
and maintains
Work
Requests, for example. That keeps the code modular.
We have deployed 500+ "applications" of that type of scope.
Using Express.JS, would you deploy 500+ HTTP server instances?
--
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 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 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
Company Registration Number 5021022.
Registered Office:
12-14 Carlton Place
Southampton
Hampshire
SO15 2EA
VAT Registration Number 834 1020 74.
As an Amazon Associate we earn from qualifying purchases.