diff --git a/.editorconfig b/.editorconfig index 733f173..566cfc0 100755 --- a/.editorconfig +++ b/.editorconfig @@ -3,4 +3,7 @@ indent_style = space indent_size = 4 end_of_line = lf charset = utf-8 -trim_trailing_whitespace = true \ No newline at end of file +trim_trailing_whitespace = true + +[*.js] +indent_size = 2 diff --git a/api/.env.example b/api/.env.example new file mode 100644 index 0000000..496ef02 --- /dev/null +++ b/api/.env.example @@ -0,0 +1,7 @@ +APPLICATION_PORT=5000 + +DATABASE_PORT=5432 +DATABASE_USER=harpoon +DATABASE_HOST=localhost +DATABASE_NAME=harpoon +DATABASE_PASSWORD=harpoon diff --git a/api/.gitignore b/api/.gitignore new file mode 100644 index 0000000..3502ef7 --- /dev/null +++ b/api/.gitignore @@ -0,0 +1,144 @@ +# Created by https://www.toptal.com/developers/gitignore/api/node +# Edit at https://www.toptal.com/developers/gitignore?templates=node + +### Node ### +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +lerna-debug.log* +.pnpm-debug.log* + +# Diagnostic reports (https://nodejs.org/api/report.html) +report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage +*.lcov + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Bower dependency directory (https://bower.io/) +bower_components + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (https://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules/ +jspm_packages/ + +# Snowpack dependency directory (https://snowpack.dev/) +web_modules/ + +# TypeScript cache +*.tsbuildinfo + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Optional stylelint cache +.stylelintcache + +# Microbundle cache +.rpt2_cache/ +.rts2_cache_cjs/ +.rts2_cache_es/ +.rts2_cache_umd/ + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variable files +.env +.env.development.local +.env.test.local +.env.production.local +.env.local + +# parcel-bundler cache (https://parceljs.org/) +.cache +.parcel-cache + +# Next.js build output +.next +out + +# Nuxt.js build / generate output +.nuxt +dist + +# Gatsby files +.cache/ +# Comment in the public line in if your project uses Gatsby and not Next.js +# https://nextjs.org/blog/next-9-1#public-directory-support +# public + +# vuepress build output +.vuepress/dist + +# vuepress v2.x temp and cache directory +.temp + +# Docusaurus cache and generated files +.docusaurus + +# Serverless directories +.serverless/ + +# FuseBox cache +.fusebox/ + +# DynamoDB Local files +.dynamodb/ + +# TernJS port file +.tern-port + +# Stores VSCode versions used for testing VSCode extensions +.vscode-test + +# yarn v2 +.yarn/cache +.yarn/unplugged +.yarn/build-state.yml +.yarn/install-state.gz +.pnp.* + +### Node Patch ### +# Serverless Webpack directories +.webpack/ + +# Optional stylelint cache + +# SvelteKit build / generate output +.svelte-kit + +# End of https://www.toptal.com/developers/gitignore/api/node diff --git a/api/Dockerfile b/api/Dockerfile new file mode 100644 index 0000000..83195f5 --- /dev/null +++ b/api/Dockerfile @@ -0,0 +1,13 @@ +FROM node:lts + +WORKDIR /usr/src/app + +COPY package*.json ./ + +RUN npm install + +COPY . . + +EXPOSE 3000 + +CMD ["npm", "run", "dev"] diff --git a/api/database/connector.js b/api/database/connector.js new file mode 100644 index 0000000..1893df5 --- /dev/null +++ b/api/database/connector.js @@ -0,0 +1,13 @@ +const { Pool } = require('pg'); +const dotenv = require('dotenv') +dotenv.config() + +const pool = new Pool({ + user: process.env.DATABASE_USER, + host: process.env.DATABASE_HOST, + database: process.env.DATABASE_NAME, + password: process.env.DATABASE_PASSWORD, + port: process.env.DATABASE_PORT, +}); + +module.exports = pool; diff --git a/api/database/database.sql b/api/database/database.sql new file mode 100644 index 0000000..85aff41 --- /dev/null +++ b/api/database/database.sql @@ -0,0 +1,36 @@ +CREATE TABLE IF NOT EXISTS public.company ( + ID SERIAL PRIMARY KEY, + NAME VARCHAR(62) NOT NULL, + EMAIL VARCHAR(50) NOT NULL, + STATUS INT NOT NULL +); + +CREATE TABLE IF NOT EXISTS public.rule ( + ID SERIAL PRIMARY KEY, + ID_COMPANY INT NOT NULL, + STRING VARCHAR(60) NOT NULL, + FILTER TEXT NOT NULL, + SCORE VARCHAR(10) NOT NULL, + DESCRIPTION VARCHAR(64) NOT NULL, + STATUS INT NOT NULL, + CONSTRAINT FK_company_rule FOREIGN KEY (ID_COMPANY) REFERENCES public.company (ID) ON DELETE NO ACTION ON UPDATE NO ACTION +); + +CREATE TABLE IF NOT EXISTS public.alert ( + ID SERIAL PRIMARY KEY, + ID_COMPANY INT NOT NULL, + DATETIME TIMESTAMP NOT NULL DEFAULT current_timestamp, + STATUS INT NOT NULL, + NOTIFICATION INT NOT NULL, + HASH CHAR(32) NOT NULL, + CONSTRAINT FK_company_alert FOREIGN KEY (ID_COMPANY) REFERENCES public.company (ID) ON DELETE NO ACTION ON UPDATE NO ACTION +); + +CREATE TABLE IF NOT EXISTS public.history ( + ID SERIAL PRIMARY KEY, + ID_COMPANY INT NOT NULL, + SOURCE VARCHAR(255), + DATETIME TIMESTAMP NOT NULL DEFAULT current_timestamp, + STATUS INT NOT NULL, + CONSTRAINT FK_company_history FOREIGN KEY (ID_COMPANY) REFERENCES public.company (ID) ON DELETE NO ACTION ON UPDATE NO ACTION +); diff --git a/api/docker-compose.yml b/api/docker-compose.yml new file mode 100644 index 0000000..1e4087d --- /dev/null +++ b/api/docker-compose.yml @@ -0,0 +1,34 @@ +services: + db: + container_name: harpoon_database + image: postgres:latest + env_file: + - .env + environment: + - POSTGRES_USER=${DATABASE_USER} + - POSTGRES_PASSWORD=${DATABASE_PASSWORD} + - POSTGRES_DB=${DATABASE_NAME} + volumes: + - ./database:/docker-entrypoint-initdb.d + ports: + - "${DATABASE_PORT}:${DATABASE_PORT}" + healthcheck: + test: ["CMD", "pg_isready", "-U", "${DATABASE_USER}"] + interval: 5s + timeout: 5s + retries: 3 + + app: + container_name: harpoon_app + env_file: + - .env + build: + context: . + dockerfile: Dockerfile + ports: + - "${APPLICATION_PORT}:${APPLICATION_PORT}" + environment: + - NODE_ENV=development + depends_on: + - db + restart: unless-stopped diff --git a/api/index.js b/api/index.js new file mode 100644 index 0000000..093f592 --- /dev/null +++ b/api/index.js @@ -0,0 +1,20 @@ +const express = require('express') +const app = express() +const dotenv = require('dotenv') +dotenv.config() + +const port = process.env.APPLICATION_PORT + +app.use(express.json()) + +const alertsRoutes = require('./routes/alerts') +const companyRoutes = require('./routes/company') +const historyRoutes = require('./routes/history') +const ruleRoutes = require('./routes/rule') + +app.use('/alerts', alertsRoutes) +app.use('/company', companyRoutes) +app.use('/history', historyRoutes) +app.use('/rule', ruleRoutes) + +app.listen(port, () => console.log(`App listening on port ${port}`)) diff --git a/api/package-lock.json b/api/package-lock.json new file mode 100644 index 0000000..9a773d4 --- /dev/null +++ b/api/package-lock.json @@ -0,0 +1,1188 @@ +{ + "name": "api", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "api", + "version": "1.0.0", + "license": "MIT", + "dependencies": { + "dotenv": "^16.4.5", + "express": "^4.19.2", + "pg": "^8.12.0" + }, + "devDependencies": { + "nodemon": "^3.1.4" + } + }, + "node_modules/accepts": { + "version": "1.3.8", + "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz", + "integrity": "sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw==", + "dependencies": { + "mime-types": "~2.1.34", + "negotiator": "0.6.3" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/anymatch": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz", + "integrity": "sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==", + "dev": true, + "dependencies": { + "normalize-path": "^3.0.0", + "picomatch": "^2.0.4" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/array-flatten": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", + "integrity": "sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg==" + }, + "node_modules/balanced-match": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", + "dev": true + }, + "node_modules/binary-extensions": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.3.0.tgz", + "integrity": "sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw==", + "dev": true, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/body-parser": { + "version": "1.20.2", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.2.tgz", + "integrity": "sha512-ml9pReCu3M61kGlqoTm2umSXTlRTuGTx0bfYj+uIUKKYycG5NtSbeetV3faSU6R7ajOPw0g/J1PvK4qNy7s5bA==", + "dependencies": { + "bytes": "3.1.2", + "content-type": "~1.0.5", + "debug": "2.6.9", + "depd": "2.0.0", + "destroy": "1.2.0", + "http-errors": "2.0.0", + "iconv-lite": "0.4.24", + "on-finished": "2.4.1", + "qs": "6.11.0", + "raw-body": "2.5.2", + "type-is": "~1.6.18", + "unpipe": "1.0.0" + }, + "engines": { + "node": ">= 0.8", + "npm": "1.2.8000 || >= 1.4.16" + } + }, + "node_modules/brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "node_modules/braces": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz", + "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==", + "dev": true, + "dependencies": { + "fill-range": "^7.1.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/bytes": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz", + "integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/call-bind": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.7.tgz", + "integrity": "sha512-GHTSNSYICQ7scH7sZ+M2rFopRoLh8t2bLSW6BbgrtLsahOIB5iyAVJf9GjWK3cYTDaMj4XdBpM1cA6pIS0Kv2w==", + "dependencies": { + "es-define-property": "^1.0.0", + "es-errors": "^1.3.0", + "function-bind": "^1.1.2", + "get-intrinsic": "^1.2.4", + "set-function-length": "^1.2.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/chokidar": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.6.0.tgz", + "integrity": "sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==", + "dev": true, + "dependencies": { + "anymatch": "~3.1.2", + "braces": "~3.0.2", + "glob-parent": "~5.1.2", + "is-binary-path": "~2.1.0", + "is-glob": "~4.0.1", + "normalize-path": "~3.0.0", + "readdirp": "~3.6.0" + }, + "engines": { + "node": ">= 8.10.0" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + }, + "optionalDependencies": { + "fsevents": "~2.3.2" + } + }, + "node_modules/concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", + "dev": true + }, + "node_modules/content-disposition": { + "version": "0.5.4", + "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.4.tgz", + "integrity": "sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ==", + "dependencies": { + "safe-buffer": "5.2.1" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/content-type": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.5.tgz", + "integrity": "sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/cookie": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.6.0.tgz", + "integrity": "sha512-U71cyTamuh1CRNCfpGY6to28lxvNwPG4Guz/EVjgf3Jmzv0vlDp1atT9eS5dDjMYHucpHbWns6Lwf3BKz6svdw==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/cookie-signature": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz", + "integrity": "sha512-QADzlaHc8icV8I7vbaJXJwod9HWYp8uCqf1xa4OfNu1T7JVxQIrUgOWtHdNDtPiywmFbiS12VjotIXLrKM3orQ==" + }, + "node_modules/debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "dependencies": { + "ms": "2.0.0" + } + }, + "node_modules/define-data-property": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/define-data-property/-/define-data-property-1.1.4.tgz", + "integrity": "sha512-rBMvIzlpA8v6E+SJZoo++HAYqsLrkg7MSfIinMPFhmkorw7X+dOXVJQs+QT69zGkzMyfDnIMN2Wid1+NbL3T+A==", + "dependencies": { + "es-define-property": "^1.0.0", + "es-errors": "^1.3.0", + "gopd": "^1.0.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/depd": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", + "integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/destroy": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.2.0.tgz", + "integrity": "sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg==", + "engines": { + "node": ">= 0.8", + "npm": "1.2.8000 || >= 1.4.16" + } + }, + "node_modules/dotenv": { + "version": "16.4.5", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.4.5.tgz", + "integrity": "sha512-ZmdL2rui+eB2YwhsWzjInR8LldtZHGDoQ1ugH85ppHKwpUHL7j7rN0Ti9NCnGiQbhaZ11FpR+7ao1dNsmduNUg==", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://dotenvx.com" + } + }, + "node_modules/ee-first": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", + "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==" + }, + "node_modules/encodeurl": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", + "integrity": "sha512-TPJXq8JqFaVYm2CWmPvnP2Iyo4ZSM7/QKcSmuMLDObfpH5fi7RUGmd/rTDf+rut/saiDiQEeVTNgAmJEdAOx0w==", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/es-define-property": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.0.tgz", + "integrity": "sha512-jxayLKShrEqqzJ0eumQbVhTYQM27CfT1T35+gCgDFoL82JLsXqTJ76zv6A0YLOgEnLUMvLzsDsGIrl8NFpT2gQ==", + "dependencies": { + "get-intrinsic": "^1.2.4" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-errors": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz", + "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/escape-html": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", + "integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==" + }, + "node_modules/etag": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", + "integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/express": { + "version": "4.19.2", + "resolved": "https://registry.npmjs.org/express/-/express-4.19.2.tgz", + "integrity": "sha512-5T6nhjsT+EOMzuck8JjBHARTHfMht0POzlA60WV2pMD3gyXw2LZnZ+ueGdNxG+0calOJcWKbpFcuzLZ91YWq9Q==", + "dependencies": { + "accepts": "~1.3.8", + "array-flatten": "1.1.1", + "body-parser": "1.20.2", + "content-disposition": "0.5.4", + "content-type": "~1.0.4", + "cookie": "0.6.0", + "cookie-signature": "1.0.6", + "debug": "2.6.9", + "depd": "2.0.0", + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "etag": "~1.8.1", + "finalhandler": "1.2.0", + "fresh": "0.5.2", + "http-errors": "2.0.0", + "merge-descriptors": "1.0.1", + "methods": "~1.1.2", + "on-finished": "2.4.1", + "parseurl": "~1.3.3", + "path-to-regexp": "0.1.7", + "proxy-addr": "~2.0.7", + "qs": "6.11.0", + "range-parser": "~1.2.1", + "safe-buffer": "5.2.1", + "send": "0.18.0", + "serve-static": "1.15.0", + "setprototypeof": "1.2.0", + "statuses": "2.0.1", + "type-is": "~1.6.18", + "utils-merge": "1.0.1", + "vary": "~1.1.2" + }, + "engines": { + "node": ">= 0.10.0" + } + }, + "node_modules/fill-range": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", + "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==", + "dev": true, + "dependencies": { + "to-regex-range": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/finalhandler": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.2.0.tgz", + "integrity": "sha512-5uXcUVftlQMFnWC9qu/svkWv3GTd2PfUhK/3PLkYNAe7FbqJMt3515HaxE6eRL74GdsriiwujiawdaB1BpEISg==", + "dependencies": { + "debug": "2.6.9", + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "on-finished": "2.4.1", + "parseurl": "~1.3.3", + "statuses": "2.0.1", + "unpipe": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/forwarded": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz", + "integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/fresh": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", + "integrity": "sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/fsevents": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", + "dev": true, + "hasInstallScript": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, + "node_modules/function-bind": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", + "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/get-intrinsic": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.4.tgz", + "integrity": "sha512-5uYhsJH8VJBTv7oslg4BznJYhDoRI6waYCxMmCdnTrcCrHA/fCFKoTFz2JKKE0HdDFUF7/oQuhzumXJK7paBRQ==", + "dependencies": { + "es-errors": "^1.3.0", + "function-bind": "^1.1.2", + "has-proto": "^1.0.1", + "has-symbols": "^1.0.3", + "hasown": "^2.0.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/glob-parent": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", + "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", + "dev": true, + "dependencies": { + "is-glob": "^4.0.1" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/gopd": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.0.1.tgz", + "integrity": "sha512-d65bNlIadxvpb/A2abVdlqKqV563juRnZ1Wtk6s1sIR8uNsXR70xqIzVqxVf1eTqDunwT2MkczEeaezCKTZhwA==", + "dependencies": { + "get-intrinsic": "^1.1.3" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==", + "dev": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/has-property-descriptors": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/has-property-descriptors/-/has-property-descriptors-1.0.2.tgz", + "integrity": "sha512-55JNKuIW+vq4Ke1BjOTjM2YctQIvCT7GFzHwmfZPGo5wnrgkid0YQtnAleFSqumZm4az3n2BS+erby5ipJdgrg==", + "dependencies": { + "es-define-property": "^1.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-proto": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/has-proto/-/has-proto-1.0.3.tgz", + "integrity": "sha512-SJ1amZAJUiZS+PhsVLf5tGydlaVB8EdFpaSO4gmiUKUOxk8qzn5AIy4ZeJUmh22znIdk/uMAUT2pl3FxzVUH+Q==", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-symbols": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.3.tgz", + "integrity": "sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/hasown": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz", + "integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==", + "dependencies": { + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/http-errors": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.0.tgz", + "integrity": "sha512-FtwrG/euBzaEjYeRqOgly7G0qviiXoJWnvEH2Z1plBdXgbyjv34pHTSb9zoeHMyDy33+DWy5Wt9Wo+TURtOYSQ==", + "dependencies": { + "depd": "2.0.0", + "inherits": "2.0.4", + "setprototypeof": "1.2.0", + "statuses": "2.0.1", + "toidentifier": "1.0.1" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/iconv-lite": { + "version": "0.4.24", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", + "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", + "dependencies": { + "safer-buffer": ">= 2.1.2 < 3" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/ignore-by-default": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/ignore-by-default/-/ignore-by-default-1.0.1.tgz", + "integrity": "sha512-Ius2VYcGNk7T90CppJqcIkS5ooHUZyIQK+ClZfMfMNFEF9VSE73Fq+906u/CWu92x4gzZMWOwfFYckPObzdEbA==", + "dev": true + }, + "node_modules/inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" + }, + "node_modules/ipaddr.js": { + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz", + "integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==", + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/is-binary-path": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", + "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", + "dev": true, + "dependencies": { + "binary-extensions": "^2.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-glob": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", + "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", + "dev": true, + "dependencies": { + "is-extglob": "^2.1.1" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-number": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", + "dev": true, + "engines": { + "node": ">=0.12.0" + } + }, + "node_modules/media-typer": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", + "integrity": "sha512-dq+qelQ9akHpcOl/gUVRTxVIOkAJ1wR3QAvb4RsVjS8oVoFjDGTc679wJYmUmknUF5HwMLOgb5O+a3KxfWapPQ==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/merge-descriptors": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz", + "integrity": "sha512-cCi6g3/Zr1iqQi6ySbseM1Xvooa98N0w31jzUYrXPX2xqObmFGHJ0tQ5u74H3mVh7wLouTseZyYIq39g8cNp1w==" + }, + "node_modules/methods": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz", + "integrity": "sha512-iclAHeNqNm68zFtnZ0e+1L2yUIdvzNoauKU4WBA3VvH/vPFieF7qfRlwUZU+DA9P9bPXIS90ulxoUoCH23sV2w==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz", + "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==", + "bin": { + "mime": "cli.js" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/mime-db": { + "version": "1.52.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", + "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime-types": { + "version": "2.1.35", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", + "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", + "dependencies": { + "mime-db": "1.52.0" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, + "node_modules/ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==" + }, + "node_modules/negotiator": { + "version": "0.6.3", + "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz", + "integrity": "sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/nodemon": { + "version": "3.1.4", + "resolved": "https://registry.npmjs.org/nodemon/-/nodemon-3.1.4.tgz", + "integrity": "sha512-wjPBbFhtpJwmIeY2yP7QF+UKzPfltVGtfce1g/bB15/8vCGZj8uxD62b/b9M9/WVgme0NZudpownKN+c0plXlQ==", + "dev": true, + "dependencies": { + "chokidar": "^3.5.2", + "debug": "^4", + "ignore-by-default": "^1.0.1", + "minimatch": "^3.1.2", + "pstree.remy": "^1.1.8", + "semver": "^7.5.3", + "simple-update-notifier": "^2.0.0", + "supports-color": "^5.5.0", + "touch": "^3.1.0", + "undefsafe": "^2.0.5" + }, + "bin": { + "nodemon": "bin/nodemon.js" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/nodemon" + } + }, + "node_modules/nodemon/node_modules/debug": { + "version": "4.3.5", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.5.tgz", + "integrity": "sha512-pt0bNEmneDIvdL1Xsd9oDQ/wrQRkXDT4AUWlNZNPKvW5x/jyO9VFXkJUP07vQ2upmw5PlaITaPKc31jK13V+jg==", + "dev": true, + "dependencies": { + "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/nodemon/node_modules/ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true + }, + "node_modules/normalize-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", + "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/object-inspect": { + "version": "1.13.2", + "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.2.tgz", + "integrity": "sha512-IRZSRuzJiynemAXPYtPe5BoI/RESNYR7TYm50MC5Mqbd3Jmw5y790sErYw3V6SryFJD64b74qQQs9wn5Bg/k3g==", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/on-finished": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz", + "integrity": "sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==", + "dependencies": { + "ee-first": "1.1.1" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/parseurl": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", + "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/path-to-regexp": { + "version": "0.1.7", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz", + "integrity": "sha512-5DFkuoqlv1uYQKxy8omFBeJPQcdoE07Kv2sferDCrAq1ohOU+MSDswDIbnx3YAM60qIOnYa53wBhXW0EbMonrQ==" + }, + "node_modules/pg": { + "version": "8.12.0", + "resolved": "https://registry.npmjs.org/pg/-/pg-8.12.0.tgz", + "integrity": "sha512-A+LHUSnwnxrnL/tZ+OLfqR1SxLN3c/pgDztZ47Rpbsd4jUytsTtwQo/TLPRzPJMp/1pbhYVhH9cuSZLAajNfjQ==", + "dependencies": { + "pg-connection-string": "^2.6.4", + "pg-pool": "^3.6.2", + "pg-protocol": "^1.6.1", + "pg-types": "^2.1.0", + "pgpass": "1.x" + }, + "engines": { + "node": ">= 8.0.0" + }, + "optionalDependencies": { + "pg-cloudflare": "^1.1.1" + }, + "peerDependencies": { + "pg-native": ">=3.0.1" + }, + "peerDependenciesMeta": { + "pg-native": { + "optional": true + } + } + }, + "node_modules/pg-cloudflare": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/pg-cloudflare/-/pg-cloudflare-1.1.1.tgz", + "integrity": "sha512-xWPagP/4B6BgFO+EKz3JONXv3YDgvkbVrGw2mTo3D6tVDQRh1e7cqVGvyR3BE+eQgAvx1XhW/iEASj4/jCWl3Q==", + "optional": true + }, + "node_modules/pg-connection-string": { + "version": "2.6.4", + "resolved": "https://registry.npmjs.org/pg-connection-string/-/pg-connection-string-2.6.4.tgz", + "integrity": "sha512-v+Z7W/0EO707aNMaAEfiGnGL9sxxumwLl2fJvCQtMn9Fxsg+lPpPkdcyBSv/KFgpGdYkMfn+EI1Or2EHjpgLCA==" + }, + "node_modules/pg-int8": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/pg-int8/-/pg-int8-1.0.1.tgz", + "integrity": "sha512-WCtabS6t3c8SkpDBUlb1kjOs7l66xsGdKpIPZsg4wR+B3+u9UAum2odSsF9tnvxg80h4ZxLWMy4pRjOsFIqQpw==", + "engines": { + "node": ">=4.0.0" + } + }, + "node_modules/pg-pool": { + "version": "3.6.2", + "resolved": "https://registry.npmjs.org/pg-pool/-/pg-pool-3.6.2.tgz", + "integrity": "sha512-Htjbg8BlwXqSBQ9V8Vjtc+vzf/6fVUuak/3/XXKA9oxZprwW3IMDQTGHP+KDmVL7rtd+R1QjbnCFPuTHm3G4hg==", + "peerDependencies": { + "pg": ">=8.0" + } + }, + "node_modules/pg-protocol": { + "version": "1.6.1", + "resolved": "https://registry.npmjs.org/pg-protocol/-/pg-protocol-1.6.1.tgz", + "integrity": "sha512-jPIlvgoD63hrEuihvIg+tJhoGjUsLPn6poJY9N5CnlPd91c2T18T/9zBtLxZSb1EhYxBRoZJtzScCaWlYLtktg==" + }, + "node_modules/pg-types": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/pg-types/-/pg-types-2.2.0.tgz", + "integrity": "sha512-qTAAlrEsl8s4OiEQY69wDvcMIdQN6wdz5ojQiOy6YRMuynxenON0O5oCpJI6lshc6scgAY8qvJ2On/p+CXY0GA==", + "dependencies": { + "pg-int8": "1.0.1", + "postgres-array": "~2.0.0", + "postgres-bytea": "~1.0.0", + "postgres-date": "~1.0.4", + "postgres-interval": "^1.1.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/pgpass": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/pgpass/-/pgpass-1.0.5.tgz", + "integrity": "sha512-FdW9r/jQZhSeohs1Z3sI1yxFQNFvMcnmfuj4WBMUTxOrAyLMaTcE1aAMBiTlbMNaXvBCQuVi0R7hd8udDSP7ug==", + "dependencies": { + "split2": "^4.1.0" + } + }, + "node_modules/picomatch": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "dev": true, + "engines": { + "node": ">=8.6" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/postgres-array": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/postgres-array/-/postgres-array-2.0.0.tgz", + "integrity": "sha512-VpZrUqU5A69eQyW2c5CA1jtLecCsN2U/bD6VilrFDWq5+5UIEVO7nazS3TEcHf1zuPYO/sqGvUvW62g86RXZuA==", + "engines": { + "node": ">=4" + } + }, + "node_modules/postgres-bytea": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/postgres-bytea/-/postgres-bytea-1.0.0.tgz", + "integrity": "sha512-xy3pmLuQqRBZBXDULy7KbaitYqLcmxigw14Q5sj8QBVLqEwXfeybIKVWiqAXTlcvdvb0+xkOtDbfQMOf4lST1w==", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/postgres-date": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/postgres-date/-/postgres-date-1.0.7.tgz", + "integrity": "sha512-suDmjLVQg78nMK2UZ454hAG+OAW+HQPZ6n++TNDUX+L0+uUlLywnoxJKDou51Zm+zTCjrCl0Nq6J9C5hP9vK/Q==", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/postgres-interval": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/postgres-interval/-/postgres-interval-1.2.0.tgz", + "integrity": "sha512-9ZhXKM/rw350N1ovuWHbGxnGh/SNJ4cnxHiM0rxE4VN41wsg8P8zWn9hv/buK00RP4WvlOyr/RBDiptyxVbkZQ==", + "dependencies": { + "xtend": "^4.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/proxy-addr": { + "version": "2.0.7", + "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz", + "integrity": "sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==", + "dependencies": { + "forwarded": "0.2.0", + "ipaddr.js": "1.9.1" + }, + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/pstree.remy": { + "version": "1.1.8", + "resolved": "https://registry.npmjs.org/pstree.remy/-/pstree.remy-1.1.8.tgz", + "integrity": "sha512-77DZwxQmxKnu3aR542U+X8FypNzbfJ+C5XQDk3uWjWxn6151aIMGthWYRXTqT1E5oJvg+ljaa2OJi+VfvCOQ8w==", + "dev": true + }, + "node_modules/qs": { + "version": "6.11.0", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.11.0.tgz", + "integrity": "sha512-MvjoMCJwEarSbUYk5O+nmoSzSutSsTwF85zcHPQ9OrlFoZOYIjaqBAJIqIXjptyD5vThxGq52Xu/MaJzRkIk4Q==", + "dependencies": { + "side-channel": "^1.0.4" + }, + "engines": { + "node": ">=0.6" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/range-parser": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz", + "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/raw-body": { + "version": "2.5.2", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.2.tgz", + "integrity": "sha512-8zGqypfENjCIqGhgXToC8aB2r7YrBX+AQAfIPs/Mlk+BtPTztOvTS01NRW/3Eh60J+a48lt8qsCzirQ6loCVfA==", + "dependencies": { + "bytes": "3.1.2", + "http-errors": "2.0.0", + "iconv-lite": "0.4.24", + "unpipe": "1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/readdirp": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", + "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", + "dev": true, + "dependencies": { + "picomatch": "^2.2.1" + }, + "engines": { + "node": ">=8.10.0" + } + }, + "node_modules/safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, + "node_modules/safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" + }, + "node_modules/semver": { + "version": "7.6.2", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.2.tgz", + "integrity": "sha512-FNAIBWCx9qcRhoHcgcJ0gvU7SN1lYU2ZXuSfl04bSC5OpvDHFyJCjdNHomPXxjQlCBU67YW64PzY7/VIEH7F2w==", + "dev": true, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/send": { + "version": "0.18.0", + "resolved": "https://registry.npmjs.org/send/-/send-0.18.0.tgz", + "integrity": "sha512-qqWzuOjSFOuqPjFe4NOsMLafToQQwBSOEpS+FwEt3A2V3vKubTquT3vmLTQpFgMXp8AlFWFuP1qKaJZOtPpVXg==", + "dependencies": { + "debug": "2.6.9", + "depd": "2.0.0", + "destroy": "1.2.0", + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "etag": "~1.8.1", + "fresh": "0.5.2", + "http-errors": "2.0.0", + "mime": "1.6.0", + "ms": "2.1.3", + "on-finished": "2.4.1", + "range-parser": "~1.2.1", + "statuses": "2.0.1" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/send/node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==" + }, + "node_modules/serve-static": { + "version": "1.15.0", + "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.15.0.tgz", + "integrity": "sha512-XGuRDNjXUijsUL0vl6nSD7cwURuzEgglbOaFuZM9g3kwDXOWVTck0jLzjPzGD+TazWbboZYu52/9/XPdUgne9g==", + "dependencies": { + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "parseurl": "~1.3.3", + "send": "0.18.0" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/set-function-length": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/set-function-length/-/set-function-length-1.2.2.tgz", + "integrity": "sha512-pgRc4hJ4/sNjWCSS9AmnS40x3bNMDTknHgL5UaMBTMyJnU90EgWh1Rz+MC9eFu4BuN/UwZjKQuY/1v3rM7HMfg==", + "dependencies": { + "define-data-property": "^1.1.4", + "es-errors": "^1.3.0", + "function-bind": "^1.1.2", + "get-intrinsic": "^1.2.4", + "gopd": "^1.0.1", + "has-property-descriptors": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/setprototypeof": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz", + "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==" + }, + "node_modules/side-channel": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.6.tgz", + "integrity": "sha512-fDW/EZ6Q9RiO8eFG8Hj+7u/oW+XrPTIChwCOM2+th2A6OblDtYYIpve9m+KvI9Z4C9qSEXlaGR6bTEYHReuglA==", + "dependencies": { + "call-bind": "^1.0.7", + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.4", + "object-inspect": "^1.13.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/simple-update-notifier": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/simple-update-notifier/-/simple-update-notifier-2.0.0.tgz", + "integrity": "sha512-a2B9Y0KlNXl9u/vsW6sTIu9vGEpfKu2wRV6l1H3XEas/0gUIzGzBoP/IouTcUQbm9JWZLH3COxyn03TYlFax6w==", + "dev": true, + "dependencies": { + "semver": "^7.5.3" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/split2": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/split2/-/split2-4.2.0.tgz", + "integrity": "sha512-UcjcJOWknrNkF6PLX83qcHM6KHgVKNkV62Y8a5uYDVv9ydGQVwAHMKqHdJje1VTWpljG0WYpCDhrCdAOYH4TWg==", + "engines": { + "node": ">= 10.x" + } + }, + "node_modules/statuses": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz", + "integrity": "sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ==", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "dev": true, + "dependencies": { + "has-flag": "^3.0.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/to-regex-range": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", + "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "dev": true, + "dependencies": { + "is-number": "^7.0.0" + }, + "engines": { + "node": ">=8.0" + } + }, + "node_modules/toidentifier": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz", + "integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==", + "engines": { + "node": ">=0.6" + } + }, + "node_modules/touch": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/touch/-/touch-3.1.1.tgz", + "integrity": "sha512-r0eojU4bI8MnHr8c5bNo7lJDdI2qXlWWJk6a9EAFG7vbhTjElYhBVS3/miuE0uOuoLdb8Mc/rVfsmm6eo5o9GA==", + "dev": true, + "bin": { + "nodetouch": "bin/nodetouch.js" + } + }, + "node_modules/type-is": { + "version": "1.6.18", + "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz", + "integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==", + "dependencies": { + "media-typer": "0.3.0", + "mime-types": "~2.1.24" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/undefsafe": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/undefsafe/-/undefsafe-2.0.5.tgz", + "integrity": "sha512-WxONCrssBM8TSPRqN5EmsjVrsv4A8X12J4ArBiiayv3DyyG3ZlIg6yysuuSYdZsVz3TKcTg2fd//Ujd4CHV1iA==", + "dev": true + }, + "node_modules/unpipe": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", + "integrity": "sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/utils-merge": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", + "integrity": "sha512-pMZTvIkT1d+TFGvDOqodOclx0QWkkgi6Tdoa8gC8ffGAAqz9pzPTZWAybbsHHoED/ztMtkv/VoYTYyShUn81hA==", + "engines": { + "node": ">= 0.4.0" + } + }, + "node_modules/vary": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", + "integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/xtend": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz", + "integrity": "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==", + "engines": { + "node": ">=0.4" + } + } + } +} diff --git a/api/package.json b/api/package.json new file mode 100644 index 0000000..200d9cf --- /dev/null +++ b/api/package.json @@ -0,0 +1,19 @@ +{ + "name": "api", + "version": "1.0.0", + "main": "index.js", + "scripts": { + "start": "node index.js", + "dev": "nodemon index.js" + }, + "author": "Giovanni Martins ", + "license": "MIT", + "dependencies": { + "dotenv": "^16.4.5", + "express": "^4.19.2", + "pg": "^8.12.0" + }, + "devDependencies": { + "nodemon": "^3.1.4" + } +} diff --git a/api/routes/alerts.js b/api/routes/alerts.js new file mode 100644 index 0000000..7b45052 --- /dev/null +++ b/api/routes/alerts.js @@ -0,0 +1,24 @@ +const express = require('express') +const router = express.Router() + +router.get('/', (request, response) => { + response.send('Hello World Alerts') +}) + +router.get('/:id', (request, response) => { + response.send('Hello World Alerts') +}) + +router.post('/', (request, response) => { + response.send('Hello World Alerts') +}) + +router.put('/:id', (request, response) => { + response.send('Hello World Alerts') +}) + +router.delete('/:id', (request, response) => { + response.send('Hello World Alerts') +}) + +module.exports = router; diff --git a/api/routes/company.js b/api/routes/company.js new file mode 100644 index 0000000..24c41b1 --- /dev/null +++ b/api/routes/company.js @@ -0,0 +1,24 @@ +const express = require('express') +const router = express.Router() + +router.get('/', (request, response) => { + response.send('Hello World Company') +}) + +router.get('/:id', (request, response) => { + response.send('Hello World Company') +}) + +router.post('/', (request, response) => { + response.send('Hello World Company') +}) + +router.put('/:id', (request, response) => { + response.send('Hello World Company') +}) + +router.delete('/:id', (request, response) => { + response.send('Hello World Company') +}) + +module.exports = router; diff --git a/api/routes/history.js b/api/routes/history.js new file mode 100644 index 0000000..0977de5 --- /dev/null +++ b/api/routes/history.js @@ -0,0 +1,24 @@ +const express = require('express') +const router = express.Router() + +router.get('/', (request, response) => { + response.send('Hello World History') +}) + +router.get('/:id', (request, response) => { + response.send('Hello World History') +}) + +router.post('/', (request, response) => { + response.send('Hello World History') +}) + +router.put('/:id', (request, response) => { + response.send('Hello World History') +}) + +router.delete('/:id', (request, response) => { + response.send('Hello World History') +}) + +module.exports = router; diff --git a/api/routes/rule.js b/api/routes/rule.js new file mode 100644 index 0000000..8459ca8 --- /dev/null +++ b/api/routes/rule.js @@ -0,0 +1,24 @@ +const express = require('express') +const router = express.Router() + +router.get('/', (request, response) => { + response.send('Hello World Rule') +}) + +router.get('/:id', (request, response) => { + response.send('Hello World Rule') +}) + +router.post('/', (request, response) => { + response.send('Hello World Rule') +}) + +router.put('/:id', (request, response) => { + response.send('Hello World Rule') +}) + +router.delete('/:id', (request, response) => { + response.send('Hello World Rule') +}) + +module.exports = router; diff --git a/rest-server/Dockerfile b/rest-server/Dockerfile deleted file mode 100644 index 33272df..0000000 --- a/rest-server/Dockerfile +++ /dev/null @@ -1,12 +0,0 @@ -FROM perl:latest -MAINTAINER Heitor GouvĂȘa - -EXPOSE 80 - -WORKDIR /usr/src/app -COPY . /usr/src/app - -RUN curl -L http://cpanmin.us | perl - App::cpanminus -RUN cpanm Mojolicious::Lite Mojo::Util Mojo::JSON Mojo::UserAgent IO::Socket::SSL - -CMD ["perl", "app.pl", "daemon", "-m", "production", "-l", "http://*:80"] diff --git a/rest-server/README.md b/rest-server/README.md deleted file mode 100644 index a808c43..0000000 --- a/rest-server/README.md +++ /dev/null @@ -1,15 +0,0 @@ -# REST API of Uranus - - -### Summary - -A simple and basic REST API write at Perl - ---- - -### Setup - -``` - $ docker build -t uranus-rest-server . - $ docker run -d -p 80:80 --name rest-server uranus-rest-server -``` \ No newline at end of file diff --git a/rest-server/app.conf b/rest-server/app.conf deleted file mode 100644 index 3151134..0000000 --- a/rest-server/app.conf +++ /dev/null @@ -1,4 +0,0 @@ -{ - mysql => "mysql://root:mypassword\@192.168.15.11/uranus", - secrets => ["s3cret"] -} diff --git a/rest-server/app.pl b/rest-server/app.pl deleted file mode 100644 index b091f6b..0000000 --- a/rest-server/app.pl +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env perl - -use 5.018; -use strict; -use warnings; -use lib "./lib/"; - -require Mojolicious::Commands; - -Mojolicious::Commands -> start_app("App"); \ No newline at end of file diff --git a/rest-server/database/Dockerfile b/rest-server/database/Dockerfile deleted file mode 100644 index 8072825..0000000 --- a/rest-server/database/Dockerfile +++ /dev/null @@ -1,6 +0,0 @@ -FROM mariadb/server:latest -MAINTAINER Heitor GouvĂȘa - -EXPOSE 3306 - -COPY ./app.sql /docker-entrypoint-initdb.d/ \ No newline at end of file diff --git a/rest-server/database/README.md b/rest-server/database/README.md deleted file mode 100644 index f912e67..0000000 --- a/rest-server/database/README.md +++ /dev/null @@ -1,66 +0,0 @@ -# Uranus Database - -This database is responsible for storing all the information that is generated by the uranus crawlers and workers ecosystem, in an organized and easily accessible way. - ---- - -### Database Diagram - -![](/files/uranus_database_diagram.png) - ---- - -### Data Catalog - -Table: COMPANY -COLUMN | TYPE | DESCRIPTION ----- | ---- | ---- -ID | INT - NOT NULL - AUTO INCREMENT | Unique identifier of each company within the platform -NAME | VARCHAR - NOT NULL | Company Name -PHONE | INT - DEFAULT NULL | Company manager's phone number -MANAGER | STRING - DEFAULT NULL | Name of the Manager/Company contact point -STATUS | INT - NOT NULL | Flag that references whether the company is active (1) or not (0) - -Table: RULE -COLUMN | TYPE | DESCRIPTION ----- | ---- | ---- -ID | INT - NOT NULL - AUTO INCREMENT | Unique identifier for each rule -ID_COMPANY | INT - NOT NULL - FK | Identifier that relates rule and company -STRING | VARCHAR - NOT NULL | Value to be sought by crawlers -SOURCE | VARCHAR - NOT NULL | Channel to be monitored -FILTER | LONGTEXT - NOT NULL | Type of filter to be applied -SCORE | INT - NOT NULL | Value regarding the criticality of the rule -DESCRIPTION | VARCHER - NOT NULL | Reserved area to describe the objective to be achieved with the rule -STATUS | INT - NOT NULL | Flag that references whether the rule is active (1) or not (0) - -Table: ALERT -COLUMN | TYPE | DESCRIPTION ----- | ---- | ---- -ID | INT - NOT NULL - AUTO INCREMENT | Unique identifier for each alert -ID_COMPANY | INT - NOT NULL - FK | Identifier that links the history of the alert with the company -DATETIME | DATE TIME - NOT NULL | Date and time the alert was inserted into the database -STATUS | INT - NOT NULL | Flag that references whether the alert is active (1) or not (0) -NOTIFICATION | INT - NOT NULL | Flag that references whether the notification was sent (1) or not (0) -CONTENT | LONGTEXT - NOT NULL | Content/evidence captured by the crawler -HASH | CHAR(32) - NOT NULL | Unique hash that references the alert - -Table: HISTORY -COLUMN | TYPE | DESCRIPTION ----- | ---- | ---- -ID | INT - NOT NULL - AUTO INCREMENT | Unique identifier for each activity in the history -ID_COMPANY | INT - NOT NULL - FK | Identifier that links event history with the company -ENGINE | VARCHAR - NOT NULL | Engine that ran -DATETIME | DATE TIME - NOT NULL | Date and time the activity was performed -RULE_QTT | INT - NOT NULL | Number of rules executed -EVENT_QTT | INT - NOT NULL | Number of events generated - ---- - -### Setup - -``` - $ docker build --rm --squash -t uranus-database . - $ docker run -d -p 3306:3306 --name database -e MARIADB_ROOT_PASSWORD=PasswordHere uranus-database -``` - ---- \ No newline at end of file diff --git a/rest-server/database/app.sql b/rest-server/database/app.sql deleted file mode 100644 index 92abf5a..0000000 --- a/rest-server/database/app.sql +++ /dev/null @@ -1,55 +0,0 @@ -CREATE DATABASE `uranus`; - -CREATE TABLE `uranus`.`company` ( - `ID` int(10) NOT NULL AUTO_INCREMENT, - `NAME` varchar(62) NOT NULL, - `EMAIL` varchar(50) NOT NULL, - `PHONE` int(14) DEFAULT NULL, - `MANAGER` varchar(62) DEFAULT NULL, - `STATUS` int(1) NOT NULL, - PRIMARY KEY (`ID`), - UNIQUE KEY `ID_UNIQUE` (`ID`) -) ENGINE=InnoDB AUTO_INCREMENT=3; - -CREATE TABLE `uranus`.`rule` ( - `ID` int(10) NOT NULL AUTO_INCREMENT, - `ID_COMPANY` int(10) NOT NULL, - `STRING` varchar(60) NOT NULL, - `SOURCE` varchar(32) NOT NULL, - `FILTER` longtext NOT NULL, - `SCORE` varchar(10) NOT NULL, - `DESCRIPTION` varchar(64) NOT NULL, - `STATUS` int(1) NOT NULL, - PRIMARY KEY (`ID`), - UNIQUE KEY `ID_UNIQUE` (`ID`), - KEY `ID_COMPANY_idx` (`ID_COMPANY`), - CONSTRAINT `FK_ID_COMPANY_I` FOREIGN KEY (`ID_COMPANY`) REFERENCES `company` (`ID`) ON DELETE NO ACTION ON UPDATE NO ACTION -) ENGINE=InnoDB AUTO_INCREMENT=3; - -CREATE TABLE `uranus`.`alert` ( - `ID` int(10) NOT NULL AUTO_INCREMENT, - `ID_COMPANY` int(10) NOT NULL, - `CONTENT` longtext NOT NULL, - `DATETIME` datetime NOT NULL DEFAULT current_timestamp(), - `STATUS` int(1) NOT NULL, - `NOTIFICATION` int(1) NOT NULL, - `HASH` char(32) NOT NULL, - PRIMARY KEY (`ID`), - UNIQUE KEY `ID_UNIQUE` (`ID`), - UNIQUE KEY `HASH_UNIQUE` (`HASH`), - KEY `ID_COMPANY_idx` (`ID_COMPANY`), - CONSTRAINT `FK_ID_COMPANY_II` FOREIGN KEY (`ID_COMPANY`) REFERENCES `company` (`ID`) ON DELETE NO ACTION ON UPDATE NO ACTION -) ENGINE=InnoDB AUTO_INCREMENT=3; - -CREATE TABLE `uranus`.`history` ( - `ID` int(10) NOT NULL AUTO_INCREMENT, - `ID_COMPANY` int(10) NOT NULL, - `DATETIME` datetime NOT NULL DEFAULT current_timestamp(), - `ENGINE` varchar(32) NOT NULL, - `RULE_QTT` int(10) NOT NULL, - `EVENT_QTT` int(10) NOT NULL, - PRIMARY KEY (`ID`), - UNIQUE KEY `ID_UNIQUE` (`ID`), - KEY `ID_COMPANY_idx` (`ID_COMPANY`), - CONSTRAINT `FK_ID_COMPANY_III` FOREIGN KEY (`ID_COMPANY`) REFERENCES `company` (`ID`) ON DELETE NO ACTION ON UPDATE NO ACTION -) ENGINE=InnoDB AUTO_INCREMENT=3; \ No newline at end of file diff --git a/rest-server/lib/App.pm b/rest-server/lib/App.pm deleted file mode 100644 index dca0389..0000000 --- a/rest-server/lib/App.pm +++ /dev/null @@ -1,67 +0,0 @@ -package App; - -use strict; -use warnings; -use Mojo::mysql; -use App::Helpers; -use App::Routes; -use App::Model::Company; -use App::Model::Rule; -use App::Model::Alert; -use App::Model::History; -use Mojo::Base "Mojolicious"; - -sub startup { - my ($self) = @_; - - $self -> plugin("Config"); - $self -> secrets($self -> config("secrets")); - - $self -> helper ( - mysql => sub { - state $mysql = Mojo::mysql -> new ( - shift -> config("mysql") - ) - } - ); - - $self -> helper ( - company => sub { - state $company = App::Model::Company -> new ( - mysql => shift -> mysql - ) - } - ); - - $self -> helper( - rule => sub { - state $rule = App::Model::Rule -> new ( - mysql => shift -> mysql - ) - } - ); - - $self -> helper ( - alert => sub { - state $alert = App::Model::Alert -> new ( - mysql => shift -> mysql - ) - } - ); - - $self -> helper ( - history => sub { - state $history = App::Model::History -> new ( - mysql => shift -> mysql - ) - } - ); - - my $path = $self -> home -> child("database", "app.sql"); - $self -> mysql -> auto_migrate(1) -> migrations -> name("app") -> from_file($path); - - my $routes = App::Routes -> new(routes => $self -> routes); - $routes -> register; -} - -1; diff --git a/rest-server/lib/App/Controller/Alert.pm b/rest-server/lib/App/Controller/Alert.pm deleted file mode 100644 index 625c1e3..0000000 --- a/rest-server/lib/App/Controller/Alert.pm +++ /dev/null @@ -1,86 +0,0 @@ -package App::Controller::Alert; - -use strict; -use warnings; -use Mojo::Base "Mojolicious::Controller"; - -sub index { - my ($self) = @_; - - $self -> render ( - json => $self -> alert -> all - ); -} - -sub show { - my ($self) = @_; - - $self -> render ( - json => $self -> alert -> find ( - $self -> param("id") - ) - ); -} - -sub remove { - my ($self) = @_; - - $self -> alert -> remove ( - $self -> param("id") - ); - - $self -> render ( - json => $self -> alert -> find ( - $self -> param("id") - ) - ); -} - -sub store { - my ($self) = @_; - - my $validation = $self -> _validation(); - - return $self -> render ( - action => "create", - alert => {} - ) if $validation -> has_error; - - my $id = $self -> alert -> add($validation -> output); - - $self -> redirect_to("/alert"); -} - -sub update { - my ($self) = @_; - - my $validation = $self -> _validation(); - - return $self -> render ( - action => "edit", - alert => {} - ) if $validation -> has_error; - - my $id = $self -> param("id"); - $self -> alert -> save($id, $validation -> output); - - $self -> render ( - json => $self -> alert -> all - ); - - # $self -> redirect_to("posts"); -} - -sub _validation { - my ($self) = @_; - - my $validation = $self -> validation; - - $validation -> required("email"); - $validation -> required("name"); - $validation -> required("status"); - - return $validation; -} - -1; diff --git a/rest-server/lib/App/Controller/Company.pm b/rest-server/lib/App/Controller/Company.pm deleted file mode 100644 index ea005c1..0000000 --- a/rest-server/lib/App/Controller/Company.pm +++ /dev/null @@ -1,104 +0,0 @@ -package App::Controller::Company; - -use strict; -use warnings; -use Mojo::Base "Mojolicious::Controller"; - -sub index { - my ($self) = @_; - - $self -> render ( - json => $self -> company -> all, - status => 200 - ); -} - -sub show { - my ($self) = @_; - - $self -> render ( - json => $self -> company -> find ($self -> param("id")), - status => 200 - ); -} - -sub remove { - my ($self) = @_; - - $self -> company -> remove ( - $self -> param("id") - ); - - $self -> render ( - json => $self -> company -> find ( - $self -> company("id") - ) - ); -} - -sub store { - my ($self) = @_; - - my $request = $self -> req -> json; - - # say Dumper($self -> req -> json); - - my $validation = $self -> validation; - - # $validation -> required("email"); - # $validation -> required("name"); - # $validation -> required("manager"); - # $validation -> required("status"); - - if ($validation -> has_error()) { - return $self -> render ( - json => "error" - ); - } - - my $email = $self -> param("email"); - my $name = $self -> param("name"); - my $manager = $self -> param("manager"); - my $status = $self -> param("status"); - my $phone = $self -> param("phone"); - - $self -> company -> add ( - $email, $validation -> output - ); - - $self -> redirect_to("/company"); -} - -sub update { - my ($self) = @_; - - my $id = $self -> param("id"); - my $email = $self -> param("email"); - my $name = $self -> param("name"); - my $manager = $self -> param("manager"); - my $status = $self -> param("status"); - my $phone = $self -> param("phone"); - - $self -> company -> save ( - $id, $email, $name, $manager, $status, $phone - ); - - $self -> render ( - json => $self -> company -> all - ); -} - -sub _validation { - my ($self) = @_; - - my $validation = $self -> validation(); - - $validation -> required("email"); - $validation -> required("name"); - $validation -> required("status"); - $validation -> required("manager"); - - return $validation; -} - -1; \ No newline at end of file diff --git a/rest-server/lib/App/Controller/History.pm b/rest-server/lib/App/Controller/History.pm deleted file mode 100644 index 33b0c40..0000000 --- a/rest-server/lib/App/Controller/History.pm +++ /dev/null @@ -1,86 +0,0 @@ -package App::Controller::History; - -use strict; -use warnings; -use Mojo::Base "Mojolicious::Controller"; - -sub index { - my ($self) = @_; - - $self -> render ( - json => $self -> history -> all - ); -} - -sub show { - my ($self) = @_; - - $self -> render ( - json => $self -> history -> find ( - $self -> param("id") - ) - ); -} - -sub remove { - my ($self) = @_; - - $self -> history -> remove ( - $self -> param("id") - ); - - $self -> render ( - json => $self -> history -> find ( - $self -> param("id") - ) - ); -} - -sub store { - my ($self) = @_; - - my $validation = $self -> _validation(); - - return $self -> render ( - action => "create", - history => {} - ) if $validation -> has_error; - - my $id = $self -> history -> add($validation -> output); - - $self -> redirect_to("/history"); -} - -sub update { - my ($self) = @_; - - my $validation = $self -> _validation(); - - return $self -> render ( - action => "edit", - alert => {} - ) if $validation -> has_error; - - my $id = $self -> param("id"); - $self -> history -> save($id, $validation -> output); - - $self -> render ( - json => $self -> history -> all - ); - - # $self -> redirect_to("posts"); -} - -sub _validation { - my ($self) = @_; - - my $validation = $self -> validation; - - $validation -> required("email"); - $validation -> required("name"); - $validation -> required("status"); - - return $validation; -} - -1; diff --git a/rest-server/lib/App/Controller/Rule.pm b/rest-server/lib/App/Controller/Rule.pm deleted file mode 100644 index 076edf9..0000000 --- a/rest-server/lib/App/Controller/Rule.pm +++ /dev/null @@ -1,86 +0,0 @@ -package App::Controller::Rule; - -use strict; -use warnings; -use Mojo::Base "Mojolicious::Controller"; - -sub index { - my ($self) = @_; - - $self -> render ( - json => $self -> rule -> all - ); -} - -sub show { - my ($self) = @_; - - $self -> render ( - json => $self -> rule -> find ( - $self -> param("id") - ) - ); -} - -sub remove { - my ($self) = @_; - - $self -> rule -> remove ( - $self -> param("id") - ); - - $self -> render ( - json => $self -> rule -> find ( - $self -> param("id") - ) - ); -} - -sub store { - my ($self) = @_; - - my $validation = $self -> _validation(); - - return $self -> render ( - action => "create", - rule => {} - ) if $validation -> has_error; - - my $id = $self -> rule -> add($validation -> output); - - $self -> redirect_to("/rule"); -} - -sub update { - my ($self) = @_; - - my $validation = $self -> _validation(); - - return $self -> render ( - action => "edit", - alert => {} - ) if $validation -> has_error; - - my $id = $self -> param("id"); - $self -> rule -> save($id, $validation -> output); - - $self -> render ( - json => $self -> rule -> all - ); - - # $self -> redirect_to("posts"); -} - -sub _validation { - my ($self) = @_; - - my $validation = $self -> validation; - - $validation -> required("email"); - $validation -> required("name"); - $validation -> required("status"); - - return $validation; -} - -1; diff --git a/rest-server/lib/App/Helpers.pm b/rest-server/lib/App/Helpers.pm deleted file mode 100644 index 64ec797..0000000 --- a/rest-server/lib/App/Helpers.pm +++ /dev/null @@ -1,13 +0,0 @@ -package App::Helpers; - -use strict; -use warnings; -use Mojo::Base -base; - -has "helpers"; - -sub register { - my ($self) = @_; -} - -1; \ No newline at end of file diff --git a/rest-server/lib/App/Model/Alert.pm b/rest-server/lib/App/Model/Alert.pm deleted file mode 100644 index 74e9994..0000000 --- a/rest-server/lib/App/Model/Alert.pm +++ /dev/null @@ -1,57 +0,0 @@ -package App::Model::Alert; - -use strict; -use warnings; -use Mojo::Base -base; - -has "mariadb"; - -sub add { - my ($self, $alert) = @_; - - return $self -> mariadb -> db -> insert ( - "alert", $alert, { - returning => "id" - } - ) -> hash -> {id}; -} - -sub all { - my ($self) = @_; - - $self -> mariadb -> db -> select ( - "alert" - ) -> hashes -> to_array; -} - -sub find { - my ($self, $id) = @_; - - return $self -> mariadb -> db -> select ( - "alert", undef, { - id => $id - } - ) -> hash; -} - -sub remove { - my ($self, $id) = @_; - - $self -> mariadb -> db -> delete ( - "alert", { - id => $id - } - ); -} - -sub save { - my ($self, $id, $alert) = @_; - - $self -> mariadb -> db -> update ( - "alert", $alert, { - id => $id - } - ); -} - -1; diff --git a/rest-server/lib/App/Model/Company.pm b/rest-server/lib/App/Model/Company.pm deleted file mode 100644 index 8fbe72d..0000000 --- a/rest-server/lib/App/Model/Company.pm +++ /dev/null @@ -1,57 +0,0 @@ -package App::Model::Company; - -use strict; -use warnings; -use Mojo::Base -base; - -has "mysql"; - -sub add { - my ($self, $company) = @_; - - $self -> mysql -> db -> insert ( - "company", $company, { - returning => "id" - } - ) -> hash -> {id}; -} - -sub all { - my ($self) = @_; - - return $self -> mysql -> db -> select ( - "company" - ) -> hashes -> to_array; -} - -sub find { - my ($self, $id) = @_; - - return $self -> mysql -> db -> select ( - "company", undef, { - id => $id - } - ) -> hash; -} - -sub remove { - my ($self, $id) = @_; - - return $self -> mysql -> db -> delete ( - "company", { - id => $id - } - ); -} - -sub save { - my ($self, $id, $email, $name, $manager, $status, $phone) = @_; - - $self -> mysql -> db -> update ( - "company", $email, { - id => $id - } - ); -} - -1; \ No newline at end of file diff --git a/rest-server/lib/App/Model/History.pm b/rest-server/lib/App/Model/History.pm deleted file mode 100644 index 44dea0a..0000000 --- a/rest-server/lib/App/Model/History.pm +++ /dev/null @@ -1,57 +0,0 @@ -package App::Model::History; - -use strict; -use warnings; -use Mojo::Base -base; - -has "mysql"; - -sub add { - my ($self, $history) = @_; - - return $self -> mysql -> db -> insert ( - "history", $history, { - returning => "id" - } - ) -> hash -> {id}; -} - -sub all { - my ($self) = @_; - - $self -> mysql -> db -> select ( - "history" - ) -> hashes -> to_array; -} - -sub find { - my ($self, $id) = @_; - - return $self -> mysql -> db -> select ( - "history", undef, { - id => $id - } - ) -> hash; -} - -sub remove { - my ($self, $id) = @_; - - $self -> mysql -> db -> delete ( - "history", { - id => $id - } - ); -} - -sub save { - my ($self, $id, $history) = @_; - - $self -> mysql -> db -> update ( - "history", $history, { - id => $id - } - ); -} - -1; diff --git a/rest-server/lib/App/Model/Rule.pm b/rest-server/lib/App/Model/Rule.pm deleted file mode 100644 index f769e8e..0000000 --- a/rest-server/lib/App/Model/Rule.pm +++ /dev/null @@ -1,57 +0,0 @@ -package App::Model::Rule; - -use strict; -use warnings; -use Mojo::Base -base; - -has "mysql"; - -sub add { - my ($self, $rule) = @_; - - return $self -> mysql -> db -> insert ( - "rule", $rule, { - returning => "id" - } - ) -> hash -> {id}; -} - -sub all { - my ($self) = @_; - - $self -> mysql -> db -> select ( - "rule" - ) -> hashes -> to_array; -} - -sub find { - my ($self, $id) = @_; - - return $self -> mysql -> db -> select ( - "rule", undef, { - id => $id - } - ) -> hash; -} - -sub remove { - my ($self, $id) = @_; - - $self -> mysql -> db -> delete ( - "rule", { - id => $id - } - ); -} - -sub save { - my ($self, $id, $rule) = @_; - - $self -> mysql -> db -> update ( - "rule", $rule, { - id => $id - } - ); -} - -1; diff --git a/rest-server/lib/App/Routes.pm b/rest-server/lib/App/Routes.pm deleted file mode 100644 index ed008ab..0000000 --- a/rest-server/lib/App/Routes.pm +++ /dev/null @@ -1,43 +0,0 @@ -package App::Routes; - -use strict; -use warnings; -use Mojo::Base -base; - -has "routes"; - -sub register { - my ($self) = @_; - - my $routes = $self -> routes(); - - $routes -> get("/" => sub { - shift -> redirect_to("/company") - }); - - $routes -> get("/company") -> to("company#index"); - $routes -> get("/company/:id") -> to ("company#show"); - $routes -> post("/company") -> to ("company#store"); - $routes -> put("/company/:id") -> to("company#update"); - $routes -> delete("/company/:id") -> to("company#remove"); - - $routes -> get("/rule") -> to("rule#index"); - $routes -> get("/rule/:id") -> to ("rule#show"); - $routes -> post("/rule") -> to ("rule#store"); - $routes -> put("/rule/:id") -> to("rule#update"); - $routes -> delete("/rule/:id") -> to("rule#remove"); - - $routes -> get("/alert") -> to("alert#index"); - $routes -> get("/alert/:id") -> to ("alert#show"); - $routes -> post("/alert") -> to ("alert#store"); - $routes -> put("/alert/:id") -> to("alert#update"); - $routes -> delete("/alert/:id") -> to("alert#remove"); - - $routes -> get("/history") -> to("history#index"); - $routes -> get("/history/:id") -> to ("history#show"); - $routes -> post("/history") -> to ("history#store"); - $routes -> put("/history/:id") -> to("history#update"); - $routes -> delete("/history/:id") -> to("history#remove"); -} - -1; \ No newline at end of file