
Security News
PEP 810 Proposes Explicit Lazy Imports for Python 3.15
An opt-in lazy import keyword aims to speed up Python startups, especially CLIs, without the ecosystem-wide risks that sank PEP 690.
@colucom/osseus-router
Advanced tools
JSON Routes (for osseus) based osseus module to work with osseus-server
$ npm install @colucom/osseus-router
Mandatory:
OSSEUS_ROUTER_DEPENDENCIES
Optional:
OSSEUS_ROUTER_ROUTES_PATH
./routes
OSSEUS_ROUTER_CONTROLLERS_PATH
./contollers
OSSEUS_ROUTER_POLICY_PATH
./policy
OSSEUS_ROUTER_URL_PREFIX
OSSEUS_ROUTER_CONTROLLER_NAME_NO_UPPERCASE
true
in order for contorller names not to begin with uppercase (which is the default)/routes/examples.json
:
{
"/example": {
"GET": {
"policy": "global:firstPolicy",
"route": "exampleGET"
},
"POST": {
"policy": [
"global:firstPolicy",
"global:secondPolicy"
],
"route": "./controllers/AnotherController:examplePOST"
}
}
}
Note
By default all routes in /routes/example.json
are assumed to be in /controllers/ExamplesController.js
but in case you want to use a route from another controller need to specify its location
/policy/global.js
:
module.exports = (osseus) => {
return {
firstPolicy: (req, res, next) => {
req.policies = req.policies || []
req.policies.push('firstPolicy')
next()
},
secondPolicy: (req, res, next) => {
req.policies = req.policies || []
req.policies.push('secondPolicy')
next()
}
}
}
/controllers/ExamplesController.js
:
module.exports = (osseus) => {
return {
examplePOST: (req, res, next) => {
res.send({called: 'examplePOST', policies: req.policies})
}
}
}
/controllers/AnotherController.js
:
module.exports = (osseus) => {
return {
examplePOST: (req, res, next) => {
res.send({called: 'examplePOST', policies: req.policies})
}
}
}
Running:
$ node index.js --OSSEUS_SERVER_PORT 8080
Will start your application and listen on 8080.
Now, let's send some test requests and see what we get:
$ curl 0:3000/example
will result in:
$ {"called":"exampleGET","policies":["firstPolicy"]}
and:
$ curl -XPOST 0:3000/example
will result in:
$ {"called":"examplePOST","policies":["firstPolicy","secondPolicy"]}
More detailed examples can be found here
Please see contributing guidelines.
Code released under the MIT License.
FAQs
Osseus Router
The npm package @colucom/osseus-router receives a total of 0 weekly downloads. As such, @colucom/osseus-router popularity was classified as not popular.
We found that @colucom/osseus-router demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
An opt-in lazy import keyword aims to speed up Python startups, especially CLIs, without the ecosystem-wide risks that sank PEP 690.
Security News
Socket CEO Feross Aboukhadijeh discusses the recent npm supply chain attacks on PodRocket, covering novel attack vectors and how developers can protect themselves.
Security News
Maintainers back GitHub’s npm security overhaul but raise concerns about CI/CD workflows, enterprise support, and token management.