Skip to content

Commit 5bac54c

Browse files
committed
cache role response on client
1 parent 410087c commit 5bac54c

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/routes/protected.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
import { FastifyPluginAsync } from "fastify";
2+
import fastifyCaching from "@fastify/caching";
23

34
const protectedRoute: FastifyPluginAsync = async (fastify, _options) => {
5+
fastify.register(fastifyCaching, {
6+
privacy: fastifyCaching.privacy.PRIVATE,
7+
serverExpiresIn: 0,
8+
expiresIn: 60 * 15,
9+
});
410
fastify.get("/", async (request, reply) => {
511
const roles = await fastify.authorize(request, reply, []);
612
reply.send({ username: request.username, roles: Array.from(roles) });

0 commit comments

Comments
 (0)