({
email,
password,
role,
}: {
email?: string;
password?: string;
role?: string;
})
| 5 | import { getSchema } from '../../../utils/get-schema.js'; |
| 6 | |
| 7 | export default async function usersCreate({ |
| 8 | email, |
| 9 | password, |
| 10 | role, |
| 11 | }: { |
| 12 | email?: string; |
| 13 | password?: string; |
| 14 | role?: string; |
| 15 | }): Promise<void> { |
| 16 | const database = getDatabase(); |
| 17 | const logger = useLogger(); |
| 18 | |
| 19 | if (!email || !password || !role) { |
| 20 | logger.error('Email, password, role are required'); |
| 21 | process.exit(1); |
| 22 | } |
| 23 | |
| 24 | // Ensure we enforce license limits for user create |
| 25 | await getLicenseManager().initialize(); |
| 26 | |
| 27 | try { |
| 28 | const schema = await getSchema(); |
| 29 | const service = new UsersService({ schema, knex: database }); |
| 30 | |
| 31 | const id = await service.createOne({ email, password, role, status: 'active' }); |
| 32 | process.stdout.write(`${String(id)}\n`); |
| 33 | database.destroy(); |
| 34 | process.exit(0); |
| 35 | } catch (err: any) { |
| 36 | logger.error(err); |
| 37 | process.exit(1); |
| 38 | } |
| 39 | } |
nothing calls this directly
no test coverage detected