rerumaccusamus
Version:
The meta-framework suite designed from scratch for frontend-focused modern web development.
33 lines (29 loc) • 745 B
text/typescript
// eslint-disable-next-line eslint-comments/disable-enable-pair
/* eslint-disable react-hooks/rules-of-hooks */
import { match } from '@modern-js/bff-runtime';
import { useContext } from '../../../../../src/context';
// eslint-disable-next-line arrow-body-style
export const get = ({ query }: { query: Record<string, unknown> }) => {
return { query };
};
export const post = ({ data }: { data: Record<string, unknown> }) => {
const { req } = useContext();
const { cookies } = req;
return {
query: req.query,
data,
cookies,
};
};
export const patch = match(
{
request: {
data: {
id: Number,
name: String,
},
},
response: { id: Number },
},
({ data: { id } }) => ({ id }),
);