Files
tcg-server/matches/matches.routes.js
yaoyanwei 4b2bb35c20 init
2025-08-04 16:25:38 +08:00

34 lines
1.1 KiB
JavaScript

const MatchesController = require('./matches.controller');
const MatchesTool = require('./matches.tool');
const AuthTool = require('../authorization/auth.tool');
const config = require('../config');
const ADMIN = config.permissions.ADMIN; //Highest permision, can read and write all users
const SERVER = config.permissions.SERVER; //Higher permission, can read all users
const USER = config.permissions.USER; //Lowest permision, can only do things on same user
exports.route = function (app) {
app.post('/matches/add', app.post_limiter, [
AuthTool.isValidJWT,
AuthTool.isPermissionLevel(SERVER),
MatchesController.addMatch
]);
app.post('/matches/complete', app.post_limiter, [
AuthTool.isValidJWT,
AuthTool.isPermissionLevel(SERVER),
MatchesController.completeMatch
]);
//-- Getter
app.get('/matches', [
AuthTool.isValidJWT,
AuthTool.isPermissionLevel(SERVER),
MatchesController.getAll
]);
app.get('/matches/:tid', [
AuthTool.isValidJWT,
AuthTool.isPermissionLevel(USER),
MatchesController.getByTid
]);
};