atsid / express-jefferson Goto Github PK
View Code? Open in Web Editor NEWDeclarative Application Routing
License: Apache License 2.0
Declarative Application Routing
License: Apache License 2.0
If the return type of the delegate middleware is not a promise and next()
has not been called, then the promise proxy should invoke next()
In the code example under routes in Configuration it reads past instead of post.
We've migrated our JS coding standards to use a modified AirBnb ruleset. We should migrate the .eslint we use in newer projects here.
{
premiddleware: {
all: [], // Middleware prepended to all routes
mutable: [], // Middleware prepended to POST,PUT,DELETE routes
immutable: [] // Middeware prepended to GET routes
},
postmiddleware: {
all: [], // Middleware postpended to all routes
mutable: [], // Middleware postpended to POST,PUT,DELETE routes
immutable: [] // Middeware postpended to GET routes
}
}
There's a lot of boilerplate in the text of the config file itself that can be streamlined out, namely the route name and the 'path, method, and middleware' keys.
{
routes: {
'/things': {
get: [retrieveThings]
post: [createThing]
},
'/things/:id': {
get: [getThing],
put: [editThing]
patch: [editThing]
}
}
}
Coffeescript fat arrow functions result in fn.length === 0
. This breaks promise detection.
Let's add a 'parameteResolvers' config section that invokes app.param() http://expressjs.com/4x/api.html#app.param
{
parameterResolvers: [{
parameter: "id",
resolver: (req, res, next, id) => User.findById(id).then((found) => {
res.foundUser = found;
next();
});
}],
routes: {
getUser: {
method: 'GET'
path: "/:id",
middleware: [ // asssume req.foundUser is populated ]
}
}
}
We've noticed some interesting traffic patterns on one of our applications within the last month where users are scripting against the same API endpoint every 10 seconds. We should add the capability to throttle consumers of APIs to prevent abuse patterns like this.
This would allow smaller applications to simplify their boilerplate considerably, by removing manual app creation.
Ideas:
regexRoutes: [
{ regex: /my_regex/, middleware: [] }
]
aliases: {
myRegex: /my_regex/
},
routes: {
'alias::myRegex': {
get: []
}
}
e.g.
subchains: {
processAndTransmit: [
processEntity,
addLinksToEntity,
transmitEntity,
]
},
routes: {
getBeer: {
getBeer,
'processAndTransmit'
}
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.