0.1.10 ā¢ Published 3 years ago
dobject-routing v0.1.10
Use an object to declare your express routing.
Install
npm install dobject-routing express
npm install --save-dev @types/express
Usage
Install the package with express. Then you can create a routes file as an example
import { ERequestType, IRouter } from "dobject-routing";
export const routes: IRouter = {
routes: [
{
method: ERequestType.GET,
handlers: [
(req, res) => {
res.send("Hello");
}
]
}
]
};
export default routes;
Finally, import and use the package as an example
import express from 'express';
import Routing from "dobject-routing";
import routes from './routes';
const app: express.Application = express();
const PORT: number = 8080;
app.use('/', Routing(routes));
app.listen(PORT, () => {
console.log(`Listening on http://localhost:${PORT}`);
});
Author
š¤ Carter J. Wilde
- Github: @CarterWilde
š License
Copyright Ā© 2021 Carter J. Wilde. This project is GNU GPL v3 licensed.