jormungandr-bite/src/server/api/endpoints/admin/invite.ts
2018-08-29 06:59:43 +09:00

26 lines
480 B
TypeScript

import rndstr from 'rndstr';
import RegistrationTicket from '../../../../models/registration-tickets';
export const meta = {
desc: {
'ja-JP': '招待コードを発行します。'
},
requireCredential: true,
requireAdmin: true,
params: {}
};
export default (params: any) => new Promise(async (res, rej) => {
const code = rndstr({ length: 5, chars: '0-9' });
await RegistrationTicket.insert({
createdAt: new Date(),
code: code
});
res({
code: code
});
});