Skip to content

ezeparziale/nextjs-api-template

Repository files navigation

🚀 Next.js API Template

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

💾 Installation

  1. Clone this repo:
git clone https://github.com/ezeparziale/nextjs-api-template.git
  1. Navigate to the project directory:
cd nextjs-api-template
  1. Install dependencies:
npm i
  1. Create a .env file by copying the .env.template file and updating it with your environment variables.

  2. Run migrations to initialize the database:

npx prisma migrate deploy
  1. Start the application:
npm run dev
  1. Go to:
http://localhost:3000

📄 API Docs

http://localhost:3000/api/openapi
http://localhost:3000/api/docs