mirror of
https://github.com/lukevella/rallly.git
synced 2025-05-10 15:36:49 +02:00
♻️ Create backend package (#643)
This commit is contained in:
parent
7fc08c6736
commit
05fe2edaea
68 changed files with 476 additions and 391 deletions
23
packages/backend/next/utils.ts
Normal file
23
packages/backend/next/utils.ts
Normal file
|
@ -0,0 +1,23 @@
|
|||
import { GetServerSideProps } from "next";
|
||||
|
||||
export function composeGetServerSideProps(
|
||||
...fns: GetServerSideProps[]
|
||||
): GetServerSideProps {
|
||||
return async (ctx) => {
|
||||
const res = { props: {} };
|
||||
for (const getServerSideProps of fns) {
|
||||
const fnRes = await getServerSideProps(ctx);
|
||||
|
||||
if ("props" in fnRes) {
|
||||
res.props = {
|
||||
...res.props,
|
||||
...fnRes.props,
|
||||
};
|
||||
} else {
|
||||
return fnRes;
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue