
Research
/Security News
Mini Shai-Hulud Campaign Hits Red Hat Cloud Services npm Packages
A mini Shai-Hulud campaign compromised Red Hat Cloud Services npm packages to steal developer and CI/CD secrets during installation.
@hestjs/core
Advanced tools
HestJS Core Framework - A TypeScript framework built on Hono with dependency injection and decorators
一个基于 Hono + Bun + TSyringe 的现代化 TypeScript 后端框架,提供类似 NestJS 的开发体验,但具有更轻量和更高性能的特点。
# 克隆项目
git clone https://github.com/aqz236/hest.git
cd HestJS
# 安装依赖
bun install
# 构建包
bun run build
# 运行示例应用
cd apps/hest-demo
bun run dev
// app.controller.ts
import { Controller, Get, Post, Body } from "@hestjs/core";
import { IsString, IsEmail, IsNumber } from "@hestjs/validation";
export class CreateUserDto {
@IsString({ minLength: 2, maxLength: 50 })
name!: string;
@IsEmail()
email!: string;
@IsNumber({ minimum: 0, maximum: 120 })
age!: number;
}
@Controller("/api")
export class AppController {
@Get("/users")
getUsers() {
return { users: [] };
}
@Post("/users")
createUser(@Body(CreateUserDto) createUserDto: CreateUserDto) {
// createUserDto 已经过验证和类型转换
return { success: true, data: createUserDto };
}
}
// app.module.ts
import { Module } from "@hestjs/core";
import { AppController } from "./app.controller";
@Module({
controllers: [AppController],
})
export class AppModule {}
// main.ts
import { HestFactory } from "@hestjs/core";
import { ValidationInterceptor } from "@hestjs/validation";
import { AppModule } from "./app.module";
async function bootstrap() {
const app = await HestFactory.create(AppModule);
// 启用全局验证
app.useGlobalInterceptors(new ValidationInterceptor());
await app.listen(3000);
console.log("🚀 Application is running on: http://localhost:3000");
}
bootstrap();
packages/
├── core/ # 核心框架包
│ ├── decorators/ # 装饰器定义
│ ├── interfaces/ # 核心接口
│ ├── application/ # 应用核心
│ └── exceptions/ # 异常处理
├── validation/ # 验证模块
│ ├── decorators/ # 验证装饰器
│ ├── pipes/ # 验证管道
│ └── interceptors/ # 验证拦截器
└── ...
@Controller("/users")
export class UserController {
@Get("/")
findAll() {
return { users: [] };
}
@Get("/:id")
findOne(@Param("id") id: string) {
return { user: { id } };
}
@Post("/")
create(@Body(CreateUserDto) createUserDto: CreateUserDto) {
return { success: true };
}
}
@Injectable()
export class UserService {
async findAll() {
return [];
}
async create(userData: any) {
// 创建用户逻辑
return userData;
}
}
@Controller("/users")
export class UserController {
constructor(private readonly userService: UserService) {}
@Get("/")
async findAll() {
return await this.userService.findAll();
}
}
export class CreateUserDto {
@IsString({ minLength: 2, maxLength: 50 })
name!: string;
@IsEmail()
email!: string;
@IsNumber({ minimum: 18, maximum: 100 })
age!: number;
@IsOptional()
@IsString()
bio?: string;
}
import { Type } from "@sinclair/typebox";
import { Custom, CommonValidators, SchemaFactory } from "@hestjs/validation";
export class AdvancedDto {
// 使用 TypeBox API 自定义验证
@Custom(
Type.String({
minLength: 3,
maxLength: 20,
pattern: "^[a-zA-Z0-9_]+$",
})
)
username!: string;
// 使用联合类型
@Custom(
Type.Union([
Type.Literal("admin"),
Type.Literal("user"),
Type.Literal("guest"),
])
)
role!: "admin" | "user" | "guest";
// 使用常用验证器
@CommonValidators.UUID()
userId!: string;
// 使用便捷构建器
@Custom(SchemaFactory.chinesePhoneNumber())
phoneNumber!: string;
// 复杂对象验证
@Custom(
Type.Object({
lat: Type.Number({ minimum: -90, maximum: 90 }),
lng: Type.Number({ minimum: -180, maximum: 180 }),
})
)
location!: { lat: number; lng: number };
}
import { Interceptor, ExecutionContext, CallHandler } from "@hestjs/core";
export class LoggingInterceptor implements Interceptor {
intercept(context: ExecutionContext, next: CallHandler) {
console.log("Before...");
const now = Date.now();
return next.handle().then(() => {
console.log(`After... ${Date.now() - now}ms`);
});
}
}
// 使用拦截器
app.useGlobalInterceptors(new LoggingInterceptor());
import {
HttpException,
NotFoundException,
BadRequestException,
} from "@hestjs/core";
@Controller("/users")
export class UserController {
@Get("/:id")
findOne(@Param("id") id: string) {
const user = this.findUserById(id);
if (!user) {
throw new NotFoundException(`User with id ${id} not found`);
}
return user;
}
@Post("/")
create(@Body() userData: any) {
if (!userData.email) {
throw new BadRequestException("Email is required");
}
return this.createUser(userData);
}
}
Phase 1: 核心基础设施 ✅
@Controller, @Injectable, @Module, 路由装饰器)HestFactory.create())Phase 2: 中间件和异常处理 ✅
Phase 3: 验证系统 ✅
基于 Bun 运行时和 Hono 框架,HestJS 提供了卓越的性能:
# 安装依赖
bun install
# 构建所有包
bun run build
# 运行测试
bun run test
# 运行示例应用
cd apps/hest-demo
bun run dev
# 运行 Phase 3 验证测试
bun test-phase3.ts
@Controller(path?) - 定义控制器@Injectable() - 标记可注入服务@Module(options) - 定义模块@Get(path?), @Post(path?), @Put(path?), @Delete(path?) - HTTP 路由@Body(dtoClass?), @Param(key?), @Query(key?) - 参数注入@IsString(), @IsEmail(), @IsNumber() - 基础验证@Custom(schema, options?) - 自定义 TypeBox 验证HestFactory - 应用工厂HttpException - HTTP 异常基类ValidationInterceptor - 验证拦截器Interceptor - 拦截器接口ExecutionContext - 执行上下文欢迎贡献代码!请查看 贡献指南 了解详情。
⭐ 如果这个项目对你有帮助,请给个 Star!
FAQs
HestJS Core Framework - A TypeScript framework built on Hono with dependency injection and decorators
The npm package @hestjs/core receives a total of 21 weekly downloads. As such, @hestjs/core popularity was classified as not popular.
We found that @hestjs/core 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.

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

Research
/Security News
The North Korean malware loader hides in a Packagist-listed package and its GitHub branch to fetch and execute remote code in a likely Contagious Interview-style lure.

Security News
The Rust project is moving toward formal rules on LLM use in contributions after months of internal debate over maintainer burden, code quality, and contributor experience.