/factory

Primary LanguageJavaScriptThe UnlicenseUnlicense

nodejs-mysql-starter-kit

A starter kit for setting up a Node.js/Express project with a MySQL database.

There aren't that many resources out there for using a SQL database with Node.js, so this is a starter kit with boilerplate for setting up a quick Node.js project with user sign up and authentication. You can interact with the database with raw SQL. If you want to add an object-relational mapping (ORM) package like Sequelize or Bookshelf, you can drop it in models/db.js and models/user.js.

Prerequisites

Quick setup

  1. npm install to install the necessary packages.
  2. Update config/database.js with your MySQL database information and uncomment the line in the .gitignore to ignore the updated config file.
  3. Update some project-specific info in a few places:
  1. node scripts/dbsetup.js to set up your database, if it doesn't already exist.
  2. npm start to start up your app! Go to http://localhost:3000 to see it.

User authentication

This starter kit comes with local user authentication. The user authentication is roughly based off of this tutorial. There is a User class in models/user.js and new users are furnished with a UUID instead of the default MySQL ascending object ids.