patch no-query bug in rooms/ endpoint
This commit is contained in:
parent
34c3b34ada
commit
e3ce466bb4
5 changed files with 13 additions and 3 deletions
|
@ -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);
|
||||||
|
|
|
@ -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');
|
||||||
|
|
|
@ -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
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
});
|
});
|
|
@ -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",
|
||||||
|
|
Loading…
Reference in a new issue