소스 정보
- 저장소
- 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 express-js명령은 한 줄로 유지됩니다. 복사하기 전에 가로로 스크롤해 전체 내용을 확인하세요.
로컬 사본을 원하시나요? SkillsMP에서 현재 제공할 수 있는 파일을 다운로드하세요.
SOC 직업 분류 기준
SKILL.md 표시 중
| name | Express.js服务 |
| description | 当开发Express.js应用时,分析路由设计,优化中间件配置,解决性能问题。验证API架构,设计RESTful服务,和最佳实践。 |
| license | MIT |
Express.js是Node.js最流行的Web框架。不当的Express应用设计会导致性能问题、安全漏洞和维护困难。在开发Express应用前需要仔细分析架构需求。
核心原则: 好的Express应用应该模块化、高性能、安全可靠。坏的Express应用会导致代码混乱、性能瓶颈和安全风险。
始终:
触发短语:
问题:
路由结构混乱,缺乏一致性
错误示例:
- 路由命名不规范
- 缺乏RESTful设计
- 参数验证缺失
- 错误处理不统一
解决方案:
1. 遵循RESTful设计原则
2. 统一路由命名规范
3. 实施参数验证中间件
4. 建立统一错误处理机制
问题:
中间件配置过多或顺序不当
错误示例:
- 不必要的中间件加载
- 中间件执行顺序错误
- 同步中间件阻塞
- 中间件依赖混乱
解决方案:
1. 只加载必要的中间件
2. 正确配置中间件顺序
3. 使用异步中间件
4. 清理中间件依赖关系
问题:
应用响应慢,并发能力差
错误示例:
- 同步阻塞操作
- 内存泄漏
- 数据库连接未复用
- 缺乏缓存机制
解决方案:
1. 使用异步操作避免阻塞
2. 实施内存监控和清理
3. 配置数据库连接池
4. 添加适当的缓存策略
const express = require('express');
const fs = require('fs');
const path = require('path');
const { performance } = require('perf_hooks');
class ExpressAppAnalyzer {
constructor(appPath) {
this.appPath = appPath;
this.issues = [];
this.metrics = {
routes: [],
middlewares: [],
controllers: [],
performance: {}
};
}
analyzeApplication() {
try {
// 分析路由结构
this.analyzeRoutes();
// 分析中间件配置
this.analyzeMiddlewares();
// 分析控制器代码
this.analyzeControllers();
// 性能分析
this.analyzePerformance();
// 生成分析报告
return this.generateReport();
} catch (error) {
{ : };
}
}
() {
{
routesPath = path.(., );
(!fs.(routesPath)) {
..({
: ,
: ,
: ,
:
});
;
}
routeFiles = fs.(routesPath).( file.());
( file routeFiles) {
filePath = path.(routesPath, file);
content = fs.(filePath, );
.(file, content);
}
} (error) {
..({
: ,
: ,
: ,
:
});
}
}
() {
routeInfo = {
: fileName,
: [],
: []
};
httpMethods = [, , , , ];
routePatterns = [];
( method httpMethods) {
regex = (, );
match;
((match = regex.(content)) !== ) {
routePatterns.({
: method.(),
: match[],
: content.(, match.).().
});
}
}
routeInfo. = routePatterns;
( route routePatterns) {
(!.(route.)) {
routeInfo..({
: ,
: ,
: ,
:
});
}
}
(content.() || content.() || content.()) {
(!content.() && !content.() && !content.()) {
routeInfo..({
: ,
: ,
: ,
:
});
}
}
...(routeInfo);
..(...routeInfo.);
}
() {
(path.() || path.() || path.() || path.()) {
;
}
pathParts = path.().( part && !part.());
( part pathParts) {
(part.() || part === || part === ) {
;
}
([, , ].(part)) {
;
}
;
}
;
}
() {
{
appFile = path.(., );
serverFile = path.(., );
mainFile = ;
(fs.(appFile)) {
mainFile = appFile;
} (fs.(serverFile)) {
mainFile = serverFile;
}
(!mainFile) {
..({
: ,
: ,
: ,
:
});
;
}
content = fs.(mainFile, );
.(content);
} (error) {
..({
: ,
: ,
: ,
:
});
}
}
() {
middlewareInfo = {
: ,
: [],
: []
};
commonMiddlewares = [
{ : , : , : },
{ : , : , : },
{ : , : , : },
{ : , : , : },
{ : , : , : }
];
( middleware commonMiddlewares) {
(!middleware..(content)) {
middlewareInfo..({
: middleware.,
: ,
: ,
:
});
} {
middlewareInfo..(middleware.);
}
}
(!content.() || !content.()) {
middlewareInfo..({
: ,
: ,
: ,
:
});
}
lines = content.();
middlewareLines = [];
lines.( {
(line.() && !line.()) {
middlewareLines.({
: index + ,
: line.()
});
}
});
.(middlewareLines, middlewareInfo);
...(middlewareInfo);
..(...middlewareInfo.);
}
() {
hasErrorHandling = ;
hasRoutesAfterError = ;
( middleware middlewareLines) {
(middleware..()) {
hasErrorHandling = ;
} (hasErrorHandling && (middleware..(./routes) || middleware..())) {
hasRoutesAfterError = ;
}
}
(hasRoutesAfterError) {
middlewareInfo..({
: ,
: ,
: ,
:
});
}
}
() {
{
controllersPath = path.(., );
(!fs.(controllersPath)) {
..({
: ,
: ,
: ,
:
});
;
}
controllerFiles = fs.(controllersPath).( file.());
( file controllerFiles) {
filePath = path.(controllersPath, file);
content = fs.(filePath, );
.(file, content);
}
} (error) {
..({
: ,
: ,
: ,
:
});
}
}
() {
controllerInfo = {
: fileName,
: [],
: []
};
functionPattern = ;
match;
((match = functionPattern.(content)) !== ) {
controllerInfo..({
: match[],
: content.(, match.).().
});
}
(content.() && content.()) {
} (controllerInfo.. > ) {
controllerInfo..({
: ,
: ,
: ,
:
});
}
(!content.() && !content.()) {
controllerInfo..({
: ,
: ,
: ,
:
});
}
(content.() && !content.() && !content.()) {
}
...(controllerInfo);
..(...controllerInfo.);
}
() {
{
packageJsonPath = path.(., );
(!fs.(packageJsonPath)) {
..({
: ,
: ,
: ,
:
});
;
}
packageJson = .(fs.(packageJsonPath, ));
.(packageJson);
.(packageJson);
} (error) {
..({
: ,
: ,
: ,
:
});
}
}
() {
dependencies = packageJson. || {};
devDependencies = packageJson. || {};
expressVersion = dependencies.;
(expressVersion) {
(expressVersion.() || expressVersion.()) {
..({
: ,
: ,
: ,
:
});
}
}
securityDeps = [, , , ];
( dep securityDeps) {
(!dependencies[dep] && !devDependencies[dep]) {
..({
: ,
: ,
: ,
:
});
}
}
}
() {
dependencies = packageJson. || {};
devDependencies = packageJson. || {};
performanceDeps = [, , , ];
( dep performanceDeps) {
(!dependencies[dep] && !devDependencies[dep]) {
..({
: ,
: ,
: ,
:
});
}
}
}
() {
summary = {
: ..,
: ..( i. === ).,
: ..( i. === ).,
: ..( i. === ).,
: ..( i. === ).
};
recommendations = .();
{
summary,
: .,
: .,
recommendations,
: .(summary)
};
}
() {
recommendations = [];
issueTypes = {};
..( {
issueTypes[issue.] = (issueTypes[issue.] || ) + ;
});
(issueTypes. > ) {
recommendations.({
: ,
: ,
: ,
:
});
}
(issueTypes. > ) {
recommendations.({
: ,
: ,
: ,
:
});
}
(issueTypes. > ) {
recommendations.({
: ,
: ,
: ,
:
});
}
recommendations;
}
() {
score = ;
score -= summary. * ;
score -= summary. * ;
score -= summary. * ;
score -= summary. * ;
.(, score);
}
}
{
() {
. = appPath;
}
() {
optimizations = [];
packageOptimization = .();
(packageOptimization) {
optimizations.(packageOptimization);
}
middlewareOptimization = .();
(middlewareOptimization) {
optimizations.(middlewareOptimization);
}
routeOptimization = .();
(routeOptimization) {
optimizations.(routeOptimization);
}
{
optimizations,
: {
: optimizations.,
: .(optimizations)
}
};
}
() {
{
packageJsonPath = path.(., );
(!fs.(packageJsonPath)) {
{
: ,
: ,
:
};
}
packageJson = .(fs.(packageJsonPath, ));
optimizations = [];
performanceDeps = [, , ];
( dep performanceDeps) {
(!packageJson.[dep] && !packageJson.[dep]) {
optimizations.(dep);
}
}
(optimizations. > ) {
{
: ,
: ,
:
};
}
} (error) {
{
: ,
: ,
:
};
}
;
}
() {
{
appFile = path.(., );
serverFile = path.(., );
mainFile = ;
(fs.(appFile)) {
mainFile = appFile;
} (fs.(serverFile)) {
mainFile = serverFile;
}
(!mainFile) {
{
: ,
: ,
:
};
}
content = fs.(mainFile, );
optimizations = [];
(!content.()) {
optimizations.();
}
(!content.()) {
optimizations.();
}
(optimizations. > ) {
{
: ,
: ,
:
};
}
} (error) {
{
: ,
: ,
:
};
}
;
}
() {
{
routesPath = path.(., );
(!fs.(routesPath)) {
{
: ,
: ,
:
};
}
routeFiles = fs.(routesPath).( file.());
(routeFiles. === ) {
{
: ,
: ,
:
};
}
( file routeFiles) {
filePath = path.(routesPath, file);
stats = fs.(filePath);
(stats. > ) {
{
: ,
: ,
:
};
}
}
} (error) {
{
: ,
: ,
:
};
}
;
}
() {
improvements = {
: ,
: ,
:
};
optimizations.( {
(opt.) {
:
improvements. += ;
;
:
improvements. += ;
improvements. += ;
;
:
improvements. += ;
;
}
});
improvements;
}
}
() {
analyzer = ();
report = analyzer.();
.();
.();
.();
.();
.();
report..( {
.();
});
optimizer = ();
optimization = optimizer.();
.();
optimization..( {
.();
});
}
. = { , };
const express = require('express');
const { performance } = require('perf_hooks');
class ExpressPerformanceMonitor {
constructor(app) {
this.app = app;
this.metrics = {
requests: [],
responseTimes: [],
errorCounts: {},
routeStats: {}
};
this.setupMonitoring();
}
setupMonitoring() {
// 请求计时中间件
this.app.use((req, res, next) => {
const start = performance.now();
res.on('finish', () => {
const duration = performance.now() - start;
this.recordRequest(req, res, duration);
});
next();
});
// 错误监控中间件
this.app.use((err, req, res, next) => {
this.recordError(err, req);
(err);
});
}
() {
requestInfo = {
: req.,
: req.,
: res.,
: duration,
: ().(),
: req.(),
: req. || req..
};
...(requestInfo);
...(duration);
routeKey = ;
(!..[routeKey]) {
..[routeKey] = {
: ,
: ,
: ,
:
};
}
stats = ..[routeKey];
stats.++;
stats. += duration;
stats. = stats. / stats.;
(res. >= ) {
stats.++;
}
(... > ) {
...();
}
(... > ) {
...();
}
}
() {
errorKey = err. || ;
..[errorKey] = (..[errorKey] || ) + ;
}
() {
responseTimeStats = .();
errorRate = .();
topRoutes = .();
{
: ...,
responseTimeStats,
errorRate,
: ..,
topRoutes,
: ().()
};
}
() {
times = ..;
(times. === ) {
{ : , : , : , : , : };
}
sorted = times.( a - b);
len = sorted.;
{
: times.( sum + time, ) / len,
: sorted[],
: sorted[len - ],
: sorted[.(len * )],
: sorted[.(len * )]
};
}
() {
totalRequests = ...;
errorRequests = ...( req. >= ).;
totalRequests > ? (errorRequests / totalRequests) * : ;
}
() {
routes = .(..);
routes
.( b. - a.)
.(, )
.( ({ route, ...stats }));
}
}
. = ;