JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 18
  • Score
    100M100P100Q39287F
  • License MIT

Fastify plugin for Permit.io integration

Package Exports

  • fastify-permit-io
  • fastify-permit-io/dist/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (fastify-permit-io) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

fastify-permit-io

NPM version

A Fastify plugin for seamless integration with Permit.io, enabling robust, flexible, and scalable permissions and authorization in your Fastify applications.

Features

  • Installs a Permit instance on your Fastify server
  • Supports all Permit.io authorization models (RBAC, ABAC, ReBAC)
  • Simple, type-safe integration

Installation

npm install fastify-permit-io permitio

Usage

import Fastify from "fastify";
import FastifyPermitio from "fastify-permit-io";

const app = Fastify();

app.register(FastifyPermitio, {
  pdp: "https://cloudpdp.api.permit.io",
  token: "YOUR_PERMIT_API_KEY",
  // ...other Permit config options
});

app.get("/resource", async (request, reply) => {
  // Access the Permit instance
  const permit = app.permit;
  const allowed = await permit.check("user:123", "read", "document:456");
  if (!allowed) {
    return reply.code(403).send({ error: "Forbidden" });
  }
  return { data: "Secret document" };
});

app.listen({ port: 3000 });

Additional Context

I am not affiliated with permit.io and this project is an independent integration created for convenience. For official support or documentation, please refer to the Permit.io website and their official documentation.

License

Licensed under MIT.