0.1.7 • Published 2 years ago

@httpz/core v0.1.7

Weekly downloads
-
License
-
Repository
-
Last release
2 years ago

HTTPz

A fast and simple JSON HTTP middleware framework.

What to know

  • HTTP is the only protocol supported (no HTTPs or HTTP/2).
  • JSON (application/json) is the only supported content type.

Example

import { HTTPz } from '@httpz/core'
import { Router } from '@httpz/router'

const httpz = new HTTPz()
const router = new Router()

router.route({
  method: 'GET',
  path: '/test',
  schema: {
    query: z.object({
      token: z.string(),
    }),
  },
  handler: req => {
    const { token } = req.query

    if (token !== 'abc') {
      throw new HTTPError({
        statusCode: 403,
        message: 'Invalid token',
      })
    }

    return HTTPResponse.success({ token })
  },
})

httpz.use(router.middleware())
httpz.listen(3579, '0.0.0.0')
0.1.7

2 years ago

0.1.6

2 years ago

0.1.5

2 years ago

0.1.4

2 years ago

0.1.3

2 years ago

0.1.2

2 years ago

0.1.0

2 years ago