siggame / coliselia

Common components & services between ophelia and colisee; note: repo name subject to change
3 stars 1 forks source link

DbApi - Game API Router #7

Open russleyshaw opened 7 years ago

russleyshaw commented 7 years ago

file: /dbapi/src/routers/api/game.ts

The express router needs to be developed for the gamelog router api

NOTE: Schemas must also be developed at /dbapi/src/schemas/game.ts. A schema should be created for each use of params, query, or body in the express router

import { Validator } from 'jsonschema';
import { team as schemas } from '../../schemas';

let v: Validator = new Validator();

let result = v.validate(thing, schemas.getTeamParams);
if(result.errors.length > 0) {
    return foo('did bad');
}

NOTE: Make sure to add the exported router to /dbapi/src/routers/api/index.ts. Then, if the dbapi/src/routers folder is imported as routers, it can be retrieved as routers.api.game

NOTE: Currently, the gamelog itself is stored in the game table. Endpoints should not return (or even SELECT at the SQL level) for the gamelog column as it will only slow things down. Add seperate endpoints for adding and getting gamelogs

Endpoints