minor cleanup
This commit is contained in:
@@ -5,7 +5,7 @@ export const activeGames: Array<Game> = [];
|
||||
|
||||
// todo: join user and game relationship
|
||||
|
||||
const create = async (game: Game) => {
|
||||
export const create = async (game: Game) => {
|
||||
try {
|
||||
const res = await db.query(
|
||||
`INSERT INTO "game"(pgn, white_id, black_id, winner) VALUES($1, $2, $3, $4) RETURNING *`,
|
||||
@@ -24,7 +24,7 @@ const create = async (game: Game) => {
|
||||
}
|
||||
};
|
||||
|
||||
const find = async (where?: string, limit = 1) => {
|
||||
export const find = async (where?: string, limit = 1) => {
|
||||
const query = where
|
||||
? `SELECT * FROM "game"`
|
||||
: {
|
||||
@@ -49,7 +49,7 @@ const find = async (where?: string, limit = 1) => {
|
||||
}
|
||||
};
|
||||
|
||||
const update = async (id: number, data: string) => {
|
||||
export const update = async (id: number, data: string) => {
|
||||
try {
|
||||
const res = await db.query(`UPDATE "game" SET $1 WHERE id = $2 RETURNING *`, [data, id]);
|
||||
return {
|
||||
@@ -65,7 +65,7 @@ const update = async (id: number, data: string) => {
|
||||
}
|
||||
};
|
||||
|
||||
const remove = async (id: number) => {
|
||||
export const remove = async (id: number) => {
|
||||
try {
|
||||
const res = await db.query(`DELETE FROM "game" WHERE id = $1 RETURNING *`, [id]);
|
||||
return {
|
||||
@@ -80,10 +80,3 @@ const remove = async (id: number) => {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
export const GameModel = {
|
||||
create,
|
||||
find,
|
||||
update,
|
||||
remove
|
||||
};
|
||||
|
||||
@@ -12,7 +12,7 @@ import {
|
||||
const socketConnect = (socket: Socket) => {
|
||||
const req = socket.request;
|
||||
|
||||
// re-analyze if this is necessary, or if io.use will handle logout
|
||||
// review if this is necessary, or if io.use will handle logout
|
||||
socket.use((__, next) => {
|
||||
req.session.reload((err) => {
|
||||
if (err) {
|
||||
|
||||
Reference in New Issue
Block a user