Add a signerMiddleware

This commit is contained in:
Alex Gleason
2024-05-14 11:30:45 -05:00
parent b7821f6585
commit ee7864da8c
3 changed files with 28 additions and 3 deletions

View File

@@ -0,0 +1,13 @@
import { AppMiddleware } from '@/app.ts';
import { APISigner } from '@/signers/APISigner.ts';
/** Make a `signer` object available to all controllers, or unset if the user isn't logged in. */
export const signerMiddleware: AppMiddleware = async (c, next) => {
try {
c.set('signer', new APISigner(c));
} catch {
// do nothing
}
await next();
};