1.0.0-rc.19 • Published 3 months ago

@exobase/use-node v1.0.0-rc.19

Weekly downloads
-
License
MIT
Repository
-
Last release
3 months ago

title: 'useNode' description: 'A root hook to handle the standard Node.js http/https server framework' group: 'Root Hooks'

badge: 'Node.js'

An Exobase root hook for a raw Node HTTP/S server

Install

yarn add @exobase/use-node

Import

import { useNode } from '@exobsae/use-node'

Usage

import https from 'https'
import { error } from '@exobase/core'
import { compose, toInt } from 'radash'
import { useRouter } from '@exobase/hooks'
import { useNode } from '@exobase/use-node'

const server = https.createServer(
  compose(
    useNode(),
    useRouter(router => router
      .on(['GET', 'POST'], '/ping', pingEndpoint)
      put('/v1/library/book/*/return', returnBookEndpoint),
      post('/v1/library/book', createBookEndpoint),
      get('/v1/library/book/*', findBookEndpoint),
      get('/v1/library/book', listBooksEndpoint),
    ),
    async () => {
      throw error({
        status: 404,
        message: 'Not found'
      })
    }
  )
)

const port = toInt(process.env.PORT, 8500)

server.listen(port, () => {
  console.log(`API listening on port ${port}`)
})
1.0.0-rc.19

3 months ago

1.0.0-rc.18

3 months ago

1.0.0-rc.17

3 months ago

1.0.0-rc.16

3 months ago

1.0.0-rc.14

1 year ago

1.0.0-rc.13

1 year ago

1.0.0-rc.12

1 year ago

1.0.0-rc.11

1 year ago

1.0.0-rc.9

1 year ago

1.0.0-rc.10

1 year ago

1.0.0-rc.7

1 year ago

1.0.0-rc.8

1 year ago

1.0.0-rc.5

1 year ago

1.0.0-rc.6

1 year ago

1.0.0-rc.3

1 year ago

1.0.0-rc.4

1 year ago

1.0.0-rc.2

1 year ago