Api Resources for Next.js
Open Source. Full Stack. Own Your Data.
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.
To get started, you can install Endurance.js using npm:
npm install endurance-js
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.