用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/MikeTreml/MissionControl --skill fastify命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
Expert Electron application architecture skill for IPC design, main/renderer/preload boundaries, security hardening, performance optimization, packaging strategy, native integration, and cross-platform desktop development. Use when reviewing or designing Electron apps, planning migrations, auditing architecture risks, choosing IPC patterns, diagnosing startup or memory issues, or coordinating related Electron skills.
Generates DrawIO XML diagrams for Amazon Web Services architectures from text descriptions or images. Analyzes existing .drawio files to extract AWS components. Use for AWS architecture diagrams, cloud infrastructure documentation, or when converting AWS diagram images to editable DrawIO format.
Generates DrawIO XML diagrams for Google Cloud Platform architectures from text descriptions or images. Analyzes existing .drawio files to extract GCP components. Use for GCP architecture diagrams, cloud infrastructure documentation, or when converting GCP diagram images to editable DrawIO format.
基于 SOC 职业分类
正在显示 SKILL.md
| name | fastify |
| description | Fastify plugins, hooks, validation, serialization, and performance optimization patterns. |
| allowed-tools | Read, Write, Edit, Bash, Glob, Grep |
Expert assistance for building high-performance APIs with Fastify.
Invoke this skill when you need to:
| Parameter | Type | Required | Description |
|---|---|---|---|
| routePrefix | string | Yes | Route prefix |
| validation | boolean | No | Add JSON Schema validation |
| plugins | array | No | Plugins to use |
// src/app.ts
import Fastify, { FastifyInstance } from 'fastify';
import cors from '@fastify/cors';
import helmet from '@fastify/helmet';
import rateLimit from '@fastify/rate-limit';
import swagger from '@fastify/swagger';
import swaggerUi from '@fastify/swagger-ui';
import { usersRoutes } from './routes/users';
import { authRoutes } from './routes/auth';
import { errorHandler } from './plugins/error-handler';
export async function buildApp(): Promise<FastifyInstance> {
const app = Fastify({
logger: {
level: process.env.LOG_LEVEL || 'info',
transport: process.env.NODE_ENV !== 'production'
? { target: 'pino-pretty' }
: undefined,
},
ajv: {
customOptions: {
removeAdditional: 'all',
coerceTypes: true,
useDefaults: true,
},
},
});
// Security plugins
await app.register(helmet);
await app.register(cors, {
origin: process.env.CORS_ORIGIN || true,
credentials: true,
});
await app.register(rateLimit, {
max: 100,
timeWindow: '1 minute',
});
// Documentation
await app.register(swagger, {
openapi: {
info: {
title: 'API Documentation',
version: '1.0.0',
},
components: {
securitySchemes: {
bearerAuth: {
type: 'http',
scheme: 'bearer',
},
},
},
},
});
await app.register(swaggerUi, {
routePrefix: '/docs',
});
// Custom plugins
await app.register(errorHandler);
// Routes
await app.register(authRoutes, { prefix: '/api/auth' });
await app.register(usersRoutes, { prefix: '/api/users' });
// Health check
app.get('/health', async () => ({
status: 'ok',
timestamp: new Date().toISOString(),
}));
return app;
}
// src/routes/users.ts
import { FastifyPluginAsync } from 'fastify';
import { Type, Static } from '@sinclair/typebox';
import { UsersService } from '../services/users.service';
const UserSchema = Type.Object({
id: Type.String(),
name: Type.String(),
email: Type.String({ format: 'email' }),
role: Type.Union([Type.Literal('user'), Type.Literal('admin')]),
createdAt: Type.String({ format: 'date-time' }),
});
const CreateUserSchema = Type.Object({
name: Type.String({ minLength: 1 }),
email: .({ : }),
: .({ : }),
: .(.([.(), .()])),
});
= .();
= .({
: .(.({ : , : })),
: .(.({ : , : , : })),
: .(.()),
});
= < >;
= < >;
= < >;
= < >;
: = (fastify) => {
service = ();
fastify.<{ : }>(, {
: {
: [],
: ,
: {
: .({
: .(),
: .({
: .(),
: .(),
: .(),
}),
}),
},
},
: [fastify.],
}, (request) => {
service.(request.);
});
fastify.<{ : { : } }>(, {
: {
: [],
: .({ : .() }),
: { : },
},
: [fastify.],
}, (request, reply) => {
user = service.(request..);
(!user) {
reply.().({ : });
}
user;
});
fastify.<{ : }>(, {
: {
: [],
: ,
: { : },
},
: [fastify., fastify.([])],
}, (request, reply) => {
user = service.(request.);
reply.().(user);
});
fastify.<{ : { : }; : }>(, {
: {
: [],
: .({ : .() }),
: ,
: { : },
},
: [fastify.],
}, (request) => {
service.(request.., request.);
});
fastify.<{ : { : } }>(, {
: {
: [],
: .({ : .() }),
},
: [fastify., fastify.([])],
}, (request, reply) => {
service.(request..);
reply.().();
});
};
// src/plugins/auth.ts
import { FastifyPluginAsync, FastifyRequest } from 'fastify';
import fp from 'fastify-plugin';
import jwt from '@fastify/jwt';
declare module 'fastify' {
interface FastifyInstance {
authenticate: (request: FastifyRequest) => Promise<void>;
authorize: (roles: string[]) => (request: FastifyRequest) => Promise<void>;
}
}
declare module '@fastify/jwt' {
interface FastifyJWT {
payload: { id: string; email: string; role: string };
user: { id: string; email: string; role: string };
}
}
const : = (fastify) => {
fastify.(jwt, {
: process..!,
});
fastify.(, (: ) => {
request.();
});
fastify.(, {
(: ) => {
request.();
(!roles.(request..)) {
fastify..();
}
};
});
};
(authPlugin, {
: ,
});
{ } ;
fp ;
: = (fastify) => {
fastify.( {
fastify..(error);
(error.) {
reply.().({
: ,
: error.,
});
}
statusCode = error. || ;
message = statusCode === && process.. ===
?
: error.;
reply.(statusCode).({ : message });
});
};
(errorHandler, {
: ,
});
// Lifecycle hooks
fastify.addHook('onRequest', async (request, reply) => {
request.startTime = Date.now();
});
fastify.addHook('onResponse', async (request, reply) => {
const duration = Date.now() - request.startTime;
request.log.info({ duration }, 'Request completed');
});
fastify.addHook('onSend', async (request, reply, payload) => {
// Modify response before sending
return payload;
});