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-sweet-generator

v4.0.0

Published

EXPRESS SWEET application generator.

Readme

EXPRESS SWEET Generator

Scaffold production-ready Express.js applications in seconds.

A powerful application generator for EXPRESS SWEET that creates a complete, feature-rich web application with authentication, database ORM, frontend bundling, and professional project structure out of the box.

Express 5 Ready

Version 4.0+ generates applications with full Express 5 compatibility:

  • Express 5.2.1 - Latest Express version with modern features
  • Node.js 18+ - Requires Node.js 18.x or higher
  • express-handlebars v7.1.3 - Maintained at v7 for Node.js 18+ compatibility (v8 requires Node.js 20+)
  • Modern Route Patterns - Templates use RegExp with named capture groups for route validation
  • File Upload Support - Includes config/upload.js for Multer configuration

For more details on Express 5 changes, see the Express.js Release Notes.

Table of Contents

Installation

npm install -g express-sweet-generator

Quick Start

Use the express-sweet-generator tool to quickly create a fully-featured application skeleton with all the essentials preconfigured.

Image

1. Generate Application

Create an Express app named myapp. The application will be created in a folder named myapp in the current working directory.

# Generate ESM (ECMAScript Modules) application
express-sweet -o esm myapp

# Or generate CJS (CommonJS) application (default)
express-sweet myapp

2. Install Dependencies

cd myapp/
npm install

3. Database Setup

The generated template uses MySQL/MariaDB as an example database. EXPRESS SWEET supports any Sequelize-compatible database (MySQL, PostgreSQL, SQLite, etc.).

Create a database with the following SQL:

-- Create database
CREATE DATABASE IF NOT EXISTS `sample_db` DEFAULT CHARACTER SET utf8mb4;

USE `sample_db`;

-- User table: Stores user account information
CREATE TABLE `user` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Primary key',
  `name` varchar(30) NOT NULL COMMENT 'User display name',
  `email` varchar(255) NOT NULL COMMENT 'User email address (unique)',
  `password` varchar(100) NOT NULL COMMENT 'Encrypted password',
  `icon` varchar(768) NOT NULL DEFAULT MD5(RAND()) COMMENT 'User icon path or identifier',
  `created` datetime NOT NULL DEFAULT current_timestamp() COMMENT 'Record creation timestamp',
  `modified` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() COMMENT 'Record last modified timestamp',
  PRIMARY KEY (`id`),
  UNIQUE KEY `ukUserEmail` (`email`),
  UNIQUE KEY `ukUserIcon`(`icon`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='User accounts table';

-- Profile table: Stores additional user profile information
CREATE TABLE `profile` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Primary key',
  `userId` int(10) unsigned NOT NULL COMMENT 'Foreign key to user table',
  `address` varchar(255) NOT NULL COMMENT 'User address',
  `tel` varchar(14) NOT NULL COMMENT 'User telephone number',
  `created` datetime NOT NULL DEFAULT current_timestamp() COMMENT 'Record creation timestamp',
  `modified` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() COMMENT 'Record last modified timestamp',
  PRIMARY KEY (`id`),
  UNIQUE KEY `ukProfileUserId` (`userId`),
  CONSTRAINT `fkProfileUser` FOREIGN KEY (`userId`) REFERENCES `user` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='User profiles table';

-- Comment table: Stores user comments
CREATE TABLE `comment` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Primary key',
  `userId` int(10) unsigned NOT NULL COMMENT 'Foreign key to user table',
  `text` text NOT NULL COMMENT 'Comment text content',
  `created` datetime NOT NULL DEFAULT current_timestamp() COMMENT 'Record creation timestamp',
  `modified` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() COMMENT 'Record last modified timestamp',
  PRIMARY KEY (`id`),
  CONSTRAINT `fkCommentUser` FOREIGN KEY (`userId`) REFERENCES `user` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='User comments table';

-- Book table: Stores user books
CREATE TABLE `book` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Primary key',
  `userId` int(10) unsigned NOT NULL COMMENT 'Foreign key to user table',
  `title` text NOT NULL COMMENT 'Book title',
  `created` datetime NOT NULL DEFAULT current_timestamp() COMMENT 'Record creation timestamp',
  `modified` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() COMMENT 'Record last modified timestamp',
  PRIMARY KEY (`id`),
  UNIQUE KEY `ukBookTitle` (`userId`, `title`(255)),
  CONSTRAINT `fkBookUser` FOREIGN KEY (`userId`) REFERENCES `user` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='User books table';

-- Sample data insertion
INSERT INTO `user` (`id`, `email`, `password`, `name`, `icon`) VALUES
  (1, '[email protected]', 'password', 'Robin', '/upload/1.png'),
  (2, '[email protected]', 'password', 'Taylor', '/upload/2.png');

INSERT INTO `profile` (`userId`, `address`, `tel`) VALUES
  (1, '777 Brockton Avenue, Abington MA 2351', '202-555-0105'),
  (2, '30 Memorial Drive, Avon MA 2322', '');

INSERT INTO `comment` (`userId`, `text`) VALUES
  (1, 'From Robin #1'),
  (1, 'From Robin #2'),
  (2, 'From Taylor #1');

INSERT INTO `book` (`userId`, `title`) VALUES
  (1, 'Beautiful'),
  (1, 'Lose Yourself'),
  (2, 'When Im Gone');

4. Database Configuration

Configure the database connection in config/database.js. For more details, refer to the Sequelize documentation.

For ESM applications:

export default {
  development: {
    username: 'root',
    password: 'password',
    database: 'sample_db',
    host: 'localhost',
    dialect: 'mariadb'
  },
  test: {
    username: 'root',
    password: 'password',
    database: 'sample_db',
    host: 'localhost',
    dialect: 'mariadb'
  },
  production: {
    username: 'root',
    password: 'password',
    database: 'sample_db',
    host: 'localhost',
    dialect: 'mariadb'
  }
}

For CJS applications:

module.exports = {
  development: {
    username: 'root',
    password: 'password',
    database: 'sample_db',
    host: 'localhost',
    dialect: 'mariadb'
  },
  test: {
    username: 'root',
    password: 'password',
    database: 'sample_db',
    host: 'localhost',
    dialect: 'mariadb'
  },
  production: {
    username: 'root',
    password: 'password',
    database: 'sample_db',
    host: 'localhost',
    dialect: 'mariadb'
  }
}

5. Environment Configuration

The database environment can be defined in the .env file:

NODE_ENV=development

6. Run the Application

Start the application:

npm start

7. Access the Application

Open your browser and navigate to http://localhost:3000/ to access the application.

Application Structure

The generated application has the following directory structure:

.
├── .env                          # Environment variables configuration
├── app.js                        # Main application entry point
├── ecosystem.config.js           # PM2 process manager configuration
├── nginx.sample.conf             # Sample Nginx reverse proxy configuration
├── package.json                  # Node.js dependencies and scripts
├── bin
│   └── www                       # Application startup script
├── client                        # Frontend application directory
│   ├── package.json              # Frontend dependencies
│   ├── webpack.config.js         # Webpack bundler configuration
│   └── src                       # Frontend source code
├── config                        # Application configuration files
│   ├── authentication.js         # Authentication and session settings
│   ├── config.js                 # Core application configuration
│   ├── database.js               # Database connection settings
│   ├── logging.js                # HTTP request logging configuration
│   ├── upload.js                 # File upload (Multer) configuration
│   └── view.js                   # Template engine configuration
├── errors                        # Custom error classes
│   └── NotFoundError.js          # Custom error definitions
├── middlewares                   # Express middlewares
│   └── checkValidationResult.js  # Validation middleware
├── models                        # Database models (Sequelize ORM)
│   ├── BookModel.js              # Book entity model
│   ├── CommentModel.js           # Comment entity model
│   ├── ProfileModel.js           # User profile model
│   └── UserModel.js              # User entity model
├── public                        # Static assets directory
│   ├── build                     # Compiled frontend assets
│   └── upload                    # User uploaded files
├── routes                        # Express route definitions
│   ├── login.js                  # Authentication routes
│   ├── profile.js                # Profile management routes
│   ├── users.js                  # User management routes
│   └── api                       # API endpoints
│       ├── profile.js            # Profile API routes
│       └── users.js              # User API routes
├── validators                    # Custom validation functions
│   └── isValidImageDataUrl.js    # Image validation
└── views                         # Handlebars template files
    ├── error.hbs                 # Error page template
    ├── login.hbs                 # Login page template
    ├── layout                    # Layout templates
    │   └── default.hbs           # Default page layout
    ├── partials                  # Reusable template components
    │   └── .gitkeep              # Placeholder for partial templates
    ├── users
    │   └── index.hbs             # Users listing template
    ├── profile
    │   ├── show.hbs              # Profile display template
    │   └── edit.hbs              # Profile editing template
    └── errors
        ├── 404.hbs               # 404 error template
        └── 500.hbs               # 500 error template

Key Directories Explained

Configuration (config/) Contains all application settings divided by functionality. Modify these files to customize database connections, authentication behavior, view rendering, logging, and file uploads.

Models (models/)
Database entities using Sequelize ORM. Each model represents a database table and defines the schema, relationships, and business logic for that entity.

Routes (routes/)
URL endpoint handlers organized by feature. The file structure automatically maps to URL paths - for example, routes/api/users.js handles requests to /api/users.

Views (views/)
Handlebars templates for rendering HTML pages. The layout/ directory contains base templates, while partials/ holds reusable components.

Public (public/) Static files served directly by the web server. The build/ directory contains compiled frontend assets, while upload/ stores user-generated content.

Getting Started with Your Generated Application

Once your application is generated and running, you can:

  1. Explore the Features: Visit the main framework documentation to understand routing, models, authentication, and the view system
  2. Customize Configuration: Modify files in the config/ directory to suit your project needs
  3. Add New Models: Create additional models in the models/ directory following the existing patterns
  4. Build Routes: Add new routes in the routes/ directory for your application logic
  5. Create Views: Design templates in the views/ directory using Handlebars

For detailed tutorials and advanced usage, visit the EXPRESS SWEET Documentation.

API Reference

For comprehensive documentation on using the generated application, refer to the EXPRESS SWEET Documentation.

The complete API reference includes:

Command Options

express-sweet [options] [dir]

Options:
  -o, --output <output>   Add output module support (esm|cjs) (defaults to cjs)
  -p, --port <port>       Application listening port (default: 3000)
  -f, --force             Force creation on non-empty directory
  -V, --version           Display version number
  -h, --help              Display help for command

Release Notes

Latest Release: v4.0.0 (2025-12-05)

Major update with Express 5 migration and file upload support:

  • Express 5 Migration: Upgraded to Express 5.2.1 with Node.js 18+ requirement
  • File Upload Support: Added Multer configuration (config/upload.js) for flexible file handling
  • Template Updates: Express 5 path pattern syntax for regex validation

For complete version history and migration guides, see CHANGELOG.md.

Author

Takuya Motoshima

License

MIT