authfyio-fastify
Fastify plugin. Decorates the app with protect / verifyAuth and attaches request.auth on every request.
Copy this quickstart guide as a prompt for LLMs to implement Authfyio in your application.
Install
npm install authfyio-fastify authfyio-backend @fastify/cookieRegister
import Fastify from 'fastify';
import cookie from '@fastify/cookie';
import authfyio from 'authfyio-fastify';
const app = Fastify();
await app.register(cookie);
await app.register(authfyio, { // baseUrl defaults to https://api.authfyio.com });
app.get('/api/private', { preHandler: [(app as any).protect] }, (req: any) => ({
userId: req.auth.userId,
orgId: req.auth.orgId,
}));Shape
Same as authfyio-express — see that page.