diff --git a/.gcloudignore b/.gcloudignore index 4d7d693..bd37189 100644 --- a/.gcloudignore +++ b/.gcloudignore @@ -14,4 +14,5 @@ .gitignore # Node.js dependencies: -node_modules/ \ No newline at end of file +node_modules/ +front/node_modules/ \ No newline at end of file diff --git a/api-mentalhealth-datasets/index.js b/back/api-mentalhealth-datasets/index.js similarity index 99% rename from api-mentalhealth-datasets/index.js rename to back/api-mentalhealth-datasets/index.js index b2ba6e3..114704f 100644 --- a/api-mentalhealth-datasets/index.js +++ b/back/api-mentalhealth-datasets/index.js @@ -1,12 +1,7 @@ -const { json } = require("body-parser"); - const API_BASE = '/api/v1/mentalhealth-datasets'; - - - // Datos de ejemplo -module.exports = (app, dbMental) => { +function loadMentalApi(app, dbMental) { // Ruta para redirigir al portal de documentación de Postman @@ -192,7 +187,7 @@ module.exports = (app, dbMental) => { } if (datosMental) { delete datosMental._id; - + res.status(200).json(datosMental); // Devuelve un solo objeto } else { res.status(404).json({ message: 'Data not found for the specified country and year,404' }); @@ -266,14 +261,14 @@ module.exports = (app, dbMental) => { if (newData.country && newData.country !== countryName) { res.status(400).json({ error: 'Mismatched ID in the request body,400' }); return; - + } dbMental.update({ country: countryName }, { $set: newData }, { multi: true }, (err, numUpdated) => { if (err) { res.status(500).json({ error: 'Internal Server Error' }); return; - + } if (numUpdated > 0) { res.status(200).json({ message: 'Updated,200' }); @@ -373,11 +368,6 @@ module.exports = (app, dbMental) => { } }); }); +}; - - - - - -} - +export { loadMentalApi }; \ No newline at end of file diff --git a/api-salaries-datasets/index.js b/back/api-salaries-datasets/index.js similarity index 65% rename from api-salaries-datasets/index.js rename to back/api-salaries-datasets/index.js index 5777c59..4b181e8 100644 --- a/api-salaries-datasets/index.js +++ b/back/api-salaries-datasets/index.js @@ -1,6 +1,6 @@ - const API_BASE = '/api/v1/salaries-datasets'; +const API_BASE = '/api/v1/salaries-datasets'; - module.exports = (app, salarieDB) => { +function loadSalarieApi(app, salarieDB) { // RUTA "/loadInitialData" @@ -117,84 +117,84 @@ }); }); -// GET por país y año -app.get(API_BASE + '/country/:country/year/:year', (req, res) => { - const country = req.params.country; - const year = parseInt(req.params.year); + // GET por país y año + app.get(API_BASE + '/country/:country/year/:year', (req, res) => { + const country = req.params.country; + const year = parseInt(req.params.year); - // Buscar datos por país y año en la base de datos - salarieDB.findOne({ country: country, year: year }, (err, data) => { - if (err) { - return res.status(500).json({ error: 'Internal Server Error' }); - } + // Buscar datos por país y año en la base de datos + salarieDB.findOne({ country: country, year: year }, (err, data) => { + if (err) { + return res.status(500).json({ error: 'Internal Server Error' }); + } - if (data) { - // Verificar si data es un objeto - if (typeof data === 'object' && data !== null && !Array.isArray(data)) { - // Extraer los campos del primer elemento y devolverlos como un objeto - const { _id, ...formattedData } = data; - return res.status(200).json(formattedData); + if (data) { + // Verificar si data es un objeto + if (typeof data === 'object' && data !== null && !Array.isArray(data)) { + // Extraer los campos del primer elemento y devolverlos como un objeto + const { _id, ...formattedData } = data; + return res.status(200).json(formattedData); + } else { + return res.status(500).json({ error: 'Unexpected data format' }); + } } else { - return res.status(500).json({ error: 'Unexpected data format' }); + return res.status(404).json({ error: 'Data not found for the specified country and year' }); } - } else { - return res.status(404).json({ error: 'Data not found for the specified country and year' }); - } + }); }); -}); -// GET -- OK -app.get(API_BASE, (req, res) => { - - const { limit, offset, fields, ...searchParams } = req.query; + // GET -- OK + app.get(API_BASE, (req, res) => { - // obtengo los datos del dataset - salarieDB.find(searchParams, (err, response) => { - if (err) { - return res.status(500).json({ error: '500, Internal Server Error' }); - } - - let resultData = response; - console.log(resultData) - // aplico la vista personalizada - if (fields) { - const selectedFields = fields.split(','); - resultData = resultData.map(data => { - const selectedData = {}; - selectedFields.forEach(field => { - if (data.hasOwnProperty(field)) { - selectedData[field] = data[field]; - } + const { limit, offset, fields, ...searchParams } = req.query; + + // obtengo los datos del dataset + salarieDB.find(searchParams, (err, response) => { + if (err) { + return res.status(500).json({ error: '500, Internal Server Error' }); + } + + let resultData = response; + console.log(resultData) + // aplico la vista personalizada + if (fields) { + const selectedFields = fields.split(','); + resultData = resultData.map(data => { + const selectedData = {}; + selectedFields.forEach(field => { + if (data.hasOwnProperty(field)) { + selectedData[field] = data[field]; + } + }); + return selectedData; }); - return selectedData; - }); - } + } - // aplico limit y offset - - if (offset) { - resultData = resultData.slice(parseInt(offset)); - } - console.log(resultData) - if (limit) { - resultData = resultData.slice(0, parseInt(limit)); - } - console.log(resultData) - + // aplico limit y offset - if (resultData.length > 0) { - const resultsWithoutId = resultData.map(d => { - const { _id, ...datWithoutId } = d; - return datWithoutId; - }); - res.status(200).json(resultsWithoutId); - } else { - res.status(404).json({ message: '404, Data not found' }); - } + if (offset) { + resultData = resultData.slice(parseInt(offset)); + } + console.log(resultData) + if (limit) { + resultData = resultData.slice(0, parseInt(limit)); + } + console.log(resultData) + + + if (resultData.length > 0) { + const resultsWithoutId = resultData.map(d => { + const { _id, ...datWithoutId } = d; + return datWithoutId; + }); + res.status(200).json(resultsWithoutId); + } else { + res.status(404).json({ message: '404, Data not found' }); + } + }); }); -}); @@ -212,39 +212,39 @@ app.get(API_BASE, (req, res) => { } // POST para añadir nuevo salario -app.post(API_BASE, (req, res) => { - const newData = req.body; - - // Verificar si los datos cumplen con todos los campos del CSV - if (!isValidData(newData)) { - return res.status(400).json({ error: 'Bad Request - Invalid data format' }); - } - - // Comprobar si los datos ya existen - salarieDB.findOne(newData, (err, existingData) => { - if (err) { - return res.status(500).json({ error: 'Internal Server Error' }); - } + app.post(API_BASE, (req, res) => { + const newData = req.body; - if (existingData) { - return res.status(409).json({ error: 'Conflict - Data already exists' }); + // Verificar si los datos cumplen con todos los campos del CSV + if (!isValidData(newData)) { + return res.status(400).json({ error: 'Bad Request - Invalid data format' }); } - // Si los datos no existen, añadir nuevo salario - salarieDB.insert(newData, (err, newDoc) => { + // Comprobar si los datos ya existen + salarieDB.findOne(newData, (err, existingData) => { if (err) { return res.status(500).json({ error: 'Internal Server Error' }); } - if (newDoc) { - const { _id, ...responseData } = newDoc; - return res.status(201).json({ id: _id, ...responseData }); - } else { - return res.status(500).json({ error: 'Internal Server Error - Resource not created' }); + if (existingData) { + return res.status(409).json({ error: 'Conflict - Data already exists' }); } + + // Si los datos no existen, añadir nuevo salario + salarieDB.insert(newData, (err, newDoc) => { + if (err) { + return res.status(500).json({ error: 'Internal Server Error' }); + } + + if (newDoc) { + const { _id, ...responseData } = newDoc; + return res.status(201).json({ id: _id, ...responseData }); + } else { + return res.status(500).json({ error: 'Internal Server Error - Resource not created' }); + } + }); }); }); -}); // PUT para actualizar datos de un país específico @@ -284,30 +284,30 @@ app.post(API_BASE, (req, res) => { }); // PUT por país y año -app.put(API_BASE + '/country/:country/year/:year', (req, res) => { - const country = req.params.country; - const year = parseInt(req.params.year); - const newData = req.body; - - // Verificar si los datos son válidos - if (!isValidData(newData)) { - return res.status(400).json({ error: 'Bad Request - Invalid data format' }); - } + app.put(API_BASE + '/country/:country/year/:year', (req, res) => { + const country = req.params.country; + const year = parseInt(req.params.year); + const newData = req.body; - // Actualizar datos en la base de datos - salarieDB.update({ country: country, year: year }, { $set: newData }, { multi: true }, (err, numUpdated) => { - if (err) { - return res.status(500).json({ error: 'Internal Server Error' }); + // Verificar si los datos son válidos + if (!isValidData(newData)) { + return res.status(400).json({ error: 'Bad Request - Invalid data format' }); } - // Verificar si se actualizó algún documento - if (numUpdated > 0) { - return res.status(200).json({ message: 'Data updated successfully' }); - } else { - return res.status(404).json({ error: 'Data not found for the specified country and year' }); - } + // Actualizar datos en la base de datos + salarieDB.update({ country: country, year: year }, { $set: newData }, { multi: true }, (err, numUpdated) => { + if (err) { + return res.status(500).json({ error: 'Internal Server Error' }); + } + + // Verificar si se actualizó algún documento + if (numUpdated > 0) { + return res.status(200).json({ message: 'Data updated successfully' }); + } else { + return res.status(404).json({ error: 'Data not found for the specified country and year' }); + } + }); }); -}); @@ -343,41 +343,40 @@ app.put(API_BASE + '/country/:country/year/:year', (req, res) => { // DELETE para eliminar datos por país app.delete(API_BASE + '/country/:country', (req, res) => { - const country = req.params.country; + const country = req.params.country; - // Eliminar datos por el nombre del país en la base de datos - salarieDB.remove({ country: country }, { multi: true }, (err, numRemoved) => { - if (err) { - return res.status(500).json({ error: 'Internal Server Error' }); - } + // Eliminar datos por el nombre del país en la base de datos + salarieDB.remove({ country: country }, { multi: true }, (err, numRemoved) => { + if (err) { + return res.status(500).json({ error: 'Internal Server Error' }); + } - if (numRemoved > 0) { - return res.status(200).json({ message: 'Data for ' + country + ' deleted successfully' }); - } else { - return res.status(404).json({ error: 'Data not found for the specified country' }); - } + if (numRemoved > 0) { + return res.status(200).json({ message: 'Data for ' + country + ' deleted successfully' }); + } else { + return res.status(404).json({ error: 'Data not found for the specified country' }); + } }); }); //DELETE por país y año -app.delete(API_BASE + '/country/:country/year/:year', (req, res) => { - const country = req.params.country; - const year = parseInt(req.params.year); - - // Eliminar datos por país y año en la base de datos - salarieDB.remove({ country: country, year: year }, { multi: true }, (err, numRemoved) => { - if (err) { - return res.status(500).json({ error: 'Internal Server Error' }); - } - - if (numRemoved > 0) { - return res.status(200).json({ message: 'Data for ' + country + ' in year ' + year + ' deleted successfully' }); - } else { - return res.status(404).json({ error: 'Data not found for the specified country and year' }); - } - }); -}); + app.delete(API_BASE + '/country/:country/year/:year', (req, res) => { + const country = req.params.country; + const year = parseInt(req.params.year); + // Eliminar datos por país y año en la base de datos + salarieDB.remove({ country: country, year: year }, { multi: true }, (err, numRemoved) => { + if (err) { + return res.status(500).json({ error: 'Internal Server Error' }); + } + if (numRemoved > 0) { + return res.status(200).json({ message: 'Data for ' + country + ' in year ' + year + ' deleted successfully' }); + } else { + return res.status(404).json({ error: 'Data not found for the specified country and year' }); + } + }); + }); +}; -}; \ No newline at end of file +export {loadSalarieApi}; \ No newline at end of file diff --git a/api-wris-datasets/index.js b/back/api-wris-datasets/index.js similarity index 99% rename from api-wris-datasets/index.js rename to back/api-wris-datasets/index.js index 0836a82..43b68be 100644 --- a/api-wris-datasets/index.js +++ b/back/api-wris-datasets/index.js @@ -1,12 +1,12 @@ const API_BASE = '/api/v1/wris-datasets'; -module.exports = (app, dataset) => { +function loadWRIApi(app, dataset) { // PAGINA "/DOCS" // GET -- OK app.get(API_BASE + '/docs', (req, res) => { res.redirect('https://documenter.getpostman.com/view/32976490/2sA2xh3YgN'); - }); + }); // RUTA "/loadInitialData" // GET -- OK @@ -355,4 +355,6 @@ module.exports = (app, dataset) => { } }); }); -}; \ No newline at end of file +}; + +export { loadWRIApi }; \ No newline at end of file diff --git a/index.js b/index.js index ef629f0..7c479e2 100644 --- a/index.js +++ b/index.js @@ -1,29 +1,31 @@ //CODIGO GENERAL DEL SERVIDOR -let express = require("express"); -let bodyParser = require("body-parser"); -let dataStore = require("nedb"); +import express from "express"; +import bodyParser from "body-parser"; +import { loadWRIApi } from "./back/api-wris-datasets/index.js"; +import { loadMentalApi } from "./back/api-mentalhealth-datasets/index.js"; +import { loadSalarieApi } from "./back/api-salaries-datasets/index.js"; +import dataStore from "nedb"; +import {handler} from "./front/build/handler.js"; -let riskData = new dataStore(); +// Configuracion del servidor +let dbRisk = new dataStore(); let dbMental = new dataStore(); -let salarieDB = new dataStore(); - -let wris_datasetsAPI = require("./api-wris-datasets"); -let mentalhealth_datasetsAPI = require("./api-mentalhealth-datasets"); -let salaries_datasetsAPI = require("./api-salaries-datasets") - -//inicio del servidor +let dbSalarie = new dataStore(); let app = express(); // Configuracion del puerto const PORT = (process.env.PORT || 10000); - app.use(bodyParser.json()); -wris_datasetsAPI(app, riskData); -mentalhealth_datasetsAPI(app,dbMental); -salaries_datasetsAPI(app ,salarieDB ) +// Cargar las functions de las APIs +loadWRIApi(app, dbRisk); +loadMentalApi(app, dbMental); +loadSalarieApi(app, dbSalarie); + +// Cargamos el handler +app.use(handler); -app.listen(PORT); -console.log(`Server listening on port ${PORT}.`); +app.listen(PORT, () => { + console.log(`Server listening on port ${PORT}.`); +}); -// Ruta raíz "/" -app.use("/", express.static("./home")); \ No newline at end of file +console.log(`Server initializing...`); \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 2687981..ac61e13 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,20 +14,7 @@ "ejs": "^3.1.9", "express": "^4.18.3", "nedb": "^1.8.0", - "newman": "^6.1.1", - "svelte": "^4.2.12" - } - }, - "node_modules/@ampproject/remapping": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/@ampproject/remapping/-/remapping-2.3.0.tgz", - "integrity": "sha512-30iZtAPgz+LTIYoeivqYo853f02jBYSd5uGnGpkFV0M3xOt9aN73erkgYAmZU43x4VfqcnLxW9Kpg3R5LC4YYw==", - "dependencies": { - "@jridgewell/gen-mapping": "^0.3.5", - "@jridgewell/trace-mapping": "^0.3.24" - }, - "engines": { - "node": ">=6.0.0" + "newman": "^6.1.1" } }, "node_modules/@colors/colors": { @@ -44,49 +31,6 @@ "resolved": "https://registry.npmjs.org/@faker-js/faker/-/faker-5.5.3.tgz", "integrity": "sha512-R11tGE6yIFwqpaIqcfkcg7AICXzFg14+5h5v0TfF/9+RMDL6jhzCy/pxHVOfbALGdtVYdt6JdR21tuxEgl34dw==" }, - "node_modules/@jridgewell/gen-mapping": { - "version": "0.3.5", - "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.5.tgz", - "integrity": "sha512-IzL8ZoEDIBRWEzlCcRhOaCupYyN5gdIK+Q6fbFdPDg6HqX6jpkItn7DFIpW9LQzXG6Df9sA7+OKnq0qlz/GaQg==", - "dependencies": { - "@jridgewell/set-array": "^1.2.1", - "@jridgewell/sourcemap-codec": "^1.4.10", - "@jridgewell/trace-mapping": "^0.3.24" - }, - "engines": { - "node": ">=6.0.0" - } - }, - "node_modules/@jridgewell/resolve-uri": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz", - "integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==", - "engines": { - "node": ">=6.0.0" - } - }, - "node_modules/@jridgewell/set-array": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/@jridgewell/set-array/-/set-array-1.2.1.tgz", - "integrity": "sha512-R8gLRTZeyp03ymzP/6Lil/28tGeGEzhx1q2k703KGWRAI1VdvPIXdG70VJc2pAMw3NA6JKL5hhFu1sJX0Mnn/A==", - "engines": { - "node": ">=6.0.0" - } - }, - "node_modules/@jridgewell/sourcemap-codec": { - "version": "1.4.15", - "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.15.tgz", - "integrity": "sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==" - }, - "node_modules/@jridgewell/trace-mapping": { - "version": "0.3.25", - "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.25.tgz", - "integrity": "sha512-vNk6aEwybGtawWmy/PzwnGDOjCkLWSD2wqvjGGAgOAwCGWySYXfYoxt00IJkTF+8Lb57DwOb3Aa0o9CApepiYQ==", - "dependencies": { - "@jridgewell/resolve-uri": "^3.1.0", - "@jridgewell/sourcemap-codec": "^1.4.14" - } - }, "node_modules/@postman/form-data": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/@postman/form-data/-/form-data-3.1.1.tgz", @@ -125,11 +69,6 @@ "node": "*" } }, - "node_modules/@types/estree": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.5.tgz", - "integrity": "sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw==" - }, "node_modules/accepts": { "version": "1.3.8", "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz", @@ -142,17 +81,6 @@ "node": ">= 0.6" } }, - "node_modules/acorn": { - "version": "8.11.3", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.11.3.tgz", - "integrity": "sha512-Y9rRfJG5jcKOE0CLisYbojUjIrIEE7AGMzA/Sm4BslANhbS+cDMpgBdcPT91oJ7OuJ9hYJBx59RjbhxVnrF8Xg==", - "bin": { - "acorn": "bin/acorn" - }, - "engines": { - "node": ">=0.4.0" - } - }, "node_modules/ajv": { "version": "6.12.6", "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", @@ -190,14 +118,6 @@ "url": "https://github.com/chalk/ansi-styles?sponsor=1" } }, - "node_modules/aria-query": { - "version": "5.3.0", - "resolved": "https://registry.npmjs.org/aria-query/-/aria-query-5.3.0.tgz", - "integrity": "sha512-b0P0sZPKtyu8HkeRAfCq0IfURZK+SuwMjY1UXGBU27wpAiTwQAIlq56IbIO+ytk/JjS1fMR14ee5WBBfKi5J6A==", - "dependencies": { - "dequal": "^2.0.3" - } - }, "node_modules/array-flatten": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", @@ -242,14 +162,6 @@ "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.12.0.tgz", "integrity": "sha512-NmWvPnx0F1SfrQbYwOi7OeaNGokp9XhzNioJ/CSBs8Qa4vxug81mhJEAVZwxXuBmYB5KDRfMq/F3RR0BIU7sWg==" }, - "node_modules/axobject-query": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/axobject-query/-/axobject-query-4.0.0.tgz", - "integrity": "sha512-+60uv1hiVFhHZeO+Lz0RYzsVHy5Wr1ayX0mwda9KPDVLNJgZ1T9Ny7VmFbLDzxsH0D87I86vgj3gFrjTJUYznw==", - "dependencies": { - "dequal": "^2.0.3" - } - }, "node_modules/balanced-match": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", @@ -419,18 +331,6 @@ "@colors/colors": "1.5.0" } }, - "node_modules/code-red": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/code-red/-/code-red-1.0.4.tgz", - "integrity": "sha512-7qJWqItLA8/VPVlKJlFXU+NBlo/qyfs39aJcuMT/2ere32ZqvF5OSxgdM5xOfJJ7O429gg2HM47y8v9P+9wrNw==", - "dependencies": { - "@jridgewell/sourcemap-codec": "^1.4.15", - "@types/estree": "^1.0.1", - "acorn": "^8.10.0", - "estree-walker": "^3.0.3", - "periscopic": "^3.1.0" - } - }, "node_modules/color-convert": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", @@ -546,18 +446,6 @@ "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz", "integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==" }, - "node_modules/css-tree": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/css-tree/-/css-tree-2.3.1.tgz", - "integrity": "sha512-6Fv1DV/TYw//QF5IzQdqsNDjx/wc8TrMBZsqjL9eW01tWb7R7k/mq+/VXfJCl7SoD5emsJop9cOByJZfs8hYIw==", - "dependencies": { - "mdn-data": "2.0.30", - "source-map-js": "^1.0.1" - }, - "engines": { - "node": "^10 || ^12.20.0 || ^14.13.0 || >=15.0.0" - } - }, "node_modules/csv-parse": { "version": "4.16.3", "resolved": "https://registry.npmjs.org/csv-parse/-/csv-parse-4.16.3.tgz", @@ -614,14 +502,6 @@ "node": ">= 0.8" } }, - "node_modules/dequal": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/dequal/-/dequal-2.0.3.tgz", - "integrity": "sha512-0je+qPKHEMohvfRTCEo3CrPG6cAzAYgmzKyxRiYSSDkS6eGJdyVJm7WaYA5ECaAD9wLB2T4EEeymA5aFVcYXCA==", - "engines": { - "node": ">=6" - } - }, "node_modules/des.js": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/des.js/-/des.js-1.1.0.tgz", @@ -705,14 +585,6 @@ "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", "integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==" }, - "node_modules/estree-walker": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-3.0.3.tgz", - "integrity": "sha512-7RUKfXgSMMkzt6ZuXmqapOurLGPPfgj6l9uRZ7lRGolvk0y2yocc35LdcxKC5PQZdn2DMqioAQ2NoWcrTKmm6g==", - "dependencies": { - "@types/estree": "^1.0.0" - } - }, "node_modules/etag": { "version": "1.8.1", "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", @@ -1138,14 +1010,6 @@ "node": ">=8" } }, - "node_modules/is-reference": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/is-reference/-/is-reference-3.0.2.tgz", - "integrity": "sha512-v3rht/LgVcsdZa3O2Nqs+NMowLOxeOm7Ay9+/ARQ2F+qEoANRcqrjAZKGN0v8ymUetZGgkp26LTnGT7H0Qo9Pg==", - "dependencies": { - "@types/estree": "*" - } - }, "node_modules/is-typedarray": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", @@ -1254,11 +1118,6 @@ "lie": "3.1.1" } }, - "node_modules/locate-character": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/locate-character/-/locate-character-3.0.0.tgz", - "integrity": "sha512-SW13ws7BjaeJ6p7Q6CO2nchbYEc3X3J6WrmTTDto7yMPqVSZTUyY5Tjbid+Ab8gLnATtygYtiDIJGQRRn2ZOiA==" - }, "node_modules/lodash": { "version": "4.17.21", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", @@ -1275,22 +1134,6 @@ "node": ">=10" } }, - "node_modules/magic-string": { - "version": "0.30.8", - "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.8.tgz", - "integrity": "sha512-ISQTe55T2ao7XtlAStud6qwYPZjE4GK1S/BeVPus4jrq6JuOnQ00YKQC581RWhR122W7msZV263KzVeLoqidyQ==", - "dependencies": { - "@jridgewell/sourcemap-codec": "^1.4.15" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/mdn-data": { - "version": "2.0.30", - "resolved": "https://registry.npmjs.org/mdn-data/-/mdn-data-2.0.30.tgz", - "integrity": "sha512-GaqWWShW4kv/G9IEucWScBx9G1/vsFZZJUO+tD26M8J8z3Kw5RDQjaoZe03YAClgeS/SWPOcb4nkFBTEi5DUEA==" - }, "node_modules/media-typer": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", @@ -1542,16 +1385,6 @@ "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", "integrity": "sha512-7EAHlyLHI56VEIdK57uwHdHKIaAGbnXPiw0yWbarQZOKaKpvUIgW0jWRVLiatnM+XXlSwsanIBH/hzGMJulMow==" }, - "node_modules/periscopic": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/periscopic/-/periscopic-3.1.0.tgz", - "integrity": "sha512-vKiQ8RRtkl9P+r/+oefh25C3fhybptkHKCZSPlcXiJux2tJF55GnEj3BVn4A5gKfq9NWWXXrxkHBwVPUfH0opw==", - "dependencies": { - "@types/estree": "^1.0.0", - "estree-walker": "^3.0.0", - "is-reference": "^3.0.0" - } - }, "node_modules/postman-collection": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/postman-collection/-/postman-collection-4.3.0.tgz", @@ -1958,14 +1791,6 @@ "node": ">=0.10.0" } }, - "node_modules/source-map-js": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.0.tgz", - "integrity": "sha512-itJW8lvSA0TXEphiRoawsCksnlf8SyvmFzIhltqAHluXd88pkCd+cXJVHTDwdCr0IzwptSm035IHQktUu1QUMg==", - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/sshpk": { "version": "1.18.0", "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.18.0.tgz", @@ -2082,30 +1907,6 @@ "node": ">=8" } }, - "node_modules/svelte": { - "version": "4.2.12", - "resolved": "https://registry.npmjs.org/svelte/-/svelte-4.2.12.tgz", - "integrity": "sha512-d8+wsh5TfPwqVzbm4/HCXC783/KPHV60NvwitJnyTA5lWn1elhXMNWhXGCJ7PwPa8qFUnyJNIyuIRt2mT0WMug==", - "dependencies": { - "@ampproject/remapping": "^2.2.1", - "@jridgewell/sourcemap-codec": "^1.4.15", - "@jridgewell/trace-mapping": "^0.3.18", - "@types/estree": "^1.0.1", - "acorn": "^8.9.0", - "aria-query": "^5.3.0", - "axobject-query": "^4.0.0", - "code-red": "^1.0.3", - "css-tree": "^2.3.1", - "estree-walker": "^3.0.3", - "is-reference": "^3.0.1", - "locate-character": "^3.0.0", - "magic-string": "^0.30.4", - "periscopic": "^3.1.0" - }, - "engines": { - "node": ">=16" - } - }, "node_modules/teleport-javascript": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/teleport-javascript/-/teleport-javascript-1.0.0.tgz", diff --git a/package.json b/package.json index 8f46b12..1520461 100644 --- a/package.json +++ b/package.json @@ -5,8 +5,7 @@ "ejs": "^3.1.9", "express": "^4.18.3", "nedb": "^1.8.0", - "newman": "^6.1.1", - "svelte": "^4.2.12" + "newman": "^6.1.1" }, "name": "sos2324-13", "description": "Version inicial", @@ -14,11 +13,12 @@ "main": "index.js", "scripts": { "start": "node index", - "test": "npx newman run ./tests-wris/api-wris.json -e ./tests-wris/environments/gcloud.json && npx newman run ./tests-mentalhealth/test-mentalhealth-datasets.json -e ./tests-mentalhealth/enviroments/gcloud.json && npx newman run ./tests-salaries/salaries.json -e ./tests-salaries/enviroments/gcloud.json", - "test-wris-datasets": "npx newman run ./tests-wris/api-wris.json -e ./tests-wris/environments/local.json", - "test-mentalhealth-datasets": "npx newman run ./tests-mentalhealth/test-mentalhealth-datasets.json -e ./tests-mentalhealth/enviroments/local.json", - "test-salaries": "npx newman run ./tests-salaries/salaries.json -e ./tests-salaries/enviroments/local.json" + "test": "npm run test-wris-datasets && npm run test-mentalhealth-datasets && npm run test-salaries", + "test-wris-datasets": "npx newman run ./tests/api-wris.json -e ./tests/environments-wr/gcloud.json", + "test-mentalhealth-datasets": "npx newman run ./tests/api-mentalhealth.json -e ./tests/environments-mh/gcloud.json", + "test-salaries": "npx newman run ./tests/api-salaries.json -e ./tests/environments-sa/gcloud.json" }, "author": "rubromgui ", - "license": "GPL-3.0" + "license": "GPL-3.0", + "type": "module" } diff --git a/tests-mentalhealth/test-mentalhealth-datasets.json b/tests/api-mentalhealth.json similarity index 100% rename from tests-mentalhealth/test-mentalhealth-datasets.json rename to tests/api-mentalhealth.json diff --git a/tests-salaries/salaries.json b/tests/api-salaries.json similarity index 97% rename from tests-salaries/salaries.json rename to tests/api-salaries.json index aeefc21..cd326d8 100644 --- a/tests-salaries/salaries.json +++ b/tests/api-salaries.json @@ -62,12 +62,11 @@ "method": "GET", "header": [], "url": { - "raw": "{{SERVER}}//api/v1/salaries-datasets/", + "raw": "{{SERVER}}/api/v1/salaries-datasets/", "host": [ "{{SERVER}}" ], "path": [ - "", "api", "v1", "salaries-datasets", @@ -98,12 +97,11 @@ "method": "GET", "header": [], "url": { - "raw": "{{SERVER}}//api/v1/salaries-datasets/country/Sweden", + "raw": "{{SERVER}}/api/v1/salaries-datasets/country/Sweden", "host": [ "{{SERVER}}" ], "path": [ - "", "api", "v1", "salaries-datasets", @@ -144,12 +142,11 @@ } }, "url": { - "raw": "{{SERVER}}//api/v1/salaries-datasets/", + "raw": "{{SERVER}}/api/v1/salaries-datasets/", "host": [ "{{SERVER}}" ], "path": [ - "", "api", "v1", "salaries-datasets", @@ -566,12 +563,11 @@ } }, "url": { - "raw": "{{SERVER}}//api/v1/salaries-datasets/", + "raw": "{{SERVER}}/api/v1/salaries-datasets/", "host": [ "{{SERVER}}" ], "path": [ - "", "api", "v1", "salaries-datasets", @@ -607,7 +603,6 @@ "{{SERVER}}" ], "path": [ - "", "api", "v1", "salaries-datasets", @@ -658,14 +653,9 @@ "method": "DELETE", "header": [], "url": { - "raw": "https://sos2324-13.ew.r.appspot.com/api/v1/salaries-datasets", - "protocol": "https", + "raw": "{{SERVER}}/api/v1/salaries-datasets", "host": [ - "sos2324-13", - "ew", - "r", - "appspot", - "com" + "{{SERVER}}" ], "path": [ "api", diff --git a/tests-wris/api-wris.json b/tests/api-wris.json similarity index 100% rename from tests-wris/api-wris.json rename to tests/api-wris.json diff --git a/tests-mentalhealth/enviroments/gcloud.json b/tests/environments-mh/gcloud.json similarity index 100% rename from tests-mentalhealth/enviroments/gcloud.json rename to tests/environments-mh/gcloud.json diff --git a/tests-mentalhealth/enviroments/local.json b/tests/environments-mh/local.json similarity index 100% rename from tests-mentalhealth/enviroments/local.json rename to tests/environments-mh/local.json diff --git a/tests-salaries/enviroments/gcloud.json b/tests/environments-sa/gcloud.json similarity index 85% rename from tests-salaries/enviroments/gcloud.json rename to tests/environments-sa/gcloud.json index d459ecc..b55639c 100644 --- a/tests-salaries/enviroments/gcloud.json +++ b/tests/environments-sa/gcloud.json @@ -4,7 +4,7 @@ "values": [ { "key": "SERVER", - "value": "https://sos2324-13.ew.r.appspot.com", + "value": "https://sos2324-13.appspot.com", "type": "default", "enabled": true } diff --git a/tests-salaries/enviroments/local.json b/tests/environments-sa/local.json similarity index 100% rename from tests-salaries/enviroments/local.json rename to tests/environments-sa/local.json diff --git a/tests-wris/environments/gcloud.json b/tests/environments-wr/gcloud.json similarity index 100% rename from tests-wris/environments/gcloud.json rename to tests/environments-wr/gcloud.json diff --git a/tests-wris/environments/local.json b/tests/environments-wr/local.json similarity index 100% rename from tests-wris/environments/local.json rename to tests/environments-wr/local.json