fastify-casbin-rest
Advanced tools
Comparing version 1.1.0 to 1.1.1
{ | ||
"name": "fastify-casbin-rest", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"description": "Plugin for fastify to add support for Casbin REST model", | ||
@@ -5,0 +5,0 @@ "main": "plugin.js", |
@@ -5,2 +5,14 @@ /// <reference types="node" /> | ||
declare module 'fastify' { | ||
interface RouteShorthandOptions { | ||
casbin?: { | ||
rest?: boolean | { | ||
getSub?: (request: FastifyRequest) => string, | ||
getObj?: (request: FastifyRequest) => string, | ||
getAct?: (request: FastifyRequest) => string | ||
} | ||
} | ||
} | ||
} | ||
export type Hook = | ||
@@ -7,0 +19,0 @@ | 'onRequest' |
@@ -29,1 +29,11 @@ import fastify, { FastifyReply, FastifyRequest } from 'fastify' | ||
}) | ||
server.get('/', { | ||
casbin: { | ||
rest: { | ||
getSub: (request: FastifyRequest) => '1', | ||
getObj: (request: FastifyRequest) => request.url, | ||
getAct: (request: FastifyRequest) => request.method | ||
} | ||
} | ||
}, () => Promise.resolve('ok')) |
16120
284