This is boilerplate code to use for projects. Node/express app with basic local user authentication. Exists for use in project so I don't have to start from scratch
- Sequelize user model / migration
- Settings for PostgreSQL
- Passport and passport-local for authentication
- Sessions to keep user logged in between pages
- Flash messages for errors and successes
- Passwords that are hashed with BCrypt
- EJS Templating and EJS Layouts
Column Name | Data Type | Notes |
---|---|---|
id | Integer | Serial Primary Key |
createdAt | Date | Auto-generated |
updatedAt | Date | Auto-generated |
firstname | String | Required |
lastname | String | - |
username | String | - |
String | Must be unique / used for login | |
password | String | Stored as a hash |
photoURL | String | Profile Picture |
admin | Boolean | Defaults to false |
bio | Text | - |
birthday | Date | - |
Method | Path | Location | Purpose |
---|---|---|---|
GET | / | index.js | homepage |
GET | * | index.js | Render error page |
GET | /auth/login | auth.js | Login form |
GET | /auth/signup | auth.js | Signup form |
POST | /auth/login | auth.js | Login user |
POST | /auth/signup | auth.js | Creates user |
GET | /auth/logout | auth.js | Removes session info |
GET | /profile | profile.js | Regular user profile |
GET | /profile/admin | profile.js | Admin profile |
git clone <repo_link> <new_name>
npm install
(or npm i
)
Remove/update defaults. Ex:
- Title in
layout.ejs
- Logo in navbar
- Description of repo link in
package.json
- New README for project
- Footer
createdb <new_db_name>
- Change database name
- Other settings likely already correct (check username, password, dialect)
i.e. update database fields based on what the project requires or does not require
sequelize db:migrate
- SESSION_SECRET: any string (can be random - usually a hash in production)
Note: if using OAuth - switch to directions on
with-oauth
branch
nodemon
or
node index.js
- delete old remote to origin (
git remote remove origin
) - add new repo link as remote (
git remote add origin <new_link>
) - add, commit, push
Note: don't make commits from the new project to your auth boilerplate. Keep it PRISTINE for other future projects.