modern-express-decorators
v1.4.0
Published
A very simple express decorator partly vibecoded and made because I hate long codes a bit
Maintainers
Readme
Partly Vibecoded
Back then:
import express from "express";
const app = express();
app.get("/", async (req, res) => {
res.send("Hello World");
});This can get messy as the codebase grows, surely you can separate it into services, controllers, models so on. But those individualities can also get messy
With decorators:
"src/controller/*.ts";
import { Get } from "modern-express-decorators";
export class HealthCheckController {
@Get("/")
async function(req, res) {
res.send("Hello World!");
}
}
("src/index.ts");
import { HealthCheckController } from "src/controller/*.ts";
import { registerRouter } from "modern-express-decorators";
import express from "express";
const router = express.Router();
registerRouter(router, HealthCheckController);
app.use("/api", router);To be added features:
- ~~DTO/Validation Schema on decorators~~ ✅
- Middleware Support (though one can pass on function itself)
- Performance enhancement
- Probably automatically allowing OpenAPI documentation support(?)
