# @exobase/core

> Exobase types and hook helper functions

Latest version **1.0.0-rc.31** (published 2024-07-08) · MIT license · 0 weekly downloads

## Install

```sh
npm install @exobase/core
pnpm add @exobase/core
yarn add @exobase/core
bun add @exobase/core
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0-rc.31 |
| Published | 2024-07-08 |
| First published | 2021-12-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 120.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 21 |
| Author | rayepps |
| Maintainers | rayepps |

## Links

- npm: https://www.npmjs.com/package/@exobase/core
- Repository: https://github.com/rayepps/exobase-js
- Homepage: https://github.com/rayepps/exobase-js#readme
- Issues: https://github.com/rayepps/exobase-js/issues
- npm.io page: https://npm.io/package/@exobase/core

## Dependencies (1)

- [radash](https://npm.io/package/radash.md) 12.0.0

## Recent versions

- 1.0.0-rc.31 (latest) — 2024-07-08
- 1.0.0-rc.1 (next) — 2022-10-30
- 1.0.0-rc.30 — 2024-02-21
- 1.0.0-rc.29 — 2024-02-20
- 1.0.0-rc.28 — 2024-02-19
- 1.0.0-rc.27 — 2024-02-19
- 1.0.0-rc.26 — 2024-02-19
- 1.0.0-rc.25 — 2023-03-07
- 1.0.0-rc.24 — 2023-03-02
- 1.0.0-rc.23 — 2023-03-01
- 1.0.0-rc.22 — 2023-03-01
- 1.0.0-rc.21 — 2023-02-22
- 1.0.0-rc.20 — 2023-02-22
- 1.0.0-rc.19 — 2023-01-08
- 1.0.0-rc.18 — 2023-01-07
- … 25 more at https://npm.io/package/@exobase/core/versions

## README

---
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

```sh
yarn add @exobase/core
```

## Usage

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

```ts
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.

```ts
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.

---
_Source: https://npm.io/package/@exobase/core · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
