Guard

Api route protector

import { guard, handler, t, type Store } from 'mantou/routes'

const auth = (roles: string[]) => guard(async () => {
  console.log('Auth guard: ', roles);
  return true // return boolean only
})

Example usage

export const post = handler(() => {
  return "Update Something";
}, {}, [
auth(["buyer"])
])

Last updated