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

decoress

v0.1.3

Published

a minimal package for decorating express controllers

Downloads

5

Readme

Decoress

A minimal package for creating express controllers using decorators in typescript. you can use your express as before. this package tends to be lightweight and only add decorators to your controllers.

Features

  • very minimal and lightweight
  • handling asynchronous functions
  • makes your code cleaner

Installation

  1. install express and decoress:
npm install decoress --save-exact
npm install express
  1. in tsconfig.json set these options:
{
  "emitDecoratorMetadata": true,
  "experimentalDecorators": true
}

Usage

  1. first you need to import Controller and a method (for example Get) and add them to your class. you can also add your middlewares using Mw decorator.

    for example create Data.controller.ts file and add these code:

import { Mw, Get, Post, Controller } from 'decoress';

function aMiddleware(req: any, res: any, next: any) {
  next();
}

@Controller('/data')
export class UserController {
  @Get('/get')
  @Mw(aMiddleware)
  async get(req: any, res: any) {
    res.send('...data');
  }

  @Post('/post')
  async post(req: any, res: any) {
    res.send('...data');
  }
}
  1. then you need to pass your controllers to setControllers

for example create app.ts file and add these to it:

import express from 'express';
import { setControllers } from 'decoress';
import { UserController } from './data.controller';

const app = express();

app.listen(3000);

setControllers(app, { controllers: [UserController] });

now if you open http://localhost:3000/data/get in your browser you should see the response.

Settings

pathPrefix

you can set pathPrefix in setControllers

setControllers(app, { controllers: [UserController], pathPrefix: '/api' });

now you should see the response if you open http://localhost:300/api/data/get in your browser.

options

  • catchAsync

    by default decoress handles async functions in express and catch the error and send it to errorHandler with next() function.

    but you can disable it in setControllers:

setControllers(app, {
  controllers: [UserController],
  options: { catchAsync: false },
});

Middlewares

you have two ways to implement middlewares:

  1. as shown above you can use Mw() decorator. for example you have validate() function which you want to use as middleware:
  @Get('/get')
  @Mw(validate(schema))
  async get(req: any, res: any) {
    res.send('...data');
  }
  1. create a wrapper around Mw() decorator. if you use a middleware repeatedly, for example validate(), you may want to use Validate(schema) instead of Mw(validate(schema)):
// in validateMw.ts file
import { Mw } from 'decoress';

// your wrapper
export function Validate(schema) {
  // your middleware
  function fn(req: any, res: any, next: any) {
    // ... do something with schema or whatever
    next();
  }
  // pass yuor middleware to Mw decorator and return it
  return Mw(fn);
}

then you can use it as decorator:

// in your controller.ts file

import { Get, Controller } from 'decoress';
import { Validate } from './validateMw.ts';
import { schema } from './someFile.ts';

@Controller('/data')
export class UserController {
  @Get('/get')
  @Validate(schema)
  async get(req: any, res: any) {
    res.send('...data');
  }
}

Inspired by