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-template-es6

v1.0.3

Published

Express application generator with es6

Readme

Express Logo This package is a class type express template created in es6 version.

Installation

> npm install -g express-template-es6

Initialization

> estemplate init

Make Router

> estemplate make router [routername]

Make Model

> estemplate make model [modelname]

Example

import express from 'express';
import nunjucks from 'nunjucks';
import passportConfig from './passport';

export default class App{
  app = express();    
  port;  
  constructor(appConfig){
    passportConfig();
    nunjucks.configure('views', { // 폴더 경로
      express: this.app,
      watch: true,
    }); 

    this.port = appConfig.port;        
    this.applySettings(appConfig.settings);
    this.applyMiddlewares(appConfig.middlewares);           
    this.applyRoutes(appConfig.routes);        
    this.app.use(this.notFoundError)
    this.app.use(this.serverError);
  }
  

  applySettings(settings){
    settings.forEach(setting => {
      this.app.set(setting.key, setting.value);
    })
  }

  applyRoutes(routes){
    routes.forEach(route => {          
      this.app.use(route.path, route.router);
    })
  }

  applyMiddlewares(middlewares){
    middlewares.forEach(middleware => {      
      this.app.use(middleware);
    })
  }

  notFoundError = (req, res, next) => {
    const error =  new Error(`${req.method} ${req.url} 라우터가 없습니다.`);
    error.status = 404;
    next(error);
  }

  serverError = (err, req, res, next) => {
    res.locals.message = err.message;
    res.locals.error = process.env.NODE_ENV !== 'production' ? err : {};
    res.status(err.status || 500);
    res.render('error');
  }
  

  listen(){
    this.app.listen(this.port, () => {
      console.log(this.port, '번 포트에서 대기중');
    });
  }
}

Usage

This app is es6 based, so it runs on an es6 environment base.

Install the necessary modules before opening the server.

> npm i express dotenv nunjucks

This module is using a sequelize module and must first enter a value in /config/config.json to connect to the database.

The model, router, and middleware settings are set in server.js.

model

import User from './models/user';
import User from './models/domain';

const models = [
  {name : 'User',   value : User},
  {name : 'Domain', value : Domain},
];
const model = new modelIndex(models);

router

import Index from './routes/';
const routes = [    
    new Index(),    
];

middleware

const middlewares = [
    morgan('dev'),
    express.static(path.join(__dirname, 'public')),
    express.json(),
    express.urlencoded({extended: false}),
    cookieParser(process.env.COOKIE_SECRET),
    session({
        resave: false,
        saveUninitialized: false,
        secret: process.env.COOKIE_SECRET,
        cookie: {
            httpOnly: true,
            secure: false,
            }
    }),     
    passport.initialize(),
    passport.session(), 
]

setting

Set the existing express.set() function to key and value.

const settings = [
  {key : 'port', value : process.env.PORT || 8002},
  {key : 'view engine', value : 'html'},
]

start server

const appConfig = {
    routes : routes,
    middlewares : middlewares,
    settings : settings,
    port : process.env.PORT || 3000,
};


new App(appConfig).listen();