This is a simple server template to for my students to start projects quickly.
- Create a new project based on this template using the
Use this templatebutton
- Clone the app
git clone [email protected]:YOUR_GITHUB_NAME/YOUR_PROJECT_NAME.git
- cd into your project
cd YOUR_PROJECT_NAME
- install dependencies
npm install
- Configure your database in
config/config.json
Default config is setup for usage with an ElephantSQL database instance, you need to provide the DB Url on the "url" key of the config.json file, key development.
// config/config.json
{
"development": {
"url": "YOUR_ELEPHANTSQL_URL_HERE",
"dialect": "postgres"
},
}- Create database, run migrations & seed data
package.json contains a script for this
npm run initdevOr run the commands seperately
npx sequelize-cli db:migrate
npx sequelize-cli db:seed:all- start server with
nodemon(recommended for development)
npm run dev
- or start normally
npm start
| Method | Path | Purpose | required parameters | auth |
|---|---|---|---|---|
| POST | '/signup' | Create a new user and get a token | email, name, password | no |
| POST | '/login' | Get a token with email & password | email, password | no |
| GET | '/me' | Get information of this user | none | yes |
To demo making request to this server, bash commands are included that make requests using httpie
| Method | Path | Command |
|---|---|---|
| POST | '/signup' | http :4000/sign |
| POST | '/login' | http :4000/login |
| GET | '/me' | http :4000/me |
