1.1.1 • Published 3 years ago

hetter v1.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

hetter

A simple route manager for Next.js API Routes.

npm size


Installation

with npm:

$ npm i hetter

with yarn:

$ yarn add hetter

Usage

In this example we will create user api routes

Folder structure

pages
 ┣ api
 ┃ ┣ user
 ┃ ┃ ┗ UserController.ts
 ┃ ┗ [[...path]].ts
 ┗ index.tsx

Handling

On [[...path]].ts file:

import { NextApiRequest, NextApiResponse } from 'next'
import Hetter from 'hetter'

import UserController from './user/UserController'

export default function handler(req: NextApiRequest, res: NextApiResponse) {
  const Route = new Hetter(req, res)

  Route.get('/users/:id', UserController.index)
  Route.post('/users/:id', UserController.store)
}

1.1.1

3 years ago

1.1.0

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago