tianji/src/server/router/user.ts

21 lines
532 B
TypeScript
Raw Normal View History

2023-09-02 14:53:57 +00:00
import { Router } from 'express';
import { body, validate } from '../middleware/validate';
import { createAdminUser } from '../model/user';
export const userRouter = Router();
userRouter.post(
'/createAdmin',
validate(
body('username').exists().withMessage('Username should be existed'),
body('password').exists().withMessage('Password should be existed')
),
async (req, res) => {
const { username, password } = req.body;
await createAdminUser(username, password);
res.json({ result: true });
}
);