![Create React App Officially Deprecated Amid React 19 Compatibility Issues](https://cdn.sanity.io/images/cgdhsj6q/production/04fa08cf844d798abc0e1a6391c129363cc7e2ab-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Create React App Officially Deprecated Amid React 19 Compatibility Issues
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
alta-express-file-routing
Advanced tools
Flexible system-based file routing for Express with 0
dependencies.
npm install express-file-routing
Note: If you prefer yarn
instead of npm
, just use yarn add express-file-routing
.
import express from "express"
import createRouter, { router } from "express-file-routing"
const app = express()
app.use("/", router()) // as router middleware or
createRouter(app) // as wrapper function
app.listen(2000)
Note: It uses your project's /routes
directory as source by default.
export default async (req, res) => {
if (req.method !== "GET") return res.status(404)
return res.status(200)
}
Files inside your project's /routes
directory will get matched an url path automatically.
├── app.ts
├── routes
├── index.ts // index routes
├── posts
├── index.ts
└── :id.ts or [id].ts // dynamic params
└── users.ts
└── package.json
/routes/index.ts
→ //routes/posts/index.ts
→ /posts/routes/posts/[id].ts
→ /posts/:id/routes/users.ts
→ /userscreateRouter(app, {
directory: path.join(__dirname, "routes"),
additionalMethods: ["ws", ...]
})
// or
app.use("/", router({
directory: path.join(__dirname, "routes"),
additionalMethods: ["ws", ...]
}))
directory
: The path to the routes directory (defaults to /routes
)additionalMethods
: Additional methods that match an export from a route like ws
(e.g. ws
for express-ws)If you export functions named e.g. get
, post
, put
, patch
, delete
/del
etc. those will get matched their corresponding http method automatically.
export const get = async (req, res) => { ... }
export const post = async (req, res) => { ... }
// it's not allowed to name variables 'delete': try 'del' instead
export const del = async (req, res) => { ... }
// you can still use a wildcard default export in addition
export default async (req, res) => { ... }
Note: Named method exports gain priority over wildcard exports (= default exports).
You can add isolated, route specific middlewares by exporting an array of Express request handlers from your route file.
import { rateLimit, bearerToken, userAuth } from "../middlewares"
export const get = [
rateLimit(), bearerToken(), userAuth(),
async (req, res) => { ... }
]
A middleware function might look like the following:
// /middlewares/userAuth.ts
export default (options) => async (req, res, next) => {
if (req.authenticated) next()
...
}
You can add support for other method exports to your route files. This means that if your root app instance accepts non built-in handler invocations like app.ws(route, handler)
, you can make them being recognized as valid handlers.
// app.ts
import ws from "express-ws"
const { app } = ws(express())
createRouter(app, {
additionalMethods: ["ws"]
})
// routes/index.ts
export const ws = async (ws, req) => {
ws.send("hello world")
}
Adding support for route & method handler type definitions is as straightforward as including Express' native Handler
type from @types/express.
// /routes/posts.ts
import type { Handler } from "express"
export const get: Handler = async (req, res, next) => { ... }
FAQs
Simple system-based file routing for Express
The npm package alta-express-file-routing receives a total of 2 weekly downloads. As such, alta-express-file-routing popularity was classified as not popular.
We found that alta-express-file-routing 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.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.