You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Hydro/hydro/script/register.ts

21 lines
517 B
TypeScript

import * as user from '../model/user';
export const description = 'Create a new user';
export async function run({
uname, password, mail, uid,
}) {
if (uid) uid = parseInt(uid, 10);
if (uid && Number.isNaN(uid)) throw new Error('uid');
uid = await user.create(mail, uname, password, uid);
return uid;
}
export const validate = {
uname: { $type: 'string' },
password: { $type: 'string' },
mail: { $type: 'string' },
};
global.Hydro.script.register = { run, description, validate };