From cecdace96c60ee4cba2151f7a2d5542f48808fb7 Mon Sep 17 00:00:00 2001 From: Marcos Pimentel Date: Fri, 15 Sep 2023 02:02:46 -0300 Subject: [PATCH] feat: req08 --- src/app.js | 3 ++- src/controllers/index.js | 2 ++ src/services/index.js | 2 ++ src/services/validations/index.js | 2 ++ src/utils/schemas.js | 5 +++++ 5 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/app.js b/src/app.js index f1f7fa1..a0f18ba 100644 --- a/src/app.js +++ b/src/app.js @@ -1,5 +1,5 @@ const express = require('express'); -const { loginController, userController } = require('./controllers'); +const { loginController, userController, categoryController } = require('./controllers'); const { error, auth } = require('./middlewares'); const app = express(); @@ -14,6 +14,7 @@ app.post('/login', loginController); app.post('/user', userController.create); app.get('/user', auth, userController.getAll); app.get('/user/:id', auth, userController.getById); +app.post('/categories', auth, categoryController.create); app.use(error); diff --git a/src/controllers/index.js b/src/controllers/index.js index aa86094..4571f59 100644 --- a/src/controllers/index.js +++ b/src/controllers/index.js @@ -1,7 +1,9 @@ const userController = require('./userController'); const loginController = require('./loginController'); +const categoryController = require('./categoryController'); module.exports = { userController, loginController, + categoryController, }; \ No newline at end of file diff --git a/src/services/index.js b/src/services/index.js index 96e90b3..9180837 100644 --- a/src/services/index.js +++ b/src/services/index.js @@ -1,7 +1,9 @@ const userService = require('./userService'); const loginService = require('./loginService'); +const categoryService = require('./categoryService'); module.exports = { userService, loginService, + categoryService, }; diff --git a/src/services/validations/index.js b/src/services/validations/index.js index 756219b..5e72fe1 100644 --- a/src/services/validations/index.js +++ b/src/services/validations/index.js @@ -1,7 +1,9 @@ const loginValidation = require('./loginValidation'); const createUserValidation = require('./createUserValidation'); +const createCategoryValidation = require('./createCategoryValidation'); module.exports = { loginValidation, createUserValidation, + createCategoryValidation, }; \ No newline at end of file diff --git a/src/utils/schemas.js b/src/utils/schemas.js index 68803df..8b0f6f5 100644 --- a/src/utils/schemas.js +++ b/src/utils/schemas.js @@ -36,7 +36,12 @@ const createUserSchema = Joi.object({ }); +const createCategorySchema = Joi.object({ + name: Joi.string().required(), +}); + module.exports = { loginSchema, createUserSchema, + createCategorySchema, };