@written/wrap
TypeScript icon, indicating that this package has built-in type declarations

1.0.18 • Public • Published

Written Logo

@written/wrap

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

Codeberg License

Installation

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

Usage

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

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

Readme

Keywords

none

Package Sidebar

Install

npm i @written/wrap

Weekly Downloads

0

Version

1.0.18

License

MIT

Unpacked Size

11.1 kB

Total Files

10

Last publish

Collaborators

  • exponentialworkload