@written/wrap
v1.0.18
Published
Create a wrapper around an Appwrite Function. It's recommended to just use `@written/app`.
Downloads
12
Readme
@written/wrap
Create a wrapper (primitive "middleware") around an Appwrite Function. It's recommended to just use @written/app
.
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!',
});
});