mirror of
https://github.com/sasjs/server.git
synced 2025-12-10 19:34:34 +00:00
21 lines
591 B
TypeScript
21 lines
591 B
TypeScript
import express from 'express'
|
|
import { ClientController } from '../../controllers'
|
|
import { registerClientValidation } from '../../utils'
|
|
|
|
const clientRouter = express.Router()
|
|
|
|
clientRouter.post('/', async (req, res) => {
|
|
const { error, value: body } = registerClientValidation(req.body)
|
|
if (error) return res.status(400).send(error.details[0].message)
|
|
|
|
const controller = new ClientController()
|
|
try {
|
|
const response = await controller.createClient(body)
|
|
res.send(response)
|
|
} catch (err: any) {
|
|
res.status(403).send(err.toString())
|
|
}
|
|
})
|
|
|
|
export default clientRouter
|