add user registration

This commit is contained in:
João Geonizeli
2022-07-08 19:08:03 -03:00
parent 874706cabb
commit 688d5e89b7
16 changed files with 478 additions and 235 deletions

View File

@@ -0,0 +1,30 @@
import { RequestHandler, Router } from 'express'
import { UserDto } from '../dto/user.dto';
import { UserService } from '../service/user.service';
const router = Router();
const basePath = '/users'
export const post: RequestHandler = (req, res) => {
const { email, password } = req.body;
UserService.create({
email,
password
}).then(user => {
const respose: UserDto = {
id: user.id,
email: user.email
}
res.json(respose);
}).catch(err => {
res.status(422).json({
error: err.message
});
})
}
router.post(basePath, post)
export const UserRoutes = router;