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

generator-express-layered

v1.0.11

Published

A Yeoman generator for creating express-layered applications

Downloads

28

Readme

generator-express-layered

A Yeoman generator for quickly setting up an Express layered architecture with models, services, controllers, routes, and middleware.

Requirements

Before using this generator, you'll need to have Yeoman installed globally. You can install Yeoman using npm:

npm install -g yo

Yeoman (yo) is a scaffolding tool that helps you quickly generate code and project structures.

Installation

Once Yeoman is installed, you can install this generator globally with the following command:

npm install -g generator-express-layered

Usage

To generate an Express app structure with a layered architecture, run the generator using:

yo express-layered

The Generator Prompts

When you run the generator, you will be prompted to provide:

  • Project Name: Enter the name of your project. This will be used to create a new directory and name files as needed.

After entering the project name, the generator will scaffold a project structure for you.

What This Generator Does

Project Structure:

  • server/app.js: The main application entry point.
  • server/server.js: Server setup and initialization.
  • server/routes/api.js: API routes configuration.
  • server/controllers/: Contains controllers for handling route logic.
  • server/services/: Contains services for business logic.
  • server/models/: Folder for model definitions (empty by default).
  • server/middleware/api-response.middleware.js: Middleware for standardized API responses.
  • Other configuration files like .gitignore and placeholder files (.gitkeep) for empty directories.

npm Dependencies:

  • Express: A web framework for Node.js.
  • Nodemon: For automatically reloading the server during development.

Post-generation:

After scaffolding the project, the generator automatically runs npm install to install all necessary dependencies.

Example Project Structure

After running the generator, your project structure will look similar to this:

project-name/
├── server/
│   ├── app.js
│   ├── server.js
│   ├── routes/
│   │   └── api.js
│   ├── controllers/
│   │   └── base-controller.js
│   ├── middleware/
│   │   └── api-response.middleware.js
│   ├── models/
│   ├── services/
│   │   └── base-service.js
│   └── .gitignore
└── package.json

Customizing the Generated Files

Once the generator has run, you can customize the generated files and add your own models, services, and controllers as needed. The generator also includes sub-generators for adding models that will automatically create associated service, controller, and route files.

How the Add-Model Generator Works

You would typically run the add-model sub-generator with:

yo express-layered:add-model

What the Add-Model Generator Does

When executed, the add-model sub-generator:

  1. Prompts for model information:

    • Model name (e.g., "User", "User-Products")
  2. Generates a complete vertical slice through your layered architecture by creating:

    • A model file in the server/models/ directory
    • A corresponding service in the server/services/ directory
    • A controller in the server/controllers/ directory
    • Route definitions in the appropriate route file (extending server/routes/api.js)
  3. Follows naming conventions like:

    • server/models/user.model.js
    • server/services/user.service.js
    • server/controllers/user.controller.js
  4. Connects the layers by:

    • Injecting the model into the service
    • Injecting the service into the controller
    • Registering the routes in the API router

Generated Files Example

For a "User" model, the generated files might look like:

server/
├── models/
│   └── user.model.js
├── services/
│   └── user.service.js
├── controllers/
│   └── user.controller.js
└── routes/
    └── api.js (updated with user routes)
    └── user-router.js

This approach follows the layered architecture pattern, maintaining separation of concerns while automating the repetitive task of creating connected components across different layers of your application.