-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
136 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { createBadge } from "./badge/createBadge"; | ||
// Aquí importamos para exportar las funciones. | ||
module.exports = {createBadge} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
const Badge = require('../../models/badge.model') | ||
|
||
const createBadge = async (req, res) => { | ||
const { name, url } = await req.body; | ||
|
||
// Validación que estén todos los campos. | ||
if (!name || !url) { | ||
return res.status(404).json({ | ||
msg: "Todos los campos son requeridos", | ||
status: 404, | ||
}); | ||
} | ||
// Fin validación | ||
|
||
// Validación si es que ya está registrado. | ||
const urlBd = await Badge.findOne({url: `${url}`}).exec() | ||
if(urlBd !== null){ | ||
return res.status(409).json({ | ||
msg: "Ya existe una cuenta con este correo.", | ||
status: 409, | ||
}); | ||
} | ||
// Fin Validación | ||
|
||
try { | ||
await Badge.create({ | ||
name: name, | ||
url: url, | ||
}); | ||
res.status(201).json({ | ||
msg: "Insignia creada.", | ||
status: 201, | ||
}); | ||
} catch (err) { | ||
console.log(err); | ||
res.status(500).json({ | ||
msg: "Error al crear una insignia.", | ||
status: 500, | ||
}); | ||
} | ||
}; | ||
|
||
module.exports = {createBadge} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
const mongoose = require("mongoose"); | ||
|
||
const { Schema } = mongoose; | ||
// Creación de esquema | ||
const badgeSchema = new Schema({ | ||
name: {type: String, require: true}, | ||
url: {type: String, require: true} | ||
}); | ||
// Creación del modelo | ||
const Badge = mongoose.model("Badge", badgeSchema); | ||
|
||
module.exports = Badge; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
const router = require('express').Router() | ||
const {createBadge} = require('../controllers/badge/createBadge') | ||
|
||
router.post('/createBadge', createBadge) | ||
|
||
module.exports = router |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
const router = require("express").Router(); | ||
|
||
const userRouter = require("../routes/user.routes"); | ||
const badgeRouter = require("../routes/badge.routes"); | ||
const authRouter = require("../routes/auth.router"); | ||
|
||
router.use("/user", userRouter); | ||
router.use("/badge", badgeRouter); | ||
router.use("/auth", authRouter); | ||
|
||
module.exports = router; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,40 @@ | ||
#contenedorNoticias > img{ | ||
#contenedorNoticias > a { | ||
|
||
border-radius: 8px; | ||
width: 100%; | ||
max-width: 350px; | ||
height: auto; | ||
box-shadow: 0px 0px 30px #000; | ||
} | ||
|
||
#contenedorNoticias { | ||
padding: 40px 100px; | ||
display: grid; | ||
grid-template-columns: | ||
repeat( | ||
auto-fit, | ||
4, | ||
minmax(150px, 1fr) | ||
); | ||
gap: 32px; | ||
|
||
gap: 32px; | ||
} | ||
|
||
@media (max-width: 768px){ | ||
#contenedorNoticias { | ||
grid-template-columns: | ||
repeat( | ||
3, | ||
minmax(150px, 1fr) | ||
); | ||
} | ||
} | ||
|
||
@media (max-width: 390px) { | ||
#contenedorNoticias { | ||
grid-template-columns: | ||
repeat( | ||
2, | ||
minmax(150px, 1fr) | ||
); | ||
padding: 40px 20px; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters