0.0.21 • Published 1 year ago
endurance-js v0.0.21
Overview
Endurance.js is a Next.js API Resource library that allows you to create API resources for your Next.js application. It is built on top of Next.js API Routes and uses Prisma ORM to connect to your database.
Getting Started
Install Endurance JS
To get started, you can install Endurance.js using npm:
npm install endurance-js
Add API route
To add NextAuth.js to a project create a file called [[...path]].ts
in pages/api
. This contains the dynamic route handler for Endurance.js which will also contain all of your global Endurance.js configurations.
import serverHandler from "endurance-js/lib/router";
import { NextApiRequest, NextApiResponse } from "next";
import entities from "../../Entity";
export default function handler(req: NextApiRequest, res: NextApiResponse) {
return serverHandler(req, res, {
entities: entities,
});
}
All requests to /api/*
(users
, posts
, roles
, etc.) will automatically be handled by Endurance.js.