feat: create from template

This commit is contained in:
Mythie
2024-02-20 19:46:18 +11:00
parent 4c5b910a59
commit b9e5905469
8 changed files with 242 additions and 70 deletions

View File

@ -16,7 +16,10 @@ export const authenticatedMiddleware = <
) => {
return async (args: T) => {
try {
const { authorization: token } = args.req.headers;
const { authorization } = args.req.headers;
// Support for both "Authorization: Bearer api_xxx" and "Authorization: api_xxx"
const [token] = (authorization || '').split('Bearer ').filter((s) => s.length > 0);
if (!token) {
throw new Error('Token was not provided for authenticated middleware');
@ -26,6 +29,7 @@ export const authenticatedMiddleware = <
return await handler(args, user);
} catch (_err) {
console.log({ _err });
return {
status: 401,
body: {