
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
A Typescript compatible file based router for Node.js.
Made for sending json and getting json.
$ npm i perstorp
Make sure to create a file named perstorp.config.json in the root of your project.
It should look something like this:
{
"cors": {
"origin": "*",
"methods": "GET,POST,PUT,DELETE",
"headers": "Content-Type,Authorization"
},
"routesPath": "/api/v1/routes",
"logger": true,
"timeout": 1000,
"typescript": true
}
import perstorp from "perstorp";
const PORT = 3000;
const app = perstorp();
app.listen(PORT, () => {
console.log(`Server is running on port ${PORT}`);
});
In order to create a route you just create a new directory in the directory that you specified in the perstorp.config.json. Create a file called index.ts in the new directory.
/api/v1/routes/hello/index.ts
The function has to have the name get
import type { ReqHandler } from "perstorp";
export const get: ReqHandler = ({ res }) => {
res.json({ message: "World" });
};
To get the data that is sent with the request just use the data parameter in your request handler.
import type { ReqHandler } from "perstorp";
export const post: ReqHandler = ({ res, data }) => {
console.log(data); // Outputs json recieved in the request
res.json({ message: "World" });
};
To get the search params for the request just use the params parameter in your request handler
import type { ReqHandler } from "perstorp";
export const post: ReqHandler = ({ res, params }) => {
console.log(params); // Outputs search params
res.json({ message: "World" });
};
Use the json function on the res object
import type { Reqhandler } from "perstorp";
export const get: ReqHandler = ({ res }) => {
res.json({ message: "World" }); // No need to stringify it. Perstorp does that for you.
};
Use the context object to store things you might want to use in your handlers
index.ts
import perstorp from "perstorp";
import SomethingYouNeed from "somethingyouneed";
const PORT = 3000;
const somethingYouNeed = new SomethingYouNeed();
const app = perstorp({ somethingYouNeed });
app.listen(PORT, () => {
console.log(`Server is running on port ${PORT}`);
});
the handler
import type { ReqHandler } from "perstorp";
export const get: ReqHandler = ({ res, context }) => {
const { somethingYouNeed } = context;
res.json({ message: "World" });
};
FAQs
A file based routing library
The npm package perstorp receives a total of 0 weekly downloads. As such, perstorp popularity was classified as not popular.
We found that perstorp demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 0 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
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.