Link to Live App: https://virtual-fight-club.juliawithers.vercel.app
Link to Client Repo: https://github.com/juliawithers/virtual-fight-club
The database is hosted on the heroku database addon. There are three tables:
USERS
id | auth | username | passw | date_created |
---|---|---|---|---|
user id primary key | auth uuid - not null | some username - not null | hashed password - not null | creation date - not null |
CHARACTERS
id | auth | username | user_id | char_name | strength | intelligence | charisma | agility | current_level | current_points | wins | losses | attrpoints |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
character id primary key | some auth - not null | some username - not null | user id - not null | character name - not null | decimal | decimal | decimal | decimal | decimal | decimal | decimal | decimal | decimal |
MATCHES
id | char_1_id | char_2_id | winner | loser | points |
---|---|---|---|---|---|
match id primary key | user id - not null | opponent id - not null | winner - not null | loser - not null | 2 points - not null |
Please see the endpoints and schemas below:
`https://virtual-fight-club.herokuapp.com/api/vfc`
/login
/users
/characters
/matches
/characters/:id
POST:
request body:
{
"username": username,
"password": passw
}
returns:
{
"login": true,
"user": [
{
"id": 3,
"auth": "b07162f0-ffaf-11e8-8eb2-f2801f1b9fd1",
"username": "lydiaMartin",
}
]
}
GET:
query params:
`/users/?login=${login status}&userId=${user_id}`
returns:
{
"users": [{
"auth": user auth,
"username": "",
"passw": "",
},... ]
}
POST:
body:
{
"auth": user auth,
"username": "",
"passw": "",
}
returns:
{
"id": user.id,
"auth": auth,
"username": username
}
DELETE:
body:
{
"id": user.id
}
returns:
{
"user_id": user.id
}
GET:
returns:
{
"characters": [{
"id": character id,
"auth": "",
"username": "",
"user_id": ,
"char_name": "",
"strength": ,
"intelligence": ,
"charisma": ,
"agility": ,
"current_level": ,
"current_points": ,
"wins": ,
"losses": ,
"attrpoints":
}, ...]
}
POST / PATCH:
body:
{
"auth": "",
"username": "",
"user_id": ,
"char_name": "",
"strength": ,
"intelligence": ,
"charisma": ,
"agility": ,
"current_level": ,
"current_points": ,
"wins": ,
"losses": ,
"attrpoints":
}
returns:
{
"character": {
"id": character id
"auth": "",
"username": "",
"user_id": ,
"char_name": "",
"strength": ,
"intelligence": ,
"charisma": ,
"agility": ,
"current_level": ,
"current_points": ,
"wins": ,
"losses": ,
"attrpoints":
}
}
TEST CHARACTER OBJECT:
{
"auth": "0810bd3e-6112-4c27-a63f-c533e885495c",
"username": "testcharacter",
"user_id": 3,
"char_name": "testy",
"strength": 5,
"intelligence": 2,
"charisma": 2,
"agility": 1,
"current_level": 0,
"current_points": 0,
"wins": 1,
"losses": 0,
"attrpoints": 0
}
DELETE:
body:
{
"id": character id
}
returns: success status or error
GET:
returns:
{
"matches":[{
"char_1_id": current user id,
"char_2_id": opponent id,
"winner": ,
"loser": ,
"points":
},...]
}
POST:
body:
{
"char_1_id": current user id,
"char_2_id": opponent id,
"winner": ,
"loser": ,
"points":
}
returns:
{
"match": {
"id": match id
"char_1_id": current user id,
"char_2_id": opponent id,
"winner": ,
"loser": ,
"points":
}
}
GET:
query params: /characters/${user_id}
`/characters/${user_id}`
returns:
{
"character": {
"id": character id
"auth": "",
"username": "",
"user_id": ,
"char_name": "",
"strength": ,
"intelligence": ,
"charisma": ,
"agility": ,
"current_level": ,
"current_points": ,
"wins": ,
"losses": ,
"attrpoints":
}
}
- Clone this repository to your local machine
git clone BOILERPLATE-URL NEW-PROJECTS-NAME
cd
into the cloned repository- Make a fresh start of the git history for this project with
rm -rf .git && git init
- Install the node dependencies
npm install
- Move the example Environment file to
.env
that will be ignored by git and read by the express servermv example.env .env
- Edit the contents of the
package.json
to use NEW-PROJECT-NAME instead of"name": "express-boilerplate",
- To create tables: psql -U postgres -d vfc -f ./migrations/001.create_tables.sql
- To seed tables: psql -U postgres -d vfc -f ./seeds/seed.vfc.sql
- Migrations: npm run migrate (version) OR npm run migrate:test(version)
Test mocha --require test/setup.js --watch
Start the application npm start
Start nodemon for the application npm run dev
Run the tests npm test
migrate postgrator --config postgrator-config.js
migrate:test env NODE_ENV=test npm run migrate
When your new project is ready for deployment, add a new Heroku application with heroku create
. This will make a new git remote called "heroku" and you can then npm run deploy
which will push to this remote's master branch.