You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
index.js -- Initializes mongoose and starts the server.
src/app.js -- Uses express to set server configuration and expose routes.
src/models/users.js -- Defines the database schema and holds methods for users
src/router/router.js -- Defines the routes available on the server and applies authorization middleware where needed.
src/authorization/authorization.js -- Checks Basic and Bearer auth and validates user tokens.
src/middleware/error_handler.js -- Controls behaviour on server errors.
src/middleware/404.js -- Controls behaviour on non-existant routes.
Setup
.env Requirements
SECRET -- token generation
MONGODB_URI -- database location
TOKEN_EXPIRATION_TIME -- token lifetime
PORT -- port to use (when running locally)
Running the App
POST /signup -- Add a user to the database. If the user's role is a superuser, they will be provided a key, otherwise the user will receive a token. Requires: username, password, email
Optional: role
POST /signin -- Passes through auth middleware to verify username and password, and provides a new token if successful.
Requires: username, password
GET /leaderboard
PUT /socket -- Used for the socket server/client to send updates after a game to be saved to the database.
Requires: stats: {wins}