Skip to content

Codaisseur/cool-story-bro-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Server template

This is a simple server template to for my students to start projects quickly.

Table of contents:

SETUP How to use this template

  1. Create a new project based on this template using the Use this template button

HOW_TO_USE

  1. Clone the app
git clone git@github.com:YOUR_GITHUB_NAME/YOUR_PROJECT_NAME.git
  1. cd into your project
cd YOUR_PROJECT_NAME
  1. install dependencies
npm install
  1. Configure your database in config/config.json

The default assumes a postgres database with

  • username: postgres
  • password: secret
// config/config.json
{
  "development": {
    "username": "postgres",
    "password": "secret",
    "database": "YOUR_PROJECT_NAME_HERE_development",
    "host": "localhost",
    "dialect": "postgres",
    "operatorsAliases": "0"
  }
}
  1. Create database, run migrations & seed data

package.json contains a script for this

npm run initdev

Or run the commands seperately

npx sequelize-cli db:create
npx sequelize-cli db:migrate
npx sequelize-cli db:seed:all
  1. start server with nodemon (recommended for development)
npm run dev
  1. or start normally
npm start

Endpoints

Method Path Purpose required parameters auth
GET '/' Test if your server is running none no
POST '/echo' Test POST requests none no
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
POST '/authorized_post_request' Test POST requests (token required) none yes

Sample requests with axios

To demo making request to this server, some small script are included that make requests using axios

The scripts can be found in /sampleRequests

  1. Make sure to follow the the setup in this readme first
  2. cd sampleRequests
  3. Run example requests
node hello.js
node echo.js
node signup.js
node login.js
node me.js
node authorizedPost.js

Sample requests with httpie

To demo making request to this server, bash commands are included that make requests using httpie

They can found in ./sampleRequests/httpie.md

History of this project

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •