Skip to content

Plugins

Plugins add functionality to your VeloxTS application. VeloxTS is built on Fastify’s plugin system.

import { veloxApp } from '@veloxts/velox';
import { databasePlugin } from '@veloxts/orm';
import { authPlugin } from '@veloxts/auth';
const app = veloxApp();
app.register(databasePlugin);
app.register(authPlugin, { secret: process.env.JWT_SECRET });
await app.start({ port: 3030 });
PackagePluginPurpose
@veloxts/ormdatabasePluginPrisma database connection
@veloxts/authauthPluginAuthentication setup
@veloxts/routerregisterDocsOpenAPI documentation
import { definePlugin } from '@veloxts/core';
export const myPlugin = definePlugin({
name: 'my-plugin',
register: async (app, options) => {
// Add hooks, decorators, routes
app.addHook('onRequest', async (request) => {
// ...
});
},
});

You can use any Fastify plugin:

import cors from '@fastify/cors';
import helmet from '@fastify/helmet';
app.register(cors, { origin: true });
app.register(helmet);