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

express-simple-decorator

v1.0.17

Published

This is new express framework

Readme

Express simple decorator

Installation

requried:

https://github.com/microsoft/tsyringe
typescript

and install

npm install express-simple-decorator || yarn add express-simple-decorator

How to use

1, Create controller by @Controller('prefix_router') Example:

@Controller('users')
class UserController {
  @Route({path : 'test', method: HttpMethod.GET})
    async test(@Request req, @Response res): Promise<any> {
        //this controller will generator /users/test route with GET Method.
        
        //or res.send('hello world');
        return "hello world";
    }
}

2, Register controller and start service Example

import {ExpressWebService} from "express-simple-decorator";
import {container} from "tsyringe";

container.register('controllers', {
            useValue: [
                UserController,
            ]
})

const expressService = container.resolve(ExpressWebService);
expressService.run();

3, edit .env to point to port whatever you want and your key application or default will running with port 3000.

+ APPLICATION_KEY = key_of_application
+ APPLICATION_PORT = 3000

4, Start service and enjoy.

Usage

@Controller('prefix_route')

Description: It's define for all Route inside class Example: Above

@Route({object})

object with params:

path: Defind your path not include prefix route of @Controller
method: 'GET'. 'POST', 'PUT',
responseCode: it's response code.

It define route of url like:

/test
/test/:id
/test/:id/hello/:name

It's depen on you logic Example: above

@Request / @Response

It's take param request and param response express function, you can use it dynamic without remember it order. Example:

@Controller('users')
class UserController {
  @Route({path : 'test', method: HttpMethod.GET})
    async test(@Request req, @Response res): Promise<any> {
        //You no need to remember it order, you can change it to
        //test(another_param, @Request req, another2_param,...)

        res.send(req.params.id);
        //order simple without param res return req.params.id;
    }
}

@Param

When you defind route like: @Route({path: 'users/:id/post/:postId'}) Then you have 2 options, 1 using @Request, 2 using @Param There 2 way using @Param

@Route({path: 'users/:id/post/:postId'})
async test(@Param param)
then `param` variable take all prames like (id, postId)
and using by param.id, param.postId to get data
@Route({path: 'users/:id/post/:postId'})
async test(@Param('id') id, @Param('postId') postId)
then id take value from :id and postId take from :postId

@Middleware

Defind middleware Class middleware

import { BaseMiddleware, Middleware } from "express-simple-decorator";

@Middleware()
export default class AdminPermission extends BaseMiddleware {
    apply(req, res, next){
        if(req.user.role !== Role.ADMIN){
            res.send({ status: false, message: "Server Error", error: "User Are Not Authorized" });
        }
        next();
    }
}

Global middleware

add register
container.register('globalMiddleware', {
            useValue: [
                bodyParser.urlencoded({ extended: false }),
                //middleware 2
                //middleware 3
                //...etc
            ]
        });

Local Middleware Using middleware for whole controller

@Controller('users')
@Middleware('name or function or class of middleware')
export class UserController {
}

Route Middleware Using middleware for route only

@Controller('users')
export class UserController {
  @Middleware('name or function or class of middleware')
  async test(@Request request): Promise<any>
}

You can using tsyringe for specialy alias middleware

@Body

Use https://github.com/typestack/class-validator to validate request before there going in route Example:

import {IsEmail, Length} from "class-validator";

export class RegisterRequest {
    @IsEmail()
    email: string;

    @Length(6)
    password: string;
}

@Controller('users')
export class UserController {
@Route({ path: '/register', method: HttpMethod.POST })
    async register(@Body registerRequest: RegisterRequest): Promise<any> {
        //do register with registerRequest.email and registerRequest.password
    }
}