jeffijoe / awilix-router-core Goto Github PK
View Code? Open in Web Editor NEWReusable building blocks for writing Awilix router adapters for HTTP frameworks.
License: MIT License
Reusable building blocks for writing Awilix router adapters for HTTP frameworks.
License: MIT License
As I'm temporarily using plain NodeJS to migrate old code to awilix
before moving to Typescript based code, I was wondering if it is possible to implement a startup validation for this module? Currently running into continuous methods which are missing, which Im trying to fix with unit and end-to-end testing (quite a slow method).
Startup validation would basically require looping over and checking whether the controller method or class has the functions indicated in the builder pattern and throwing an error when its missing. Does this sound doable to you? If not, its no problem to close the issue.
Hey,
thanks for this nice library!
Unfortunately this does not run out-of-the box (a.k.a. without babel) with Node and the "experimental modules" feature switched on.
It breaks on the following line - where you require a module instead of importing it.
When I switch the whole project to esm with this line in package.json:
"type": "module",
Then everything works... except the line I mentioned above.
But changing that line to
import(path).then(required => { ... }
Seems to work.
But since this router should be able to run in both worlds - modules and commonjs - there need to be some tuning here and there.
Do you have any experience with this?
awilix-router-core/src/state-util.ts
Line 322 in 5b6fd88
The route then takes on some very strange characteristics.
In my example:
GET /:id endpointFn
POST /:id/query endpointFn
Using middleware to coerce the payload from body to query so the same endpoint can handle body and provide a way around the maximum URL length.
I stumbled onto this requirement when POST /:id wasn't behaving as expected for someone and I told them this is not even a route and should return 404.
It was not..
I have not dug further into the WHY of the code beyond this point as I have simply re-written my code to go around the issue.
But, the replacement appears to introduce partial route matching such that invalid routes are no longer falling through to 404.
I would suggest 2 things:
Firstly, document this restriction in the readme as this library enforces a restriction that it is not making clear to the consumer (for me that is via awilix-express)
Secondly, investigate why partial route-matching is caused by the replacement or undo the decision to replace.
Once I removed the duplicate endpoint in the builder configuration the POST /:id call returned 404 as I would have expected.
master
branch failed. π¨I recommend you give this issue a high priority, so other packages depending on you could benefit from your bug fixes and new features.
You can find below the list of errors reported by semantic-release. Each one of them has to be resolved in order to automatically publish your package. Iβm sure you can resolve this πͺ.
Errors are usually caused by a misconfiguration or an authentication problem. With each error reported below you will find explanation and guidance to help you to resolve it.
Once all the errors are resolved, semantic-release will release your package the next time you push a commit to the master
branch. You can also manually restart the failed CI job that runs semantic-release.
If you are not sure how to resolve this, here is some links that can help you:
If those donβt help, or if this issue is reporting something you think isnβt right, you can always ask the humans behind semantic-release.
The npm token configured in the NPM_TOKEN
environment variable must be a valid token allowing to publish to the registry https://registry.npmjs.org/
.
If you are using Two-Factor Authentication, make configure the auth-only
level is supported. semantic-release cannot publish with the default auth-and-writes
level.
Please make sure to set the NPM_TOKEN
environment variable in your CI with the exact value of the npm token.
Good luck with your project β¨
Your semantic-release bot π¦π
prefix('shop/:shop_id').
get('/item/:item_id', 'shop_item')
shop/5c41b7bc52fd6700080461c6/item/5c49c024a72f4c00092a2495/properties
Any other alternative way around?
Something like nested routes in https://github.com/alexmingoia/koa-router
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.