소스 정보
- 저장소
- microwind/ai-skills
- 최근 소스 활동
- 2026년 3월 26일 14:58
- 감지된 SKILL.md 언어
- 중국어
- 스타
- 68
- 포크
- 17
설치 방법
기본적으로 소스를 먼저 확인하는 Prompt가 선택됩니다. 직접 명령으로 전환하거나 로컬 사본을 다운로드할 수도 있습니다.
소스 파일 검토
설치 여부를 결정하기 전에 SKILL.md와 SkillsMP에 표시된 보조 파일을 읽어 보세요.
메뉴
기본적으로 소스를 먼저 확인하는 Prompt가 선택됩니다. 직접 명령으로 전환하거나 로컬 사본을 다운로드할 수도 있습니다.
설치 여부를 결정하기 전에 SKILL.md와 SkillsMP에 표시된 보조 파일을 읽어 보세요.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
직접 명령은 검토 Prompt를 거치지 않습니다. 실행하기 전에 소스를 확인하세요.
npx skills add https://github.com/microwind/ai-skills --skill nestjs명령은 한 줄로 유지됩니다. 복사하기 전에 가로로 스크롤해 전체 내용을 확인하세요.
로컬 사본을 원하시나요? SkillsMP에서 현재 제공할 수 있는 파일을 다운로드하세요.
SOC 직업 분류 기준
SKILL.md 표시 중
| name | NestJS企业架构 |
| description | 当开发NestJS企业应用时,分析模块设计,优化依赖注入,解决架构问题。验证微服务架构,设计企业级应用,和最佳实践。 |
| license | MIT |
NestJS是构建企业级Node.js应用的渐进式框架。不当的NestJS架构设计会导致代码混乱、性能问题和企业级功能缺失。在设计企业级应用前需要仔细分析架构需求。
核心原则: 好的NestJS架构应该模块化、可扩展、可测试、可维护。坏的NestJS架构会导致代码耦合、性能瓶颈和维护困难。
始终:
触发短语:
问题:
模块结构混乱,依赖关系复杂
错误示例:
- 模块职责不清晰
- 循环依赖问题
- 模块过度耦合
- 缺乏模块边界
解决方案:
1. 明确模块职责边界
2. 使用依赖注入解耦
3. 实施模块化设计原则
4. 建立清晰的模块层次
问题:
依赖注入配置复杂,性能影响
错误示例:
- 不必要的服务注入
- 作用域配置错误
- 循环依赖未处理
- 服务生命周期管理不当
解决方案:
1. 合理设计服务依赖
2. 正确配置作用域
3. 处理循环依赖问题
4. 优化服务生命周期
问题:
服务间通信不稳定,数据一致性问题
错误示例:
- 同步通信阻塞
- 缺乏重试机制
- 数据一致性缺失
- 服务发现失效
解决方案:
1. 使用异步通信模式
2. 实施重试和熔断机制
3. 保证数据一致性
4. 完善服务发现机制
import { readFileSync, existsSync, readdirSync, statSync } from 'fs';
import { join, extname } from 'path';
import { parse } from '@typescript-eslint/parser';
import { TSESTree } from '@typescript-eslint/utils';
interface ModuleInfo {
name: string;
file: string;
imports: string[];
providers: string[];
controllers: string[];
exports: string[];
issues: string[];
}
interface ServiceInfo {
name: string;
file: string;
injectable: boolean;
scope: string;
dependencies: string[];
issues: string[];
}
interface ArchitectureIssue {
severity: 'critical' | 'high' | 'medium' | 'low';
type: string;
file: ;
: ;
: ;
?: ;
}
{
: [] = [];
: [] = [];
: [] = [];
() {}
(): {
: ;
: [];
: [];
: [];
: [];
: ;
} {
{
.();
.();
.();
.();
.();
} (error) {
{
: { : },
: [],
: [],
: [],
: [],
:
};
}
}
(): {
scanDirectory = (: ): [] => {
: [] = [];
{
items = (dir);
( item items) {
fullPath = (dir, item);
stat = (fullPath);
(stat.() && !item.() && item !== ) {
files.(...(fullPath));
} (stat.() && (item) === ) {
files.(fullPath);
}
}
} (error) {
.();
}
files;
};
tsFiles = (.);
( file tsFiles) {
.(file);
}
}
(: ): {
{
content = (filePath, );
ast = (content, {
: ,
: ,
:
});
.(ast, filePath);
.(ast, filePath);
} (error) {
..({
: ,
: ,
: filePath,
: ,
:
});
}
}
(: ., : ): {
= () => {
(node. === && .(node)) {
moduleInfo = .(node, filePath);
(moduleInfo) {
..(moduleInfo);
}
}
};
.(ast, visitNode);
}
(: ., : ): {
= () => {
(node. === && .(node)) {
serviceInfo = .(node, filePath);
(serviceInfo) {
..(serviceInfo);
}
}
};
.(ast, visitNode);
}
(: .): {
(!node.) ;
node..( {
(decorator.. === ) {
decorator.. === ;
}
(decorator.. === &&
decorator... === ) {
decorator... === ;
}
;
});
}
(: .): {
(!node.) ;
node..( {
(decorator.. === ) {
decorator.. === ;
}
(decorator.. === &&
decorator... === ) {
decorator... === ;
}
;
});
}
(: ., : ): | {
(!node.) ;
: = {
: node..,
: filePath,
: [],
: [],
: [],
: [],
: []
};
moduleDecorator = node.?.( .({
...node,
: [d]
} .));
(moduleDecorator && moduleDecorator.. === ) {
decoratorArg = moduleDecorator..[];
(decoratorArg && decoratorArg. === ) {
.(decoratorArg, moduleInfo);
}
}
moduleInfo;
}
(: ., : ): {
( property node.) {
(property. === && property.. === ) {
propertyName = property..;
(property.. === ) {
elements = property..
.( el && el. === )
.( (el .).);
(propertyName) {
:
moduleInfo..(...elements);
;
:
moduleInfo..(...elements);
;
:
moduleInfo..(...elements);
;
:
moduleInfo..(...elements);
;
}
}
}
}
}
(: ., : ): | {
(!node.) ;
: = {
: node..,
: filePath,
: ,
: ,
: [],
: []
};
injectableDecorator = node.?.( .({
...node,
: [d]
} .));
(injectableDecorator) {
serviceInfo. = ;
(injectableDecorator.. === ) {
decoratorArg = injectableDecorator..[];
(decoratorArg && decoratorArg. === ) {
.(decoratorArg, serviceInfo);
}
}
}
.(node, serviceInfo);
serviceInfo;
}
(: ., : ): {
( property node.) {
(property. === &&
property.. === &&
property.. === &&
property.. === ) {
serviceInfo. = property..;
}
}
}
(: ., : ): {
(!node.) ;
( member node..) {
(member. === &&
member. === &&
member.. === &&
member..) {
( param member..) {
(param. === &&
param. &&
param... === &&
param.... === ) {
dependencyType = param....;
serviceInfo..(dependencyType);
}
}
}
}
}
(): {
moduleGraph = .();
cycles = .(moduleGraph);
( cycle cycles) {
..({
: ,
: ,
: cycle[],
: ,
:
});
}
( .) {
( imp .) {
(!.(imp)) {
..();
..({
: ,
: ,
: .,
: ,
:
});
}
}
}
}
(): {
( service .) {
(!service.) {
service..();
..({
: ,
: ,
: service.,
: ,
:
});
}
( dep service.) {
depService = ..( s. === dep);
(depService && !depService.) {
service..();
..({
: ,
: ,
: service.,
: ,
:
});
}
}
}
}
(): {
( .) {
totalElements = .. +
.. +
.. +
..;
(totalElements > ) {
..();
..({
: ,
: ,
: .,
: ,
:
});
}
}
( service .) {
(service. === && service.. > ) {
service..();
..({
: ,
: ,
: service.,
: ,
:
});
}
}
}
(): <, []> {
graph = <, []>();
( .) {
graph.(., .);
}
graph;
}
(: <, []>): [][] {
: [][] = [];
visited = <>();
recursionStack = <>();
: [] = [];
dfs = (: ): {
(recursionStack.(node)) {
cycleStart = path.(node);
cycles.([...path.(cycleStart), node]);
;
}
(visited.(node)) {
;
}
visited.(node);
recursionStack.(node);
path.(node);
neighbors = graph.(node) || [];
( neighbor neighbors) {
((neighbor)) {
;
}
}
recursionStack.(node);
path.();
;
};
( node graph.()) {
(!visited.(node)) {
(node);
}
}
cycles;
}
(: ): {
..(
m..(moduleName) ||
m..(moduleName) ||
m..(moduleName) ||
m..(moduleName)
);
}
(: ., : ): {
(node);
( key node) {
child = (node )[key];
(.(child)) {
( item child) {
(item && item === && item.) {
.(item, visitor);
}
}
} (child && child === && child.) {
.(child, visitor);
}
}
}
() {
summary = {
: ..,
: ..,
: ..,
: ..( i. === ).,
: ..( i. === ).,
: ..( i. === ).,
: ..( i. === ).
};
recommendations = .();
healthScore = .(summary);
{
summary,
: .,
: .,
: .,
recommendations,
healthScore
};
}
(): [] {
: [] = [];
issueTypes = <, >();
( issue .) {
issueTypes.(issue., (issueTypes.(issue.) || ) + );
}
(issueTypes.() > ) {
recommendations.({
: ,
: ,
: ,
:
});
}
(issueTypes.() > ) {
recommendations.({
: ,
: ,
: ,
:
});
}
(issueTypes.() > ) {
recommendations.({
: ,
: ,
: ,
:
});
}
recommendations;
}
(: ): {
score = ;
score -= summary. * ;
score -= summary. * ;
score -= summary. * ;
score -= summary. * ;
.(, score);
}
}
{
() {}
(): {
: [];
: ;
} {
: [] = [];
moduleOptimization = .();
(moduleOptimization) {
optimizations.(moduleOptimization);
}
diOptimization = .();
(diOptimization) {
optimizations.(diOptimization);
}
microserviceOptimization = .();
(microserviceOptimization) {
optimizations.(microserviceOptimization);
}
{
optimizations,
: {
: optimizations.,
: .(optimizations)
}
};
}
(): | {
sharedModulePath = (., , , );
(!(sharedModulePath)) {
{
: ,
: ,
:
};
}
;
}
(): | {
configModulePath = (., , , );
(!(configModulePath)) {
{
: ,
: ,
:
};
}
;
}
(): | {
mainTsPath = (., , );
((mainTsPath)) {
{
content = (mainTsPath, );
(!content.() && !content.()) {
{
: ,
: ,
:
};
}
} (error) {
}
}
;
}
(: []): {
: ;
: ;
: ;
} {
improvements = {
: ,
: ,
:
};
( opt optimizations) {
(opt.) {
:
improvements. += ;
improvements. += ;
;
:
improvements. += ;
improvements. += ;
;
:
improvements. += ;
improvements. += ;
;
}
}
improvements;
}
}
() {
analyzer = ();
report = analyzer.();
.();
.();
.();
.();
.();
.();
( rec report.) {
.();
}
optimizer = ();
optimization = optimizer.();
.();
( opt optimization.) {
.();
}
}
{ , };
import { Injectable, OnModuleInit, OnModuleDestroy } from '@nestjs/common';
import { performance } from 'perf_hooks';
interface RequestMetrics {
method: string;
url: string;
statusCode: number;
duration: number;
timestamp: number;
userAgent: string;
ip: string;
}
interface PerformanceMetrics {
cpuUsage: number;
memoryUsage: NodeJS.MemoryUsage;
activeConnections: number;
requestsPerSecond: number;
}
@Injectable()
export class NestJSPerformanceMonitor implements OnModuleInit, OnModuleDestroy {
private requests: RequestMetrics[] = [];
private startTime = performance.now();
private metricsInterval: NodeJS.Timeout;
() {
.();
}
() {
(.) {
(.);
}
}
() {
: = {
: req.,
: req.,
: res.,
duration,
: .(),
: req.[] || ,
: req. || req.. ||
};
..(metrics);
(.. > ) {
..();
}
}
(): {
: ;
: ;
: ;
: ;
: [];
} {
requestStats = .();
performanceStats = .();
routeStats = .();
{
: .(),
: performance.() - .,
requestStats,
performanceStats,
routeStats
};
}
() {
(.. === ) {
{
: ,
: ,
: ,
: ,
: ,
:
};
}
totalRequests = ..;
uptime = performance.() - .;
requestsPerSecond = totalRequests / (uptime / );
responseTimes = ..( r.);
averageResponseTime = responseTimes.( sum + time, ) / totalRequests;
errorRequests = ..( r. >= );
errorRate = (errorRequests. / totalRequests) * ;
{
totalRequests,
requestsPerSecond,
averageResponseTime,
errorRate,
: .(responseTimes, ),
: .(responseTimes, )
};
}
(): {
memUsage = process.();
{
: process.(). / ,
: memUsage,
: ,
: .()
};
}
() {
routeStats = <, >();
( req .) {
routeKey = ;
(!routeStats.(routeKey)) {
routeStats.(routeKey, {
: ,
: ,
: ,
:
});
}
stats = routeStats.(routeKey);
stats.++;
stats. += req.;
stats. = stats. / stats.;
(req. >= ) {
stats.++;
}
}
.(routeStats.())
.( ({ route, ...stats }))
.( b. - a.)
.(, );
}
(: [], : ): {
(values. === ) ;
sorted = values.( a - b);
index = .(sorted. * (percentile / ));
sorted[.(index, sorted. - )];
}
(): {
now = performance.();
recentRequests = ..( now - r. < );
recentRequests. / ;
}
() {
. = ( {
.();
}, );
}
() {
metrics = .();
.(, {
: metrics.,
: metrics.,
: metrics.
});
}
}
() {
{
startTime = performance.();
res.(, {
duration = performance.() - startTime;
monitor.(req, res, duration);
});
();
};
}
{ } ;
{ } ;
{ , } ;
({
: [
,
{
: ,
: {
(monitor);
},
: []
}
]
})
{}