♻️ Create backend package (#643)

This commit is contained in:
Luke Vella 2023-04-03 10:41:19 +01:00 committed by GitHub
parent 7fc08c6736
commit 05fe2edaea
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
68 changed files with 476 additions and 391 deletions

View 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;
};
}