
Research
/Security News
Miasma Mini Shai-Hulud Hits ImmobiliareLabs npm Packages
Miasma Mini Shai-Hulud hits @immobiliarelabs Backstage plugins, targeting GitLab and LDAP auth packages on npm.
@yuo/glede-server
Advanced tools
import {
GledeRouter,
Get,
Post
} from '@yuo/glede-server';
// routers/api/user/index.ts
export class Router extends GledeRouter {
// 注意方法不要使用箭头函数
// 1. 依赖原型处理逻辑; 2. 注入依赖工具方便处理请求
getAllUser(this: GledeUtil, data: GledeReqData) {
// doSomething.
if (noPass) {
return {
// 1 客户端参数校验未通过, 业务无需关心
// >= 2 自定义
code: 2,
data: null,
msg: '描述错误原因'
};
}
return {
code: 0, // 0 处理成功
data: {
// ...
}
};
}
}
目前单个项目中只能创建一个Server实例, 暂时无mono-repo的要求。
若后续使用mono-repo, 则考虑新增配置 basePath: '',
路由注册、日志记录、文档校验、数据库等操作基于basePath
// 新建或修改路由文件
// mkdir routers/${api | openapi}/${router | routerDir/index.ts}
// api|openapi目录下存放路由可以是ts文件或目录, 文件内和目录内的Schema定义可相互引用
// 示例 /routers/api/user/index.ts
import {
getAllUsersSchema,
getAllUsersSchemaV2,
} from './schema';
export Router extends GledeRouter {
// version是接口的版本用于线上并行, 可选:默认 '', 如果出现版本区分可填写 v1, v2, ...
// schema是参数的拦截校验, 必选:1. 客户端字段安全拦截 2. 增加序列化的性能10%~15% 3. 生成接口文档协同开发
// match: /api/v1/:id
@Get('/:id', { version: 'v1', schema: getAllUsersSchema }) @Cors()
getAllUsers(this: GledeUtil, data: GledeReqData): GledeResData {
return {
code: 0,
data: {
// ...
}
};
}
@Get('/:id', { version: 'v2', schema: getAllUsersSchemaV2 })
@Post('/:id', { schema})
@NeedAuth('super') @Cors('https://philuo.com', 'GET,POST')
getAllUsersV2(this: GledeUtil, data: GledeReqData): GledeResData {
return {
code: 0,
data: {
// ...
}
};
}
}
FAQs
Web业务服务器
The npm package @yuo/glede-server receives a total of 4 weekly downloads. As such, @yuo/glede-server popularity was classified as not popular.
We found that @yuo/glede-server demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Research
/Security News
Miasma Mini Shai-Hulud hits @immobiliarelabs Backstage plugins, targeting GitLab and LDAP auth packages on npm.

Security News
Rolldown paused Rust React Compiler integration after a 5MB binary size increase raised concerns about shipping React-specific code to all Vite users.

Security News
/Research
Mini Shai-Hulud expands into the Go ecosystem after hitting LeoPlatform npm packages and targeting GitHub Actions workflows.