organización de endpoints
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
const fs = require('fs');
|
||||
// const fs = require('fs');
|
||||
const moment = require('moment');
|
||||
const validator = require('validator');
|
||||
const Servicio = require('../db/tablas/Servicio');
|
||||
@@ -144,42 +144,13 @@ const validarAccesibilidad = (usuariosValidos = [], idTipoUsuario) => {
|
||||
throw new Error('Este usuario no tiene permitido usar esta linea de la API.');
|
||||
};
|
||||
|
||||
const isObjectEmpty = (obj) => {
|
||||
const validarObjetoVacio = (obj) => {
|
||||
for (let key in obj) {
|
||||
if (obj.hasOwnProperty(key)) return false;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
const crearDDMMAAAA = (date) => {
|
||||
const fechaMoment = moment(date);
|
||||
let ddmmaaaa = '';
|
||||
|
||||
if (fechaMoment.isValid())
|
||||
ddmmaaaa = `${fechaMoment.date()}/${
|
||||
fechaMoment.month() + 1
|
||||
}/${fechaMoment.year()}`;
|
||||
return ddmmaaaa;
|
||||
};
|
||||
|
||||
const eliminarArchivo = (path) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
fs.unlink(path, (err) => {
|
||||
if (err) reject(err);
|
||||
resolve({ message: 'Se elimino el archivo correctamente.' });
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
const crearArchivo = (path, texto) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
fs.appendFile(path, texto, (err) => {
|
||||
if (err) reject(err);
|
||||
resolve({ message: 'Se creo el archivo correctamente.' });
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
validar,
|
||||
noValido,
|
||||
@@ -194,8 +165,5 @@ module.exports = {
|
||||
validarNumero,
|
||||
validarPreTermino,
|
||||
validarAccesibilidad,
|
||||
isObjectEmpty,
|
||||
crearDDMMAAAA,
|
||||
eliminarArchivo,
|
||||
crearArchivo,
|
||||
validarObjetoVacio,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user