sjmeverett / express-decorators Goto Github PK
View Code? Open in Web Editor NEWES2015 decorators for express
ES2015 decorators for express
when using @route('GET', '/some-path')
, the register fails, since router['GET'] is undefined.
it should be router[route.method.toLowerCase()]
I'd love to see something similar for HapiJS!
Would you mind if I created a library based off this one, but for HapiJS? Or if you are planning to, I'd be willing to contribute/test.
Hello. Could you add an instruction to create a custom decorator? What issues I get: the context of the controller class is lost. Could you describe how do you use Reflect Metadata?
Regards.
We have a middleware to be shared among multiple controllers. We also want the middleware being called in every action.
@web.use
requires a member function as the middleware, which is not suitable.
@web.middleware
assigns middleware to a single action, which is not suitable as well.
I am not using TypeScript and would still like to use these decorators. Are they also functional when using Babel?
Thanks!
Hi, typescript newbie here.
I'm trying to use the module in my nodejs+expressjs+typescript backend app and it seems I need to install the reference via tsd install to make it work. Right? Or am I missing something?
Because when I compile my project, I get this
app/app.ts(8,23): error TS2307: Cannot find module 'express-decorators/load'.
I fully understand this is a ES6 module, but it seems really useful for my case too.
Thanks in advance!
an error handling middleware should be able to handle exceptions in the action, for example:
app.use((err, req, res, next) => {
// ....
});
However when using this module I only got:
Error: .....
at Handler.<anonymous> (....)
at ....../node_modules/express-decorators/index.js:45:38
the 'del' throws error during register, since router['del'] is undefined, I am using express 4.17.1
It should be route('delete', path, middleware)
Given the following code:
@web.get('/')
@web.middleware(a)
@web.middleware(b)
@web.middleware(c)
indexAction(req, res, next) { /* <…> */ }
Middlewares will be executed in such order: c → b → a. Which is not what you'd expect.
As a quick workaround, I changed the order in which I attach middlewares, but I guess it's something that could be addressed at library level.
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.