Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
express-file-router-2
Advanced tools
An express router that allows you to use the file system to create routes.
npm install express-file-router
You can integrate the file router by using it as a middleware like this:
app.use(
"/api",
await FileRouter(
{
ROUTES_DIR: "/routes", // directory of your routes
debug: true, // simple console.log's
},
__dirname
)
);
import express from "express";
import cors from "cors";
import bodyParser from "body-parser";
import { createServer } from "http";
import FileRouter from "@ij/express-file-router";
async function init(): Promise<void> {
process.on("uncaughtException", (err) => {
console.log(err);
});
const app = express();
app.use(cors());
app.use(
bodyParser.json({
limit: "50mb",
})
);
app.use(bodyParser.urlencoded({ extended: true, limit: "50mb" }));
app.use(
"/api",
await FileRouter(
{
ROUTES_DIR: "/routes",
debug: true,
},
__dirname
)
);
const server = createServer(app);
const port = 3080;
server.listen(port, () => console.log(`Server listening on port ${port}`));
}
init();
├── index.ts // main file
├── routes
├── get.ts // get
├── dynamic // params
├── param
├── [example].ts // single
└── [...slug].ts // get all
└── post.ts // post
You are able to add route specific middlewares by exporting an array like this:
Post Example
import { RequestHandler } from "express";
import UserSession from "@/middleware/session/user";
export const post = [
// inside of file
async (req, res, next) => {
console.log("headers", req.headers);
return next();
},
// imported middelware from file
UserSession,
async (req, res) => {
const { userID } = req.params;
console.log("req.params", req.params);
return res.status(200).json({
message: "Success",
userID,
});
},
] as RequestHandler[];
Get Example
import { RequestHandler } from "express";
import UserSession from "@/middleware/session/user";
export const get = [
// inside of file
async (req, res, next) => {
console.log("headers", req.headers);
return next();
},
// imported middelware from file
UserSession,
async (req, res) => {
const { userID } = req.params;
console.log("req.params", req.params);
return res.status(200).json({
message: "Success",
userID,
});
},
] as RequestHandler[];
FAQs
An express router that allows you to use the file system to create routes.
The npm package express-file-router-2 receives a total of 0 weekly downloads. As such, express-file-router-2 popularity was classified as not popular.
We found that express-file-router-2 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
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.