mirror of
https://github.com/shishantbiswas/bknd.git
synced 2026-03-16 20:37:21 +00:00
updated adapters to automatically verify auth
This commit is contained in:
@@ -29,8 +29,10 @@ export function createApi({ req }: GetServerSidePropsContext) {
|
||||
}
|
||||
|
||||
export function withApi<T>(handler: (ctx: GetServerSidePropsContext & { api: Api }) => T) {
|
||||
return (ctx: GetServerSidePropsContext & { api: Api }) => {
|
||||
return handler({ ...ctx, api: createApi(ctx) });
|
||||
return async (ctx: GetServerSidePropsContext & { api: Api }) => {
|
||||
const api = createApi(ctx);
|
||||
await api.verifyAuth();
|
||||
return handler({ ...ctx, api });
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user