New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

express-sweet

Package Overview
Dependencies
Maintainers
1
Versions
54
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

express-sweet

Express framework extension.

  • 1.0.27
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
77
increased by305.26%
Maintainers
1
Weekly downloads
 
Created
Source

Express Sweet Logo

Express framework extension.

Documentation

Quick Start

The easiest way to get started with Express Sweet is to install express-sweet-generator and automatically create a template application.
The following application can be started immediately by executing the template.
See here for instructions on using express-sweet.

login users

user-editing personal

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

    npm install -g express-sweet-generator
    
  2. Create an Express myapp named myapp.
    The app is created in a folder named myapp in the working directory.

    express-sweet myapp
    # If you want to use ESM, below.
    #express-sweet -o esm myapp
    
  3. Install dependent packages.

    cd myapp
    npm install
    
  4. This sample application uses a database. Execute the following SQL to create the database.

    CREATE DATABASE IF NOT EXISTS `sampledb` DEFAULT CHARACTER SET utf8mb4;
    
    USE `sampledb`;
    
    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, 'robin@example.com', 'password', 'Robin', '/upload/1.png'),
      (2, 'taylor@example.com', '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');
    
  5. Build front-end JS.

    cd myapp/client
    npm install
    npm run build
    
  6. Next, you need to set how the database is connected.
    The database connection method can be set in config/database.js, so change it according to your environment.
    See here for details.

    // For ESM, use "export default".
    //export default {
    module.exports = {
      development: {
        username: 'root',
        password: 'password',
        database: 'sampledb',
        host: 'localhost',
        dialect: 'mariadb'
      },
      test: {
        username: 'root',
        password: 'password',
        database: 'sampledb',
        host: 'localhost',
        dialect: 'mariadb'
      },
      production: {
        username: 'root',
        password: 'password',
        database: 'sampledb',
        host: 'localhost',
        dialect: 'mariadb'
      }
    }
    
  7. The DB to be used can be defined individually for each environment. Specify the environment in the .env file.

    NODE_ENV=development
    
  8. Launch the application.

    cd myapp
    npm start
    

Author

Takuya Motoshima

License

MIT

Keywords

FAQs

Package last updated on 12 Jun 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc