Skip to main content

API Routes

This library was built solely for use in API Routes because it is built to improve developer experience and bring the express.js code structure to nextjs API Routes. You can write them within API Routes files

syntx

/pages/api/index.js
 
let app = new API(req, res)

app.get(auth: Boolean ,callback: fun)
// or
app.get(callback: fun)

example

/pages/api/index.js
import API from "nextjs-vip"

export default async function API_Send(req, res, next) {

let app = new API(req, res)
app.get(async () => {
// send data
// format JSON
app.Send(data)
})
}
name methodsyntx
getget(auth? ,callback)
postpost(auth? ,callback)
putput(auth? ,callback)
deletedelete(auth? ,callback)
patchpatch(auth? ,callback)
allall(auth? ,callback)