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

pokemen

v1.0.2

Published

> TODO: description

Readme

koa-ts

The best practice of building Koa2 with TypeScript. 中文


Usage

This layout requires NodeJS v12+

  1. Run npm init koa-ts.

  2. Install dependencies: yarn or npm i.

  3. Start the server: yarn dev or npm dev. visit: http://127.0.0.1:3000/apis/sessions

(Optional) if you need database, set useDatabase to true.(in configs/customs.ts).

(Optional) the project has built-in a docker-compose, run npm run mongo lift mongodb automatic.


Project Layout

├── app
│   ├── controllers         ---  server controllers
│   ├── helpers             ---  helper func (interceptor / error handler / validator...)
│   ├── jobs                ---  task (periodic task / trigger task / email server...)
│   ├── entities            ---  database entities/models
│   └── services            ---  adhesive controller and model
├── config
│   ├── environments        ---  environment variable
│   ├── koa.middlewares     ---  middlewares for Koa
│   ├── routing.middlewares ---  middlewares for Routing Controller
│   ├── routing.options     ---  configs for Routing Controller
│   ├── connection          ---  database connection
│   ├── bootstrap           ---  lifecycle
│   ├── customs             ---  user settings
│   └── interceptors        ---  global interceptor
│   └── utils               ---  pure functions for help
└── test                    ---  utils for testcase
├── variables.env           ---  environment file

Feature

  • Separation configuration and business logic.

  • Export scheme model and interface, follow style of TypeScript.

  • Test cases and lint configuration.

  • The best practice for Dependency Injection in Koa project.

  • Deploy by ncc.

  • TypeScript hotload.


Lifecycle

  1. app.ts -> collect env vars environments -> collect env files variables.env

  2. envs ready, call bootstrap.before()

  3. configs/connection.ts connecting external services (e.g. DB / Redis...)

  4. lift routing-controllers -> lift Koa middlewares -> register Container for DI

  5. start Koa & invoke bootstrap.after() after startup

  6. configs/connection.ts connected -> invoke bootstrap.connected()


Databases

You can link multiple databases (mysql / mongo etc.), each database can link configurations of multiple environments:

  1. The database will load the configs of ormconfig.js file.
  2. You can specify link configs of multiple environments under folder configs/environments.
  3. You can specify encrypted information in file variables.env. It is not recommended to add file variables.env to version control.
  4. You can still manually set process.env to override all environment variables.

About Environments

  • Development Mode (NODE_ENV=development): read configurations from configs/environments/development.ts file, but it will still be overwritten by variables.env file.

  • Production Mode (NODE_ENV=production): read configurations from configs/environments/production.ts file, but it will still be overwritten by variables.env file.


Reference


LICENSE

This project is licensed under the MIT License. See the LICENSE file for more info.