fastify-casbin-rest
Advanced tools
Comparing version 1.2.0 to 1.2.1
{ | ||
"name": "fastify-casbin-rest", | ||
"version": "1.2.0", | ||
"version": "1.2.1", | ||
"description": "Plugin for fastify to add support for Casbin REST model", | ||
@@ -5,0 +5,0 @@ "main": "plugin.js", |
/// <reference types="node" /> | ||
import { FastifyInstance, FastifyPluginAsync, FastifyReply, FastifyRequest } from 'fastify' | ||
import { | ||
ContextConfigDefault, | ||
RawReplyDefaultExpression, | ||
RawRequestDefaultExpression, | ||
RawServerBase, | ||
RawServerDefault | ||
} from 'fastify/types/utils' | ||
import { RouteGenericInterface } from 'fastify/types/route' | ||
declare module 'fastify' { | ||
interface RouteShorthandOptions { | ||
interface RouteShorthandOptions< | ||
RawServer extends RawServerBase = RawServerDefault, | ||
RawRequest extends RawRequestDefaultExpression<RawServer> = RawRequestDefaultExpression<RawServer>, | ||
RawReply extends RawReplyDefaultExpression<RawServer> = RawReplyDefaultExpression<RawServer>, | ||
RouteGeneric extends RouteGenericInterface = RouteGenericInterface, | ||
ContextConfig = ContextConfigDefault | ||
> { | ||
casbin?: { | ||
rest?: boolean | { | ||
getSub?: ((request: FastifyRequest) => string) | string, | ||
getObj?: ((request: FastifyRequest) => string) | string, | ||
getAct?: ((request: FastifyRequest) => string) | string | ||
getSub?: ((request: FastifyRequest<RouteGeneric, RawServer, RawRequest>) => string) | string, | ||
getObj?: ((request: FastifyRequest<RouteGeneric, RawServer, RawRequest>) => string) | string, | ||
getAct?: ((request: FastifyRequest<RouteGeneric, RawServer, RawRequest>) => string) | string | ||
} | ||
@@ -13,0 +27,0 @@ } |
@@ -1,2 +0,2 @@ | ||
import fastify, { FastifyReply, FastifyRequest } from 'fastify' | ||
import fastify, { FastifyReply, FastifyRequest, RequestGenericInterface } from 'fastify' | ||
import { expectType } from 'tsd' | ||
@@ -50,1 +50,16 @@ import casbinRest from '../plugin' | ||
}, () => Promise.resolve('ok')) | ||
interface ListRequest extends RequestGenericInterface { | ||
Params: { | ||
listID: string | ||
} | ||
} | ||
server.get<ListRequest>('/', { | ||
casbin: { | ||
rest: { | ||
getObj: (request) => request.params.listID, | ||
} | ||
} | ||
}, () => Promise.resolve('ok')) |
19670
390