1.0.18 • Published 2 years ago
@written/wrap
Licence
MIT
Version
1.0.18
Deps
0
Size
11 kB
Vulns
0
Weekly
0

@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!',
});
});