A boilerplate template for building APIs with Next.js, featuring schema validation and OpenAPI documentation.
- API with basic operations: POST/GET/PUT/PATCH/DELETE
- OpenAPI schema
- Validation of request bodies with Zod
- Validation of query parameters with Zod
- OpenAPI schema generation with
zod-openapi
- Swagger docs
- Token-based authorization
- Clone this repo:
git clone https://github.com/ezeparziale/nextjs-api-template.git
- Navigate to the project directory:
cd nextjs-api-template
- Install dependencies:
npm i
-
Create a
.env
file by copying the.env.template
file and updating it with your environment variables. -
Run migrations to initialize the database:
npx prisma migrate deploy
- Start the application:
npm run dev
- Go to:
http://localhost:3000
http://localhost:3000/api/openapi
http://localhost:3000/api/docs