# @written/wrap

> Create a wrapper around an Appwrite Function. It's recommended to just use `@written/app`.

Latest version **1.0.18** (published 2024-04-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install @written/wrap
pnpm add @written/wrap
yarn add @written/wrap
bun add @written/wrap
```

## Health

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

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.18 |
| Published | 2024-04-06 |
| First published | 2023-11-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=v20.0.0 |
| Dependencies | 0 |
| Unpacked size | 10.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Expo |
| Maintainers | exponentialworkload |

## Links

- npm: https://www.npmjs.com/package/@written/wrap
- Repository: https://codeberg.org/Written/Written
- Homepage: https://codeberg.org/Written/Written/src/branch/senpai/packages/@written/wrap/
- Issues: https://codeberg.org/Written/Written/issues
- npm.io page: https://npm.io/package/@written/wrap

## Recent versions

- 1.0.18 (latest) — 2024-04-06
- 1.0.17 — 2024-03-21
- 1.0.16 — 2024-03-17
- 1.0.15 — 2024-03-14
- 1.0.14 — 2024-03-14
- 1.0.13 — 2024-03-05
- 1.0.12 — 2024-03-05
- 1.0.11 — 2024-03-01
- 1.0.10 — 2024-02-02
- 1.0.9 — 2024-01-26
- 1.0.8 — 2024-01-25
- 1.0.7 — 2024-01-25
- 1.0.6 — 2024-01-25
- 1.0.5 — 2024-01-16
- 1.0.4 — 2024-01-08
- … 8 more at https://npm.io/package/@written/wrap/versions

## README

<div align="center">

![Written Logo](https://codeberg.org/Written/Written/raw/branch/senpai/ico/written.png)

# @written/wrap

Create a wrapper (primitive "middleware") around an Appwrite Function. It's recommended to just use `@written/app`.

[![Codeberg](https://img.shields.io/badge/Codeberg-Written-724773.svg?style=flat-square)](https://codeberg.org/Written/Written/src/branch/senpai/packages/@written/trailing-slash)
[![License](https://img.shields.io/badge/License-MIT-724773.svg?style=flat-square)](https://codeberg.org/Written/Written/src/branch/senpai/LICENSE)

</div>

## Installation

```sh
pnpm i @written/wrap @written/appwrite-types
```

## Usage

```ts
// wrapper.ts
import wrap from '@written/wrap';
export default wrap((ctx, rs) => {
  rs.headers['x-abc'] = ctx.req.headers['x-abc'] ?? '';
  return rs;
});
```

This example middleware will replace the `x-abc` header in the response with the same header as found in the request.

You can then use it as such:

```ts
import w from './wrapper';
export default w(ctx => {
  return ctx.res.json({
    success: 1,
    message: 'Hi!',
  });
});
```

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