mirror of
https://github.com/directus/directus.git
synced 2026-01-23 19:18:07 -05:00
22 lines
647 B
TypeScript
22 lines
647 B
TypeScript
export default async function usersCreate({ email, password, role }: any) {
|
|
const { default: database, schemaInspector } = require('../../../database/index').default;
|
|
const { UsersService } = require('../../../services/users');
|
|
|
|
if (!email || !password || !role) {
|
|
console.error('Email, password, role are required');
|
|
process.exit(1);
|
|
}
|
|
|
|
try {
|
|
const schema = await schemaInspector.overview();
|
|
const service = new UsersService({ schema, knex: database });
|
|
|
|
const id = await service.create({ email, password, role, status: 'active' });
|
|
console.log(id);
|
|
} catch (err) {
|
|
console.error(err);
|
|
} finally {
|
|
database.destroy();
|
|
}
|
|
}
|