
Security News
pnpm 11.5 Adds Support for Recognizing npm Staged Publishes
pnpm 11.5 now recognizes npm staged publish approvals in release metadata, preventing those releases from being mistaken for lower-trust package publishes.
@hestjs/demo
Advanced tools
HestJS Demo Application - A demonstration of HestJS framework capabilities
一个基于 HestJS 框架的现代化 TypeScript 演示应用,展示了类似 NestJS 的开发体验,但具有更轻量和更高性能的特点。
src/
├── main.ts # 应用入口点
├── app.module.ts # 根模块
├── app.controller.ts # 应用控制器
├── app.service.ts # 应用服务
├── config/ # 配置文件
│ └── app.config.ts # 应用配置
├── common/ # 公共组件
│ ├── filters/ # 全局过滤器
│ │ └── http-exception.filter.ts
│ └── interceptors/ # 全局拦截器
│ └── response.interceptor.ts
└── modules/ # 功能模块
├── users/ # 用户模块
│ ├── dto/ # 数据传输对象
│ │ └── user.dto.ts
│ ├── entities/ # 实体定义
│ │ └── user.entity.ts
│ ├── users.controller.ts
│ ├── users.service.ts
│ └── users.module.ts
└── custom-validation/ # 自定义验证模块
├── dto/
│ └── custom-validation.dto.ts
├── custom-validation.controller.ts
├── custom-validation.service.ts
└── custom-validation.module.ts
bun install
# 开发模式(热重载)
bun run dev
# 或者在 monorepo 根目录
turbo run dev --filter=@hestjs/demo
# 构建
bun run build
# 生产环境运行
bun run start:prod
# 创建独立可执行文件
bun run build:binary
./dist/hest-demo
GET /api - 应用信息GET /api/health - 健康检查/users)GET /users - 获取所有用户GET /users/:id - 获取特定用户POST /users - 创建新用户POST /users/:id - 更新用户信息# 创建用户
curl -X POST http://localhost:3002/users \
-H "Content-Type: application/json" \
-d '{
"name": "John Doe",
"email": "john@example.com",
"age": 30,
"password": "password123"
}'
/api/custom)GET /api/custom - 验证功能说明POST /api/custom/validate - 测试自定义验证POST /api/custom/search - 测试搜索参数验证GET /api/custom/examples - 获取验证示例# 自定义验证
curl -X POST http://localhost:3002/api/custom/validate \
-H "Content-Type: application/json" \
-d '{
"username": "john_doe123",
"role": "user",
"userId": "123e4567-e89b-12d3-a456-426614174000",
"phoneNumber": "13812345678",
"location": { "lat": 39.9042, "lng": 116.4074 },
"emails": ["john@example.com", "john.doe@company.com"]
}'
@Injectable() 和 @Module() 装饰器.env 文件配置export class CreateUserDto {
@IsString({ minLength: 2, maxLength: 50 })
name!: string;
@IsEmail()
email!: string;
@IsNumber()
@Min(0)
@Max(120)
age!: number;
}
export class CustomValidationDto {
// 正则表达式验证
@Custom(
Type.String({ minLength: 3, maxLength: 20, pattern: '^[a-zA-Z0-9_]+$' }),
{ message: '用户名必须是3-20位字母、数字或下划线' },
)
username!: string;
// 联合类型验证
@Custom(
Type.Union([
Type.Literal('admin'),
Type.Literal('user'),
Type.Literal('guest'),
]),
{ message: '角色必须是 admin、user 或 guest' },
)
role!: 'admin' | 'user' | 'guest';
// UUID 验证
@CommonValidators.UUID()
userId!: string;
// 中国手机号验证
@Custom(SchemaFactory.chinesePhoneNumber(), { optional: true })
phoneNumber?: string;
// 嵌套对象验证
@Custom(
Type.Object({
lat: Type.Number({ minimum: -90, maximum: 90 }),
lng: Type.Number({ minimum: -180, maximum: 180 }),
}),
{ optional: true },
)
location?: { lat: number; lng: number };
}
FROM oven/bun:1 as base
WORKDIR /app
# 复制依赖文件
COPY package.json bun.lock ./
RUN bun install --frozen-lockfile
# 复制源代码
COPY . .
# 构建应用
RUN bun run build
# 运行应用
CMD ["bun", "run", "start:prod"]
EXPOSE 3002
# 构建独立可执行文件
bun run build:binary
# 部署单个文件
./dist/hest-demo
# 运行测试
bun test
# 覆盖率测试
bun test --coverage
src/modules/ 下创建新目录*.module.ts、*.controller.ts、*.service.tsapp.module.ts 中导入新模块dto/ 目录下创建 DTO 类@Custom() 装饰器定义验证规则@Body() 装饰器应用验证# .env 文件
PORT=3002
NODE_ENV=development
CORS_ORIGIN=*
欢迎提交 Issue 和 Pull Request!
MIT License
FAQs
HestJS Demo Application - A demonstration of HestJS framework capabilities
The npm package @hestjs/demo receives a total of 15 weekly downloads. As such, @hestjs/demo popularity was classified as not popular.
We found that @hestjs/demo demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer 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.

Security News
pnpm 11.5 now recognizes npm staged publish approvals in release metadata, preventing those releases from being mistaken for lower-trust package publishes.

Security News
Federal audit finds NIST lacked a plan to clear the NVD backlog, wasted funds on duplicate work, and delayed use of CISA data.

Research
/Security News
A mini Shai-Hulud campaign compromised Red Hat Cloud Services npm packages to steal developer and CI/CD secrets during installation.