auto-routes-linking
v1.0.5
Published
<div class="relative flex w-[calc(100%-50px)] flex-col gap-1 md:gap-3 lg:w-[calc(100%-115px)]"><div class="flex flex-grow flex-col gap-3"><div class="min-h-[20px] flex flex-col items-start gap-4 whitespace-pre-wrap">
Downloads
3
Readme
npm i auto-routes-linking
post = (request,response)=>{ res.send("get route for api/user") } delete = (request,response)=>{ res.send("get route for api/user") }
export = { get, post, delete } You can also create dynamic routes using the "[param]" syntax. For example, to create a route for "api/user/:user", you can create a folder named "[user]" inside the "routes/user" folder, and include an index.js file inside the "[user]" folder.routes -user -index.js -[user] -index.js Inside the index.js file, you can specify the appropriate methods for the dynamic route. For example:get = (request,response)=>{ res.send("get route for api/user/:user") }
export = { get } You can then import the module and use it to automatically generate routes:var express = require('express'); var routeLinking = require('auto-routes-linking'); const app = express()
routeLinking(app)// default prefix is "api" and default route path is "src/routes". To change this, you can specify the prefix and path as arguments: routeLinking(app,"api/v1","/routes") //or routeLinking(app,"api/v1","/anything")
app.listen(3000, function () { console.log('Example app listening on port 3000!'); });