1.0.0-rc.30 • Published 3 months ago

@exobase/core v1.0.0-rc.30

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

title: 'core' description: 'The core Exobase library package'

group: 'Packages'

Provides the core types and functions to implement the Abstract & Compose design pattern with the Exobase library.

If you're writing endpoints (following the Abstract & Compose design pattern) and you're using Typescript you'll probably want this package for the types. If you're developing your own hooks you'll want the core package for the response parsing functions.

Install

yarn add @exobase/core

Usage

If you're writing endpoints in Typescript you'll want to import the Props type.

import { compose } from 'radash'
import type { Props } from '@exobase/core'

const endpoint = (props: Props) => {
  console.log(props)
}

Response Parsing

An endpoint function can return any object as the result. If the result is an AnbstractResponse object it should be parsed and applied with all specified headers, body, and status. If the result is any other object it should be treated as the json body and returned as such in the response.

The core package gives you a few small helpers to deal with these results that are not always known. A function can throw an error, return an Response object, or return any other object. In almost any case, all of these need to be converted to an Response so they can be applied to a framework.

For an example, see the source for the useExpress hook.

import { props, responseFromError, responseFromResult } from '@exobase/core'
  • props is a helper you can use in a root hook to generate the initial Props object. Think of it like a constructor.
  • responseFromError will convert an error object into an Response, handling error objects and unkonwn errors.
  • responseFromResult will convert a function's result into an Response, handling both cases mentioned above.
1.0.0-rc.30

3 months ago

1.0.0-rc.29

3 months ago

1.0.0-rc.28

3 months ago

1.0.0-rc.27

3 months ago

1.0.0-rc.26

3 months ago

1.0.0-rc.25

1 year ago

1.0.0-rc.24

1 year ago

1.0.0-rc.23

1 year ago

1.0.0-rc.22

1 year ago

1.0.0-rc.20

1 year ago

1.0.0-rc.21

1 year ago

1.0.0-rc.17

1 year ago

1.0.0-rc.16

1 year ago

1.0.0-rc.15

1 year ago

1.0.0-rc.14

1 year ago

1.0.0-rc.19

1 year ago

1.0.0-rc.18

1 year ago

2.0.0-rc.1

2 years ago

1.0.0-rc.9

1 year ago

1.0.0-rc.7

2 years ago

1.0.0-rc.8

2 years ago

1.0.0-rc.5

2 years ago

1.0.0-rc.6

2 years 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.10

1 year ago

1.0.0-rc.3

2 years ago

1.0.0-rc.4

2 years ago

1.0.0-rc.1

2 years ago

1.0.0-rc.2

2 years ago

0.0.8

2 years ago

0.0.7

2 years ago

0.0.5

2 years ago

0.0.6

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago

1.0.3-alpha.0

2 years ago