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 🙏

© 2024 – Pkg Stats / Ryan Hefner

express-sweet-generator

v2.0.8

Published

EXPRESS SWEET application generator.

Downloads

517

Readme

EXPRESS SWEET

EXPRESS SWEET's application generator.

A comprehensive list of changes in each version may be found in the CHANGELOG.

Installation

npm install -g express-sweet-generator

Quick Start

Use the application generator tool, express-sweet-generator, to quickly create an application skeleton.

Image

  1. For example, the following creates an Express app named myapp. The app will be created in a folder named myapp in the current working directory.
    express-sweet -o esm myapp
  2. Then install dependencies.
    cd myapp/
    npm install
  3. The skeleton uses a DB. Please create a DB with the following SQL.
    CREATE DATABASE IF NOT EXISTS `sample_db` DEFAULT CHARACTER SET utf8mb4;
    
    USE `sample_db`;
    
    CREATE TABLE `user` (
        `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
        `name` varchar(30) NOT NULL,
        `email` varchar(255) NOT NULL,
        `password` varchar(100) NOT NULL,
        `icon` varchar(768) NOT NULL DEFAULT MD5(RAND()),
        `created` datetime NOT NULL DEFAULT current_timestamp(),
        `modified` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
        PRIMARY KEY (`id`),
        UNIQUE KEY `ukUserEmail` (`email`),
        UNIQUE KEY `ukUserIcon`(`icon`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
    
    CREATE TABLE `profile` (
        `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
        `userId` int(10) unsigned NOT NULL,
        `address` varchar(255) NOT NULL,
        `tel` varchar(14) NOT NULL,
        `created` datetime NOT NULL DEFAULT current_timestamp(),
        `modified` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
        PRIMARY KEY (`id`),
        UNIQUE KEY `ukProfileUserId` (`userId`),
        CONSTRAINT `fkProfileUser` FOREIGN KEY (`userId`) REFERENCES `user` (`id`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
    
    CREATE TABLE `comment` (
        `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
        `userId` int(10) unsigned NOT NULL,
        `text` text NOT NULL,
        `created` datetime NOT NULL DEFAULT current_timestamp(),
        `modified` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
        PRIMARY KEY (`id`),
        CONSTRAINT `fkCommentUser` FOREIGN KEY (`userId`) REFERENCES `user` (`id`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
    
    CREATE TABLE `book` (
        `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
        `userId` int(10) unsigned NOT NULL,
        `title` text NOT NULL,
        `created` datetime NOT NULL DEFAULT current_timestamp(),
        `modified` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
        PRIMARY KEY (`id`),
        UNIQUE KEY `ukBookTitle` (`userId`, `title`(255)),
        CONSTRAINT `fkBookUser` FOREIGN KEY (`userId`) REFERENCES `user` (`id`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
    
    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. Set the DB connection method in config/database.js. For details, please refer to here.
    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'
        }
    }
  5. The DB to be accessed can be defined for each environment. Specify the environment in the .env file
    NODE_ENV=development
  6. Run the application with the following command.
    npm start
  7. Then, load http://localhost:3000/ in your browser to access the app.
    The generated app has the following directory structure:
    .
    ├── .env
    ├── app.js
    ├── ecosystem.config.js
    ├── nginx.sample.conf
    ├── package.json
    ├── bin
    │   └── www
    ├── client
    │   ├── package.json
    │   ├── webpack.config.js
    │   └── src
    ├── config
    │   ├── authentication.js
    │   ├── config.js
    │   ├── database.js
    │   └── view.js
    ├── errors
    │   └── NotFoundError.js
    ├── middlewares
    │   └── checkValidationResult.js
    ├── models
    │   ├── BookModel.js
    │   ├── CommentModel.js
    │   ├── ProfileModel.js
    │   └── UserModel.js
    ├── public
    │   ├── build
    │   └── upload
    ├── routes
    │   ├── login.js
    │   ├── users.js
    │   └── api
    │       └── users.js
    ├── shared
    │   └── isEmpty.js
    ├── validators
    │   └── isValidImageDataUrl.js
    └── views
        ├── edit-personal.hbs
        ├── error.hbs
        ├── login.hbs
        ├── personal.hbs
        ├── users.hbs
        ├── layout
        │   └── default.hbs
        └── partials
        │   └── .gitkeep
        └── errors
            ├── 404.hbs
            └── 500.hbs

Author

Takuya Motoshima

License

MIT