@prefabs.tech/feedback-fastify
v0.1.0
Published
Fastify feedback plugin
Downloads
90
Keywords
Readme
@prefabs.tech/feedback-fastify
A Fastify plugin that provides a config-driven feedback collection slice for a Fastify API.
Why this plugin?
Collecting in-app feedback usually means writing the same boilerplate every time: a table to store it, a migration to create that table, an authenticated endpoint to accept submissions, and validation. This plugin gives you all of that as a single, config-driven package that plugs into your existing @prefabs.tech/fastify-slonik database setup:
- A complete feedback slice out of the box — a
feedbackstable (created via an idempotent migration on registration) plus both a REST route and a GraphQL mutation to create entries. - Authenticated by default — the create endpoint runs behind
verifySession(); the submitter'suserIdis always taken from the session, never trusted from the client. - Centralized, typed configuration — extends the
@prefabs.tech/fastify-configApiConfiginterface so route prefix, table name, and route toggles live alongside the rest of your app config. - Clean overrides — the default create handler can be replaced via
config.feedback.handlers.feedback.createFeedbackwhen your business logic needs custom behavior.
Requirements
Peer dependencies (install compatible versions — see package.json):
- @prefabs.tech/fastify-config
- @prefabs.tech/fastify-error-handler
- @prefabs.tech/fastify-graphql
- @prefabs.tech/fastify-slonik
fastifyfastify-pluginmercuriussloniksupertokens-node
Installation
Install with npm:
npm install @prefabs.tech/fastify-config @prefabs.tech/fastify-error-handler @prefabs.tech/fastify-graphql @prefabs.tech/fastify-slonik @prefabs.tech/feedback-fastify fastify fastify-plugin mercurius slonik supertokens-nodeInstall with pnpm:
pnpm add --filter "@scope/project" @prefabs.tech/fastify-config @prefabs.tech/fastify-error-handler @prefabs.tech/fastify-graphql @prefabs.tech/fastify-slonik @prefabs.tech/feedback-fastify fastify fastify-plugin mercurius slonik supertokens-nodeUsage
Register the plugin after the config, error-handler, slonik, and user (session) plugins it depends on:
import feedbackPlugin from "@prefabs.tech/feedback-fastify";
await fastify.register(feedbackPlugin);This runs the migration for the feedbacks table and registers POST {routePrefix}/feedbacks. See GUIDE.md for configuration, the GraphQL mutation, and handler overrides.
