wip
This commit is contained in:
parent
8f9519db95
commit
06eabcbc63
6 changed files with 148 additions and 0 deletions
18
src/api/endpoints/othello/sessions/create.ts
Normal file
18
src/api/endpoints/othello/sessions/create.ts
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
import rndstr from 'rndstr';
|
||||
import Session, { pack } from '../../../models/othello-session';
|
||||
|
||||
module.exports = (params, user) => new Promise(async (res, rej) => {
|
||||
// 以前のセッションはすべて削除しておく
|
||||
await Session.remove({
|
||||
user_id: user._id
|
||||
});
|
||||
|
||||
// セッションを作成
|
||||
const session = await Session.insert({
|
||||
user_id: user._id,
|
||||
code: rndstr('a-z0-9', 3)
|
||||
});
|
||||
|
||||
// Reponse
|
||||
res(await pack(session));
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue