
Research
Malicious npm Packages Impersonate Flashbots SDKs, Targeting Ethereum Wallet Credentials
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
fastify-fs-route
Advanced tools
It is easier to add routes and schemes the validation of these routes
This plugin will help you add routes and validation schemes to these routes
npm i fastify-fs-route
const fastify = require("fastify")()
fastify.register(require("fastify-fs-route"){dirRoutes:"./routes",dirSchemas:"./schemas", folderAsPrefix: true | false, prefix:"/foo"})
//The first parameter is the path to the directory with routes.
//The second parameter is the path to the directory with schemas.
//The third parameter is responsible for whether folders in the directory with routes will be used as a prefix to your paths.
//Example, in the "routes/api/something.js" your link will look like "/api/something", if set to false the link will look like /something (default - false).
//Prefix for all routes.
fastify.listen(3000)
IMPORTANT if you want to connect the validation scheme to your route you need to create a json file and name it the same as your route and it should be located in the folder with the same name as in the routes
Adding a route
function findUser(request,reply){
//you're code
}
//To add a route you need to export it by specifying the request method and your function
module.exports = {
post: findUser,
//or array
//In the array, you can pass parameters such as {prefix: "/foo", params:"/:id"} you also add your own validation scheme or event handlers such as onRequest (request,reply,done) be sure to call the done function.
//You can see more handlers in the official fastify documentation
//See the example below
post: [
{prefix:"/foo",params:"/:id",onRequest:(req,rep,done)=>{
console.log("request")
done()},
schema:{body:{type:'object', properties:{email:{type:'string'}}}},
findUser
],
//all options in curly brackets are optional
get:[{},findUser], //working
//You can also pass just one more route as a parameter and the prefix can be a parameter
post:[
{prefix:"/:id", params:"/foo"}
findUser
]
}
Adding a schema
For each route method, you can do validation. Be sure to specify the method that you use for the route, otherwise the route will not be validated.
{
"post": {
"schema": {
"body": {
"type": "object",
"required": ["email"],
"properties": {
"email": {
"type": "string"
}
}
}
}
},
"get":{
"schema":{
"querystring":{
"type":"object",
"properties":{
"name":{
"type":"string"
}
}
}
}
}
}
}
FAQs
It is easier to add routes and schemes the validation of these routes
We found that fastify-fs-route demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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.
Research
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.