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 method | syntx |
|---|---|
| get | get(auth? ,callback) |
| post | post(auth? ,callback) |
| put | put(auth? ,callback) |
| delete | delete(auth? ,callback) |
| patch | patch(auth? ,callback) |
| all | all(auth? ,callback) |