patch no-query bug in rooms/ endpoint

This commit is contained in:
Sorrel Bri 2020-01-23 16:04:40 -08:00
parent 0a66d3f93c
commit 015be6ca6b
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) => { const getAll = async (req, res, next) => {
try { try {
const publicRooms = await roomQueries.findPublicRooms();
res.status(200).json({rooms: [...publicRooms]}) res.status(200).json({rooms: [...publicRooms]})
} }
@ -17,7 +19,6 @@ const show = async (req, res, next) => {
try { try {
const roomId = req.params.id; const roomId = req.params.id;
// TODO eventually add check for user's private rooms // TODO eventually add check for user's private rooms
const publicRooms = await roomQueries.findPublicRooms();
enableRoomSocket(roomId); enableRoomSocket(roomId);
const currentRoom = await roomQueries.findRoomById(roomId); const currentRoom = await roomQueries.findRoomById(roomId);

View file

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

View file

@ -10,7 +10,14 @@ exports.seed = function(knex) {
application: 'node-go', application_version: '0.1.0', application: 'node-go', application_version: '0.1.0',
player_black: 'anon', player_white: 'anon', player_black: 'anon', player_white: 'anon',
player_black_rank: 'K3', player_white_rank: 'K2', 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": "./node_modules/.bin/knex migrate:latest",
"migrate-test": "./node_modules/.bin/knex migrate:latest --env test", "migrate-test": "./node_modules/.bin/knex migrate:latest --env test",
"seed": "./node_modules/.bin/knex seed:run", "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": { "dependencies": {
"bcrypt": "^3.0.7", "bcrypt": "^3.0.7",