Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/howard86/next-api-handler
lightweight nextjs api handler wrapper, portable & configurable for serverless environment
https://github.com/howard86/next-api-handler
api express nextjs serverless typescript
Last synced: 26 days ago
JSON representation
lightweight nextjs api handler wrapper, portable & configurable for serverless environment
- Host: GitHub
- URL: https://github.com/howard86/next-api-handler
- Owner: Howard86
- License: other
- Created: 2021-09-19T13:16:34.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2024-04-13T16:49:49.000Z (7 months ago)
- Last Synced: 2024-04-14T06:58:20.261Z (7 months ago)
- Topics: api, express, nextjs, serverless, typescript
- Language: TypeScript
- Homepage: https://next-api-handler.vercel.app
- Size: 2.34 MB
- Stars: 47
- Watchers: 3
- Forks: 2
- Open Issues: 15
-
Metadata Files:
- Readme: README.md
- Contributing: .github/CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
---
[![install size](https://packagephobia.com/badge?p=next-api-handler)](https://packagephobia.com/result?p=next-api-handler)
[![CircleCI](https://circleci.com/gh/Howard86/next-api-handler/tree/main.svg?style=svg)](https://circleci.com/gh/Howard86/next-api-handler/tree/main)
[![codecov](https://codecov.io/gh/Howard86/next-api-handler/branch/main/graph/badge.svg?token=EIH9QQTLXT)](https://codecov.io/gh/Howard86/next-api-handler)
[![next-api-handler](https://img.shields.io/endpoint?url=https://dashboard.cypress.io/badge/detailed/d5185e/main&style=flat&logo=cypress)](https://dashboard.cypress.io/projects/d5185e/runs)
![Known Vulnerabilities](https://snyk.io/test/github/howard86/next-api-handler/badge.svg)## Lightweight and Portable [Next.js](https://nextjs.org) API builder
Building RESTful API routes in [Next.js](https://nextjs.org) with middleware support, predictable error handling and type-safe interfaces for client-server communication.
> Visit [https://next-api-handler.vercel.app](https://next-api-handler.vercel.app) to view the full documentation.
## Getting Started
**TL;DR**
```sh
npm install next-api-handler # or yarn, pnpm
``````ts
// in /pages/api/users.ts
import { RouterBuilder, ForbiddenException } from 'next-api-handler';
import { createUser, type User } from '@/services/user';const router = new RouterBuilder();
router
.get(() => 'Hello World!')
.post(async (req) => createUser(req.body))
.delete(() => {
throw new ForbiddenException();
});export default router.build();
```## License
[MIT](/LICENSE)