0.4.0
Looking to game is a service that helps people form groups to play games.
Looking to game is a full stack JavaScript application (app) with a front end and back end. Both the front and back end are necessary to make the application work. This repository (repo) is the back end.
The front end can be found at the following GitHub location:
https://github.com/Looking-To-Game/ltg-fe
The most stable version of the backend is called production. The production backend has been deployed to Heroku at the following location:
https://ltg-be-production.herokuapp.com
For use with the production API, replace http://localhost:3000 with the address or URL above.
Example:
https://ltg-be-production.herokuapp.com/api/signup
First follow the steps in the installation section below.
Open bash.
Enter one of the following commands:
npm run start
npm run start-debug
npm run debug
These commands can also be found in the scripts section of package.json.
"start": "node server.js",
"start-debug": "DEBUG='ltg*' npm start",
In second bash window run mongo
Mongo Shell Methods
- Enter
show dbs
- Enter
use ltg
- Enter
show collections
- Enter
db.users.find()
- Enter
db.users.drop()
User Schema
const userSchema = Schema({
username: {type: String, required: true, unique: true},
email: {type: String, required: true, unique: true},
password: {type:String, required:true},
findhash: {type: String, unique: true},
steam: {type: String, default:null},
bn: {type: String, default:null},
xbl: {type: String, default:null},
psn: {type: String, default:null},
lol: {type: String, default:null},
});
Group Schema
const groupSchema = Schema({
title: {type: String, required: true},
description: {type: String, required: true},
host: {type: String, required: true},
game: {type: String, required: true},
platform: {type: String, required: true},
skillLevel: {type: String},
dedication: {type: String},
groupSize: {type: Number},
startTime: {type: Date, default: Date.now},
endTime: {type: Date},
});
In a web browser enter the address or URL: http://localhost:3000 Add to the address above with the API routes below. Example: http://localhost:3000/api/signup
Auth Routes
- Use this route to sign-up for a user account.
- Headers required:
Content-Type: application/json
- Post:
- Required: object with username, email, and password.
{ "username":"test1", "email":"[email protected]", "password":"test1" }
- Response:
- Should return a 200 response and token.
- Use this route to sign-in with an existing user account.
- Headers required:
- Authorization: Basic Auth
username: password
Content-Type: application/json
- Authorization: Basic Auth
- Response:
- Should return a 200 response and new token.
User Routes
- Use this route to get information for an existing user account.
- Headers required:
Authorization: Bearer <token>
Content-Type: application/json
- Response:
{ "_id": "594d3d8edeb6ab00111e7ecd", "password": null, "username": "test1", "email": "[email protected]", "__v": null, "findhash": null, "lol": null, "psn": null, "xbl": null, "bn": null, "steam": null }
- Should return a 200 response and object properties.
- Use this route to update existing user account information.
- Headers required:
Authorization: Bearer <token>
Content-Type: application/json
- Put:
{ "_id": "594d3d8edeb6ab00111e7ecd", "password": null, "username": "test2", "email": "[email protected]", "__v": 0, "findhash": null, "lol": null, "psn": null, "xbl": null, "bn": null, "steam": null }
- Response:
- Object with id, username, email, and game accounts.
- Should return a 200 response and object properties.
Group Routes
- Use this route to create a new looking for group post.
- Headers required:
Authorization: Bearer <token>
Content-Type: application/json
- Post:
- Required: title, description, host, game, and platform.
{ "title": "game group", "description": "looking to raid", "host":"player one", "game":"destiny", "platform":"playstation" }
- Response:
- Object with title, description, host, game, platform, id, and start time.
"_id": "594d4b73aa52590dc2f7efa4"
- Should return a 200 response and object properties.
- Object with title, description, host, game, platform, id, and start time.
- Use this route to get an existing group post.
- URL example:
/api/group/594d4b73aa52590dc2f7efa4
- Headers:
Content-Type: application/json
- Response:
- Should return a 200 response and object properties.
{ "_id": "594d4b73aa52590dc2f7efa4", "title": "game group", "description": "looking to raid", "host": "test2", "game": "destiny", "platform": "playstation", "__v": 0, "startTime": "2017-06-23T17:10:11.270Z" }
- Use this route to get all group posts.
- Headers:
Content-Type: application/json
- Response:
- Should return a 200 response and an array of objects.
[ { "_id": "594d4b73aa52590dc2f7efa4", "title": "game group", "description": "looking to raid", "host": "test2", "game": "destiny", "platform": "playstation", "__v": 0, "startTime": "2017-06-23T17:10:11.270Z" }, { "_id": "594d51f5aa52590dc2f7efa5", "title": "game group2", "description": "looking to raid2", "host": "test2", "game": "destiny", "platform": "playstation", "__v": 0, "startTime": "2017-06-23T17:37:57.053Z" } ]
- Use this route to update existing group post.
- URL example:
/api/group/594d4b73aa52590dc2f7efa4/update
- Headers:
Authorization: Bearer <token>
Content-Type: application/json
- Response:
- Should return a 200 response and object properties.
{ "title": "game group3", "description": "looking to raid3", "game": "destiny", "platform": "playstation", "groupSize": "3" }
- Use this route to delete an existing group post.
- URL example:
/api/group/594d51f5aa52590dc2f7efa5/delete
- Headers:
Authorization: Bearer <token>
Content-Type: application/json
- Response:
- Should return only a 204 response.
DELETE /api/group/594d51f5aa52590dc2f7efa5/delete 204
- Use GET /api/feed to see deleted group post.
Please visit the following pages for how to install your project locally.
db install
brew update
brew install mongodb
mongod --dbpath ./db
- NPM Install
npm i
ornpm install
As a result, the following packages are installed:
"dependencies": {
"bcrypt": "^1.0.2",
"bluebird": "^3.5.0",
"body-parser": "^1.17.2",
"cors": "^2.8.3",
"crypto": "0.0.3",
"debug": "^2.6.8",
"dotenv": "^4.0.0",
"express": "^4.15.3",
"http-errors": "^1.6.1",
"jsonwebtoken": "^7.4.1",
"mongoose": "^4.10.7",
"morgan": "^1.8.2",
"superagent": "^3.5.2"
},
"devDependencies": {
"chai": "^4.0.2",
"chai-http": "^3.0.0",
"coveralls": "^2.13.1",
"istanbul": "^0.4.5",
"mocha": "^3.4.2",
"mocha-lcov-reporter": "^1.3.0"
}
In bash enter the command:
npm run test
These commands can also be found in the scripts section of package.json.
"test": "./node_modules/istanbul/lib/cli.js cover ./node_modules/mocha/bin/_mocha",
"cover": "istanbul cover _mocha",
"test-debug": "DEBUG='ltg*' ./node_modules/istanbul/lib/cli.js cover ./node_modules/mocha/bin/_mocha"
This project is licensed under the MIT License.
- Code Fellows
- Scott Schmidt, Instructor
- Cayla Zabel, Teaching Assistant
- Devon Hackley, Teaching Assistant
- Thomas Martinez, Teaching Assistant
- JR Iriarte, Teaching Assistant