refactor dashboard api.

This commit is contained in:
Simon Larsen
2022-07-07 20:35:00 +01:00
parent 1e2592202b
commit d3fc227c40
7 changed files with 65 additions and 156 deletions

View File

@@ -1 +0,0 @@
{"manager":"oneuptime-gl-manager","configDir":"./greenlock.d"}

View File

@@ -1,4 +0,0 @@
{
"include": "test",
"exclude": "backend"
}

View File

@@ -1,5 +1,5 @@
#
# OneUptime-backend Dockerfile
# OneUptime-DashboardAPI Dockerfile
#
# Pull base image nodejs image.
@@ -41,9 +41,6 @@ RUN mkdir /usr/src/app
WORKDIR /usr/src/app
# Install trivy for container scanning
RUN curl -sfL https://raw.githubusercontent.com/aquasecurity/trivy/master/contrib/install.sh | sh -s -- -b /usr/local/bin
# Install app dependencies
COPY ./DashboardAPI/package*.json /usr/src/app/
RUN npm install

View File

@@ -1,5 +1,5 @@
#
# OneUptime-backend Dockerfile
# OneUptime-DashboardAPI Dockerfile
#
# Pull base image nodejs image.
@@ -35,27 +35,18 @@ RUN npm install
COPY ./CommonServer /usr/src/CommonServer
RUN npm run compile
#SET ENV Variables
WORKDIR /usr/src/app
# Install trivy for container scanning
RUN curl -sfL https://raw.githubusercontent.com/aquasecurity/trivy/master/contrib/install.sh | sh -s -- -b /usr/local/bin
WORKDIR /usr/src/app/
# Install app dependencies
RUN cd /usr/src/app
RUN mkdir -p greenlock.d || echo "Directory already exists"
# Copy package.json files
COPY ./DashboardAPI/package.json /usr/src/app/package.json
COPY ./DashboardAPI/package-lock.json /usr/src/app/package-lock.json
COPY ./DashboardAPI/package*.json /usr/src/app/
RUN npm install
RUN npm install -g ts-node
# Bundle app source
COPY ./DashboardAPI /usr/src/app
# Expose ports.
# - 3002: OneUptime-backend
# - 3002: OneUptime-DashboardAPI
EXPOSE 3002
EXPOSE 9229

View File

@@ -1,10 +0,0 @@
# Changes to Production DB
- Make current Project Admin to Project Owners.
- Add a default Sub Project to every Project.
# ToDo:
- Add Sub Projects in Alerts.
- Add Sub Projects in Incidents.
- Add Monitor name when you create incidents.

View File

@@ -1,98 +1,28 @@
{
"name": "oneuptime-backend",
"version": "3.0.0",
"private": false,
"type": "module",
"dependencies": {
"airtable": "^0.11.2",
"async-mutex": "^0.3.2",
"axios": "^0.26.1",
"bcrypt": "^5.0.1",
"body-parser": "^1.19.2",
"cheerio": "^1.0.0-rc.10",
"CommonServer": "file:../CommonServer",
"Common": "file:../Common",
"cors": "^2.8.5",
"cross-env": "^7.0.3",
"crypto-js": "^4.1.1",
"dotenv": "^16.0.0",
"date-fns": "^2.28.0",
"dompurify": "^2.3.6",
"ejs": "^3.1.6",
"express": "^4.17.3",
"express-rate-limit": "^6.3.0",
"express-request-id": "^2.0.1",
"geoip-lite": "^1.4.4",
"greenlock": "^4.0.4",
"gridfs-stream": "^1.1.1",
"ipaddr.js": "^2.0.1",
"iplocation": "^7.2.0",
"js-base64": "^3.7.2",
"jsdom": "^19.0.0",
"jsonwebtoken": "^8.5.1",
"jstoxml": "^3.2.0",
"lodash": "^4.17.21",
"moment": "^2.29.2",
"moment-timezone": "^0.5.34",
"mongoose": "^6.2.7",
"morgan": "^1.10.0",
"multer": "^1.4.4",
"multer-gridfs-storage": "^5.0.2",
"nanoid": "^3.3.1",
"node-cron": "^3.0.0",
"node-device-detector": "^1.4.4",
"node-html-parser": "^5.3.3",
"nodemailer": "^6.7.3",
"nodemailer-express-handlebars": "^5.0.0",
"oneuptime-acme-http-01": "^4.0.43",
"oneuptime-gl-manager": "^4.0.43",
"oneuptime-le-store": "^4.0.43",
"otplib": "^12.0.1",
"p-iteration": "^1.1.8",
"psl": "^1.8.0",
"query-string": "^7.1.1",
"rand-token": "^1.0.1",
"rate-limit-redis": "^3.0.1",
"redis": "^4.0.4",
"request": "^2.88.2",
"saml2-js": "^3.0.1",
"slugify": "^1.6.5",
"socket.io": "^4.4.1",
"socket.io-redis": "^6.1.1",
"speakeasy": "^2.0.0",
"stripe": "^8.210.0",
"twilio": "^3.75.1",
"urldecode": "^1.0.1",
"uuid": "^8.3.2",
"valid-url": "^1.0.9",
"vm2": "^3.9.9",
"web-push": "^3.4.5",
"winston": "^3.6.0",
"winston-logstash-transport": "^2.0.0",
"winston-slack-webhook-transport": "^2.1.0"
},
"name": "dashboard-api",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "ts-node Index.ts",
"compile": "tsc",
"dev": "nodemon",
"test": "nyc --reporter=lcov --reporter=text mocha --exit test/index.ts",
"enterprise-test": "IS_TESTING=true nyc --reporter=lcov --reporter=text mocha --exit test/enterprise.js",
"audit": "npm audit --audit-level=low",
"preinstall": "npx npm-force-resolutions || echo 'No package-lock.json file. Skipping force resolutions'",
"dep-check": "depcheck ./ --skip-missing=true --ignores='ejs,oneuptime-acme-http-01,oneuptime-gl-manager,oneuptime-le-store'"
"start": "ts-node Index.ts",
"compile": "tsc",
"dev": "nodemon",
"audit": "npm audit --audit-level=low",
"dep-check": "depcheck ./ --skip-missing=true",
"test": "jest"
},
"author": "",
"license": "ISC",
"dependencies": {
"Common": "file:../Common",
"CommonServer": "file:../CommonServer",
"ejs": "^3.1.8"
},
"devDependencies": {
"chai": "^4.3.6",
"chai-http": "^4.3.0",
"chai-subset": "^1.6.0",
"depcheck": "^1.4.3",
"mocha": "^9.2.2",
"npm-force-resolutions": "0.0.10",
"nyc": "^15.1.0",
"sinon": "^13.0.1",
"ts-node-dev": "^1.1.8"
},
"resolutions": {
"xml-crypto": "2.0.0"
"@types/jest": "^27.5.0",
"@types/node": "^17.0.31",
"jest": "^28.1.0",
"ts-jest": "^28.0.2"
}
}
}

View File

@@ -314,32 +314,38 @@ services:
# - /usr/src/CommonUI/node_modules/
# - /usr/src/CommonServer/node_modules/
# dashboard-api:
# ports:
# - '3002:3002' # Service Port.
# - '9232:9229' # Debugging port.
# build:
# network: host
# context: .
# dockerfile: ./DashboardAPI/Dockerfile.dev
# env_file:
# - ./Common/.env
# - ./CommonServer/.env
# - ./DashboardAPI/.env
# environment: *common-variables
# depends_on:
# - redis
# volumes:
# - ./DashboardAPI:/usr/src/app
# # Use node modules of the container and not host system.
# # https://stackoverflow.com/questions/29181032/add-a-volume-to-docker-but-exclude-a-sub-folder
# - /usr/src/app/node_modules/
# - ./Common:/usr/src/Common
# - ./CommonServer:/usr/src/CommonServer
# - ./CommonUI:/usr/src/CommonUI
# - /usr/src/Common/node_modules/
# - /usr/src/CommonUI/node_modules/
# - /usr/src/CommonServer/node_modules/
dashboard-api:
ports:
- '3002:3002'
- '9232:9229' # Debugging port.
build:
network: host
context: .
dockerfile: ./DashboardAPI/Dockerfile.dev
env_file:
- ./Common/.env
- ./CommonServer/.env
- ./DashboardAPI/.env
environment: *common-variables
depends_on:
- redis
- postgres
- mail
links:
- redis
- postgres
- mail
volumes:
- ./DashboardAPI:/usr/src/app
# Use node modules of the container and not host system.
# https://stackoverflow.com/questions/29181032/add-a-volume-to-docker-but-exclude-a-sub-folder
- /usr/src/app/node_modules/
- ./Common:/usr/src/Common
- ./CommonServer:/usr/src/CommonServer
- ./CommonUI:/usr/src/CommonUI
- /usr/src/Common/node_modules/
- /usr/src/CommonUI/node_modules/
- /usr/src/CommonServer/node_modules/
identity:
ports: