patch no-query bug in rooms/ endpoint

This commit is contained in:
Sorrel Bri 2020-01-23 16:04:40 -08:00 committed by sorrelbri
parent 523bec7446
commit 6aecd7d48e
5 changed files with 13 additions and 3 deletions

View file

@ -5,6 +5,8 @@ const {enableRoomSocket} = require('../../socket');
const getAll = async (req, res, next) => {
try {
const publicRooms = await roomQueries.findPublicRooms();
res.status(200).json({rooms: [...publicRooms]})
}
@ -17,7 +19,6 @@ const show = async (req, res, next) => {
try {
const roomId = req.params.id;
// TODO eventually add check for user's private rooms
const publicRooms = await roomQueries.findPublicRooms();
enableRoomSocket(roomId);
const currentRoom = await roomQueries.findRoomById(roomId);

View file

@ -18,6 +18,7 @@ exports.up = function(knex) {
table.float('komi').default(6.5);
table.integer('handicap').default(0);
table.integer('board_size').default(19);
table.boolean('open').default(true);
table.string('application');
table.string('application_version');

View file

@ -10,7 +10,14 @@ exports.seed = function(knex) {
application: 'node-go', application_version: '0.1.0',
player_black: 'anon', player_white: 'anon',
player_black_rank: 'K3', player_white_rank: 'K2',
room: 1, time_setting: 1
room: 1, time_setting: 1, open: false
},
{
id: 2, date: new Date(),
application: 'node-go', application_version: '0.1.0',
player_black: 'user-one', player_black_rank: 'UR',
user_black: 2,
room: 1, time_setting: 1, open: true
}
]);
});

View file

@ -9,7 +9,8 @@
"migrate": "./node_modules/.bin/knex migrate:latest",
"migrate-test": "./node_modules/.bin/knex migrate:latest --env test",
"seed": "./node_modules/.bin/knex seed:run",
"make-seed": "./node_modules/.bin/knex seed:make"
"make-seed": "./node_modules/.bin/knex seed:make",
"reset-db": "./node_modules/.bin/knex migrate:rollback true && npm run migrate && npm run seed"
},
"dependencies": {
"bcrypt": "^3.0.7",