+ await createUserAccountAndChannel(user)
+
+ logger.info('User %s with its channel and account created.', body.username)
+}
+
+async function registerUserRetryWrapper (req: express.Request, res: express.Response, next: express.NextFunction) {
+ const options = {
+ arguments: [ req ],
+ errorMessage: 'Cannot insert the user with many retries.'
+ }
+
+ await retryTransactionWrapper(registerUser, options)
+
+ return res.type('json').status(204).end()
+}
+
+async function registerUser (req: express.Request) {
+ const body: UserCreate = req.body
+
+ const user = db.User.build({
+ username: body.username,
+ password: body.password,
+ email: body.email,
+ displayNSFW: false,
+ role: UserRole.USER,
+ videoQuota: CONFIG.USER.VIDEO_QUOTA
+ })
+
+ await createUserAccountAndChannel(user)
+
+ logger.info('User %s with its channel and account registered.', body.username)