npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

sakuraframework

v1.0.8

Published

a web restful framework for node

Readme

sakura

一个node后端框架
具有IOC控制反转、DI依赖注入等特性
提供多种装饰器 如:

Get, Post, Patch, Put, Delete, Options, Head, All  //路由方法装饰器
Query, Body, Headers  //参数装饰器
Controller, Provider, Inject  //IOC装饰器

Quick start

Install

npm i sakuraframework

or if you'd like to use yarn

yarn add sakuraframework

Demo

# 目录结构
src
|-Controller.ts #controller层
|-Service.ts #service层
|-main.ts #启动项目

controller层

// Controller.ts

import { Get, Post, Controller, Inject, Query } from 'sakuraframework'
import { adminService } from './Service'

@Controller('/admin') //根路由
export class Admin {
    // 依赖注入
    @Inject()
    public service: adminService;
    
    // get请求
    @Get('/name') //子路由
    getName(@Query('name') name: string, @Body('age') age: number,@Headers('who') who: string) { // 获取query中的name参数 ,获取body中的age参数, 获取header里的who参数
        console.log('getName');
        return { name, age,who }
    }
    
    // post请求
    @Post('/postName')
    postName(@Body('name') name: string) { // 获取body中的name参数
        console.log('postName');
        return name
    }
}

目前提供了 Get, Post, Patch, Put, Delete, Options, Head, All等请求方法

service层

// Service.ts
import {Provider} from 'sakuraframework';

//提供依赖
@Provider()
export class adminService {
    run() {
        console.log('car is running!');
    }
}

启动项目

// main.ts
import { sakuraAppcation } from 'sakuraframework' //启动类

//导入controller层
import './controller'
new sakuraAppcation(8080).run() //设置端口
//sakuraAppcation(port:number,options:{cors:boolean;}={cors:true}) //设置端口,或设置跨域,默认开启跨域
tsc #编译ts
npm run main.js
输出
sakuraAppcation is running!
running at 127.0.0.1:{your port}

即可访问接口:127.0.0.1:{your port}/admin/name?name=lili

响应结果:lili

特性

依赖注入

import {Provider} from 'sakuraframework';

//提供依赖
@Provider()
export class adminService {
    run() {
        console.log('car is running!');
    }
}
@Controller('/')
class controller{
    // 依赖注入
    @Inject()
    public service: adminService;
}

通过 @Provider()提供依赖 ,通过 @Inject() 即可注入依赖

路由

import { Get, Post, Controller, Inject, Query } from 'sakuraframework'

@Controller('/') //根路由,最终访问路径为根路由加上子路由
export class Admin {

    // get请求
    @Get('/name')  //子路由
    getName() { 
        console.log('getName');
        return 
    }
    
    // post请求
    @Post('/postName')
    postName() {
        console.log('postName');
        return 
    }
}

参数获取

@Controller('/')
export class Admin {

    // get请求
    @Get('/name') 
    getName(@Query('name') name: string, @Body('age') age: number,@Headers('who') who: string) { // 获取query中的name参数 ,获取body中的age参数, 获取header里的who参数
        console.log('getName');
        return { name, age,who }
    }
    
    // post请求
    @Post('/postName')
    postName(@Body() name: Obejct) { // 参数装饰器不传入参数时,默认将全部参数获取为一个对象如 {name:"lili",age:18}
        console.log('postName');
        return name
    }
}

目前提供了@Query(),@Body(),@Headers() 来分别获取query、body、header参数