Here's the backend which serves our Go Fish Game Application! The backend manages endpoints that use CRUD methods. You can learn more about the Front End code here
-- /api/users -- /api/auth
POST
request made to/api/auth/login
- The body of the request consists of:
{
email: '',
password: ''
}
(e.g. registering, playing the game)
POST
request made to/api/users
- The body of the request consists of:
{
"playerName": " ", // requires a unique username, so other users cannot already have that username
"email": " ", // requires @email.com formatting
"password": " " // requires 1 uppercase, 1 lowercase, 1 special character and a number
}
socket.on('connection', () => {})
establishes a server connection, in which event listeners can be tied- At the start of the game users join the server:
{
socket.on('joinServer', (userObj) => {
// define socket identity info before join
socket.nickname = userObj.playerName;
socket.roomNumber = userObj.room;
socket.player_id = userObj.user_id;
// NOTE: socket.id is auto generated
if (ServerRooms.activeRooms[socket.roomNumber]) {
if (ServerRooms.activeRooms[socket.roomNumber].started === true) {
return socket.emit('server join denial');
}
}
}
socket.emit('example', {userInfo})
sends an 'example' event with the object containing userInfo.- For example, when a player asks another player for a card:
{
io.to(socket.roomNumber).emit('messageResponse', {
user: 'Server Message',
value: `${asker.name} is asking ${requested.requestedName} for a ${rankReq}.`,
});
}
We use Socket.io to send a 'messageResponse' event with an object containing data about user actions in the game. io.to(some-room-id).emit('example') sends a message to all users in that room, configured in Socket.io
- Node and Express
- Authentication using JWT
- RESTful Api
- Socket.io
- Supertest (integration)
- Mocha and Chai (unit)
- Postgres
- Knex.js - SQL wrapper
- Deployed via Heroku
Complete the following steps to start a new project (NEW-PROJECT-NAME):
- Clone this repository to your local machine
git clone capstone-three-server-team-b
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
- Create an
.env
that will be ignored by git and read by the express servertouch .env
- Edit the contents of the
package.json
to use NEW-PROJECT-NAME instead of"name": "go-fish-server",
Follow the setup instructions to get Go Fish Client
up and running.
Start the application npm start
Start nodemon for the application npm run dev
Run the tests npm test
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.
- Returning users can view and edit their profile
- All users can view the leaderboard
-Caleb Jackson -Harry Winkler -Jason Stankevich -Malik DeJean -Michael Sliger
To Thinkful's Engineering Immersion Course TAs, instructors and mentors!