Backend for Spwned, CS498RK Final Project
Install Dependencies
npm install
Run Server
nodemon server.js
POST /api/register
Input
Name | Type | Description | Example |
---|---|---|---|
first_name | string | Required | Alex |
last_name | string | Required | Duh |
string | Required | ripped@math.com | |
password | string | Required | luigi1234 |
Response
{
"message": "register OK",
"data": {
"__v": 0,
"first_name": "Alex",
"last_name": "Duh",
"email": "ripped@math.com",
"password": "$2a$10$.ykPNx3Gq/rcAAuQtjHmIu8roUIS03vjgExKeK4HWSakUJOxlp0LS",
"_id": "55487085a0608480245f0693",
"dateCreated": "2015-05-05T07:25:57.186Z"
}
}
POST /api/signin
Input
Name | Type | Description | Example |
---|---|---|---|
string | Required | ripped@math.com | |
password | string | Required | luigi1234 |
Response
{
"message": "signin OK",
"data": {
"_id": "55487085a0608480245f0693",
"first_name": "Alex",
"last_name": "Duh",
"email": "ripped@math.com",
"password": "$2a$10$.ykPNx3Gq/rcAAuQtjHmIu8roUIS03vjgExKeK4HWSakUJOxlp0LS",
"__v": 1,
"games": [
"554ab75a9dfab5b206f15cdd"
],
"dateCreated": "2015-05-05T07:25:57.186Z"
}
}
GET /api/game
Supported Parameters
Name | Description | Example |
---|---|---|
where | Game ID | where={"_id":"554ab58e9dfab5b206f15cdc"} |
count | True/False | count=true |
Response
{
"message": "game list OK",
"data": [
{
"_id": "554ea771748f8ea47c0eac7e",
"start_date": "1970-01-01T00:00:01.234Z",
"end_date": "1970-01-01T00:00:01.234Z",
"capacity": 15,
"title": "Brawl Related Spwned",
"description": "Kill your enemies with GCN Controllers",
"__v": 13,
"admin_id": "554ea771748f8ea47c0eac7f",
"isFinished": false,
"hasStarted": true,
"winners": [],
"dateCreated": "2015-05-10T00:33:53.503Z",
"players": [
"554ede92257f221f2e9892c4",
"554eb3c2c737d5ce161feee6",
"554ee14756319e64341e1200"
]
}
]
}
POST /api/game
Input
Name | Type | Description | Example |
---|---|---|---|
title | string | Required | Brawl Related Spwned |
description | string | Required | Kill your enemies with GCN Controllers |
user_id | string | Required | 55487085a0608480245f0693 |
capacity | number | Required | 15 |
Response
{
"message": "game creation OK",
"data": {
"admin_id": "554fc9a0e94dafc55c7bf866",
"__v": 0,
"capacity": 2,
"title": "Annie's big Day",
"description": "Tag each other with pillows!",
"_id": "554fc9a0e94dafc55c7bf865",
"isFinished": false,
"hasStarted": false,
"winners": [],
"dateCreated": "2015-05-10T21:12:00.198Z",
"players": []
}
}
GET /api/game/:id
Supported Parameters
Name | Description | Example |
---|---|---|
user_id | Required | 55487085a0608480245f0693 |
Response
{
"message": "game select admin OK",
"data": {
"_id": "554ea771748f8ea47c0eac7e",
"start_date": "1970-01-01T00:00:01.234Z",
"end_date": "1970-01-01T00:00:01.234Z",
"capacity": 15,
"title": "Brawl Related Spwned",
"description": "Kill your enemies with GCN Controllers",
"__v": 1,
"admin_id": "554ea771748f8ea47c0eac7f",
"isFinished": false,
"hasStarted": false,
"winners": [],
"dateCreated": "2015-05-10T00:33:53.503Z",
"players": [
"554eb3c2c737d5ce161feee6"
],
"admin_token": "554ea771748f8ea47c0eac7f",
"player_token": null
}
}
PUT /api/game/:id/join
Input
Name | Type | Description | Example |
---|---|---|---|
user_id | string | Required | 55487085a0608480245f0693 |
Response
{
"message": "game join OK",
"data": {
"user_id": "55487085a0608480245f0693",
"player_id": "554c3d9980f70334099d27b9",
"game_id": "554ab75a9dfab5b206f15cdd"
}
}
GET /api/:game_id/players
Supported Parameters
Name | Description | Example |
---|---|---|
where | User ID + Game ID | where={"user_id":"554ab15cdc","game_id":"55415cdd"} |
count | True/False | count=true |
Response
{
"message": "player list OK",
"data": [
{
"_id": "554eb3c2c737d5ce161feee6",
"user_id": "554eb3a3c737d5ce161feee5",
"game_id": "554ea771748f8ea47c0eac7e",
"__v": 3,
"dateCreated": "2015-05-10T01:26:26.465Z",
"secret_code": "EIEG",
"isAlive": true,
"killed": [
"554eeb27053466ef47061c14",
"554eebd172aa85ef480c4d66",
"554eec1672aa85ef480c4d67"
],
"killer_id": null,
"target_id": "554eb3c2c737d5ce161feee6"
}
]
}
GET /api/player/:id
Supported Parameters
Name | Description | Example |
---|---|---|
none | none | none |
Response
{
"message": "player ID OK",
"data": {
"_id": "554d1e383bad7b454a9a7259",
"user_id": "55487085a0608480245f0693",
"game_id": "554d1e0d3bad7b454a9a7258",
"__v": 4,
"dateCreated": "2015-05-08T20:36:08.361Z",
"secret_code": "HI8H",
"isAlive": true,
"killed": [
"554d20f7da2240bf507c6dc9",
"554d212fda2240bf507c6dca",
"554d21e0e9c013ba522df532",
"554d21e7e9c013ba522df533"
],
"killer_id": null,
"target_id": "554d1e433bad7b454a9a725a"
}
}
PUT /api/player/report
Input
Name | Description | Example |
---|---|---|
player_id | required | 55487085a0608480245f0693 |
game_id | required | 554d1e0d3bad7b454a9a7258 |
secret_code | string | GYPB |
Response
{
"message": "player Report OK",
"data": {
"killer_id": "554d1e383bad7b454a9a7259",
"target_id": "554d1e433bad7b454a9a725a",
"game_id": "554d1e0d3bad7b454a9a7258",
"_id": "554d21e7e9c013ba522df533",
"dateCreated": "2015-05-08T20:51:51.759Z",
"timeOfKill": "2015-05-08T20:51:51.759Z"
}
}
PUT api/admin/start
Input
Name | Type | Description | Example |
---|---|---|---|
admin_id | _id | Required | 55487085a0608480245f0693 |
game_id | _id | Required | 554d1908d3317a9b11a1a34c |
Response
{
"message": "game start OK",
"data": {
"game_id": "554ea771748f8ea47c0eac7e"
}
}
DELETE api/admin/delete_game
Input
Name | Type | Description | Example |
---|---|---|---|
admin_id | _id | Required | 55487085a0608480245f0693 |
game_id | _id | Required | 554d1908d3317a9b11a1a34c |
Response
{
"message": "Game deleted",
"data": "1"
}
DELETE api/admin/remove_player
Input
Name | Type | Description | Example |
---|---|---|---|
admin_id | _id | Required | 55487085a0608480245f0693 |
player_id | _id | Required | 554d2b488277a3ca39b354be |
game_id | _id | Required | 554d1908d3317a9b11a1a34c |
Response
{
"message": "Player removed",
"data": "1"
}
GET /api/message/g/:gid/u/:uid
Supported Parameters
Name | Type | Description | Example |
---|---|---|---|
none | none | none | none |
Response
{
"message": "message OK",
"data": {
"_id": "555019ae9b2c31c327e5be2c",
"game_id": "5550138153282a901810853f",
"sender_id": "5550138153282a9018108540",
"body": "msg test",
"__v": 0,
"dateCreated": "2015-05-11T02:53:34.186Z",
"recipient_id": "554febc837f76f7a2abdc681"
}
}
POST /api/message/g/:gid/u/:uid
Supported Parameters
Name | Type | Description | Example |
---|---|---|---|
recipient_id | User ID | Required | 55487085a0608480245f0693 |
body | String | Required | "hello world" |
Response
{
"message": "message OK",
"data": {
"__v": 0,
"game_id": "5550138153282a901810853f",
"sender_id": "5550138153282a9018108540",
"body": "msg test",
"_id": "555020625e1f806333b1663c",
"dateCreated": "2015-05-11T03:22:10.821Z",
"recipient_id": "554ede7a257f221f2e9892c3"
}
}
GET /api/message/g/:gid/m/:mid
Supported Parameters
Name | Type | Description | Example |
---|---|---|---|
none | none | none | none |
Response
{
"message": "message OK",
"data": {
"_id": "555020625e1f806333b1663c",
"game_id": "5550138153282a901810853f",
"sender_id": "5550138153282a9018108540",
"body": "wrong ",
"__v": 0,
"dateCreated": "2015-05-11T03:22:10.821Z",
"recipient_id": "554ede7a257f221f2e9892c3"
}
}
POST /api/announcement/g/:gid
Supported Parameters
Name | Type | Description | Example |
---|---|---|---|
admin_id | User ID | Required | 5550138153282a9018108540 |
body | String | Required | "hello world" |
Response
{
"message": "announcement OK",
"data": {
"__v": 0,
"game_id": "5550138153282a901810853f",
"sender_id": "5550138153282a9018108540",
"body": "announcement",
"_id": "555021db5e1f806333b1663d",
"dateCreated": "2015-05-11T03:28:27.998Z",
"recipient_id": null
}
}
GET /api/announcement/g/:gid
Supported Parameters
Name | Type | Description | Example |
---|---|---|---|
none | none | none | none |
Response
{
"message": "announcement OK",
"data": [
{
"_id": "555021db5e1f806333b1663d",
"game_id": "5550138153282a901810853f",
"sender_id": "5550138153282a9018108540",
"body": "wrong ",
"__v": 0,
"dateCreated": "2015-05-11T03:28:27.998Z",
"recipient_id": "554ede7a257f221f2e9892c3"
}
]
}
GET /api/kills
Supported Parameters
Name | Type | Description | Example |
---|---|---|---|
game_id | string | Filter by game ID | 554ab75a9dfab5b206f15cdd |
Response
{
"message": "kill list OK",
"data": [
{
"_id": "554eeb27053466ef47061c14",
"killer_id": "554eb3c2c737d5ce161feee6",
"target_id": "554ee14756319e64341e1200",
"game_id": "554ea771748f8ea47c0eac7e",
"__v": 0,
"dateCreated": "2015-05-10T05:22:47.598Z",
"timeOfKill": "2015-05-10T05:22:47.598Z"
}
]
}
GET /api/kill/:id
Supported Parameters
Name | Type | Description | Example |
---|---|---|---|
none | none | none | none |
Response
{
"message": "kill ID OK",
"data": {
"_id": "55500cf3587404156996fe28",
"killer_id": "5550288e5d6105132308b044",
"target_id": "55500c14587404156996fe26",
"game_id": "554fc0476e3656d856f1805b",
"__v": 0,
"dateCreated": "2015-05-11T01:59:15.885Z",
"timeOfKill": "2015-05-11T01:59:15.885Z"
}
}
GET /api/user
Supported Parameters
Name | Type | Description | Example |
---|---|---|---|
none | none | none | none |
Response
{
"message": "kill list OK",
"data": [
{
"_id": "554ede7a257f221f2e9892c3",
"first_name": "Annie",
"last_name": "Wu",
"email": "anniewu@gt.com",
"password": "$2a$10$ebJar7CLndpY5Y91tmih/uedMeeNhA5AdIMcqSVyKyoqhIk5PVt7.",
"__v": 12,
"games": [
"554fc9a0e94dafc55c7bf865"
],
"dateCreated": "2015-05-10T04:28:42.872Z"
}
]
}
GET /api/user/:id
Supported Parameters
Name | Type | Description | Example |
---|---|---|---|
none | none | none | none |
Response
{
"message": "user ID OK",
"data": {
"_id": "554ede7a257f221f2e9892c3",
"first_name": "Annie",
"last_name": "Wu",
"email": "anniewu@gt.com",
"password": "$2a$10$ebJar7CLndpY5Y91tmih/uedMeeNhA5AdIMcqSVyKyoqhIk5PVt7.",
"__v": 12,
"games": [
"554fc9a0e94dafc55c7bf865"
],
"dateCreated": "2015-05-10T04:28:42.872Z"
}
}