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 🙏

© 2025 – Pkg Stats / Ryan Hefner

express-core

v1.0.2

Published

Easily scalable application framework on express.js

Downloads

14

Readme

Express-core

Easily scalable application framework on express.js

Легко масштабируемая инфраструктура приложения на express.js

Example / Пример

We need to deploy the application with dozens of middlewares and a bunch of routs. To place all calls app.use /app.METHOD/ .etc in one file is not cool. Therefore, you can scatter middlewares and handlers for routs on different files.

Нам нужно развернуть приложение с десятками middlewares и кучей роутов. Размещать все вызовы app.use/app.METHOD/.etc в одном файле не круто. Поэтому можно раскидать middlewares и handlers для роутов по разным файлам.

const ROOT = __dirname;

const $expressCore = require('express-core');
const $path = require('path');

const handlersPipeline = [
  'main', // main.js
  'other' // other.js
];

const middlewaresPipeline = [
  'cookie-parser' // cookie-parser.js
];

const {app} = new $expressCore({
  handlersPath: $path.resolve(ROOT, 'handlers'),
  middlewaresPath: $path.resolve(ROOT, 'middlewares'),
  handlers: handlersPipeline,
  middlewares: middlewaresPipeline,
  httpLog: true // switcher of logger for http requests
});

app.listen(1337, () => {
  console.log('started listing port');
});

This example is more detailed / Данный пример подробнее

Initialization the ready express app / Инициализация уже созданного express приложения

It may be necessary to initialize the express application before initiating the entire framework. To do this, you can transfer the finished express application in ExpressCore.

Возможно, понадобится инициализировать express приложение до инициадизации всего каркаса. Для этого можно передать готовое express приложение в ExpressCore.


let _app = $express();

...

const {app} = new $expressCore({
  ...
}, _app); // _app set to this.app for expressCore

app.listen(1337, () => {
  console.log('started listing port');
});

Middleware

Middlewares are functions that can manage app during the initialization process themselves.

Middlewares являются функицями, которые могут управлять app в процессе инициализации самостоятельно.

// middlewares/cookie-parser.js

const cookieParser = require('cookie-parser');

// middleware is independent function
function middleware (app) {
  app.use(cookieParser());
}

module.exports = {
  middleware
};

Handler

Handlers are divided into two types:

  • Primitive
  • Independent (similar to middleware)

Handlers делятся на два типа:

  • Примитивные
  • Самостоятельные (анологично middleware)
// Primitive handler

const path = '/path';

// METOD: get/post/put/option/delete/all
const method = 'GET'; 

function handler (req, res, next) {
  return res.end('Hello, world!');
}

module.exports = {
  path,
  method,
  handler
};
// Independent handler

function independent (app) {
  app.all('*', (req, res) => {
    return res.end('Hello, independent!');
  });
}

module.exports = {
  independent
};