added tooling (eslint, typescript and prettier)

This commit is contained in:
Carl-Gerhard Lindesvärd
2023-11-02 12:14:37 +01:00
parent 575b3c23bf
commit 493e1b7650
82 changed files with 1890 additions and 1363 deletions

View File

@@ -1,45 +1,46 @@
import {
type GetServerSidePropsContext,
type GetServerSidePropsResult,
} from "next";
import { getServerAuthSession } from "./auth";
import { db } from "./db";
} from 'next';
import { getServerAuthSession } from './auth';
import { db } from './db';
export function createServerSideProps(
cb?: (context: GetServerSidePropsContext) => Promise<any>,
cb?: (context: GetServerSidePropsContext) => Promise<any>
) {
return async function getServerSideProps(
context: GetServerSidePropsContext,
context: GetServerSidePropsContext
): Promise<GetServerSidePropsResult<any>> {
const session = await getServerAuthSession(context);
const session = await getServerAuthSession(context);
if(!session) {
if (!session) {
return {
redirect: {
destination: "/api/auth/signin",
destination: '/api/auth/signin',
permanent: false,
},
}
};
}
if(context.params?.organization) {
if (context.params?.organization) {
const organization = await db.user.findFirst({
where: {
id: session.user.id,
organization: {
slug: context.params.organization as string
}
}
})
if(!organization) {
slug: context.params.organization as string,
},
},
});
if (!organization) {
return {
notFound: true,
}
};
}
}
const res = await (typeof cb === "function"
const res = await (typeof cb === 'function'
? cb(context)
: Promise.resolve({}));
return {