@exobase/use-route
TypeScript icon, indicating that this package has built-in type declarations

1.0.0-rc.13 • Public • Published

Provides an Exobase hook that will do simple method/route routing to differnet endpoint functions.

Usage

import { compose } from 'radash'
import type { Props } from '@exobase/core'
import { useNext } from '@exobase/use-next'
import { useRoute } from '@exobase/use-route'

export const listLibraries = async (props: Props) => {
  return db.libraries.list()
}

export const listBooks = async (props: Props) => {
  return db.books.list()
}

export default compose(
  useNext(),
  useRoute('GET', '/library', listLibraries)
  useRoute('GET', '/library/books', listBooks)
  async () => {
    throw new Error('404 Not found')
  }
)

Readme

Keywords

none

Package Sidebar

Install

npm i @exobase/use-route

Weekly Downloads

19

Version

1.0.0-rc.13

License

MIT

Unpacked Size

20.4 kB

Total Files

17

Last publish

Collaborators

  • rayepps