-
Notifications
You must be signed in to change notification settings - Fork 0
/
routes.mjs
35 lines (33 loc) · 1.29 KB
/
routes.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// import your controllers here
import { resolve } from 'path';
import db from './db/models/index.mjs';
import InitUserController from './controllers/userController.mjs';
import InitScoreController from './controllers/scoreController.mjs';
export default function bindRoutes(app) {
const scoreController = new InitScoreController(db);
const userController = new InitUserController(db);
// main route
app.get('/', (req, res) => {
res.sendFile(resolve('dist', 'index.html'));
});
// USER CONTROLLERS/ROUTES
// Check for existing login
app.get('/checkLogin', userController.checkLogin);
// Login user
app.post('/login', userController.login);
// Signup user
app.post('/signup', userController.signUp);
// Logout user
app.get('/logout', userController.logout);
// Get user's settings
app.get('/getSettings', userController.getSettings);
// Save settings
app.post('/updateSettings', userController.updateSettings);
// Get and update user's highscore
app.post('/getScore', userController.updateUserScore);
// SCORE CONTROLLERS/ROUTES
// Get score from the community score board
app.get('/highScore', scoreController.getHighscores);
// Post score into the community board
app.post('/postHighscore', scoreController.insertHighscore);
}