From e0884bbb147168d59430e534d17f866b1b9f3e42 Mon Sep 17 00:00:00 2001 From: humberto-desk Date: Sun, 23 Jan 2022 07:51:06 -0800 Subject: [PATCH] 182. Definicion basica de ruta 'uploads' --- .gitignore | 5 ++++- controllers/uploads.js | 10 ++++++++++ models/server.js | 2 ++ routes/uploads.js | 13 +++++++++++++ 4 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 controllers/uploads.js create mode 100644 routes/uploads.js diff --git a/.gitignore b/.gitignore index 1dcef2d..3ec992e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,5 @@ node_modules -.env \ No newline at end of file +.env + +# Visual Studio Code +.vscode \ No newline at end of file diff --git a/controllers/uploads.js b/controllers/uploads.js new file mode 100644 index 0000000..7d94d89 --- /dev/null +++ b/controllers/uploads.js @@ -0,0 +1,10 @@ +const { response } = require("express"); +const { models } = require("mongoose"); + +const cargarArchivo = (req, res = response) => { + res.json({ msg: "Hola mundo" }); +}; + +module.exports = { + cargarArchivo, +}; diff --git a/models/server.js b/models/server.js index 6ea7dfb..56af9b9 100644 --- a/models/server.js +++ b/models/server.js @@ -12,6 +12,7 @@ class Server { buscar: "/api/buscar", categorias: "/api/categorias", productos: "/api/productos", + uploads: "/api/uploads", usuarios: "/api/usuarios", }; @@ -46,6 +47,7 @@ class Server { this.app.use(this.paths.buscar, require("../routes/buscar")); this.app.use(this.paths.categorias, require("../routes/categorias")); this.app.use(this.paths.productos, require("../routes/productos")); + this.app.use(this.paths.uploads, require("../routes/uploads")); this.app.use(this.paths.usuarios, require("../routes/usuarios")); } diff --git a/routes/uploads.js b/routes/uploads.js new file mode 100644 index 0000000..a774121 --- /dev/null +++ b/routes/uploads.js @@ -0,0 +1,13 @@ +const { Router } = require("express"); +const { check } = require("express-validator"); + + +const { cargarArchivo } = require("../controllers/uploads"); +const { validarCampos } = require("../middlewares/validar-campos"); + + +const router = Router(); + +router.post('/', cargarArchivo) + +module.exports = router;