diff --git a/Alert/.env b/Alert/.env index 59b4c3f258..136f2ffe55 100644 --- a/Alert/.env +++ b/Alert/.env @@ -1 +1 @@ -ONEUPTIME_SECRET=ae60cf8f0cec2df8d05aaf0b \ No newline at end of file +ONEUPTIME_SECRET=fd57b59aa8f3f516d2f6cb06 \ No newline at end of file diff --git a/CommonServer/API/StatusAPI.ts b/CommonServer/API/StatusAPI.ts index ebf3fc473a..71d7939eeb 100644 --- a/CommonServer/API/StatusAPI.ts +++ b/CommonServer/API/StatusAPI.ts @@ -13,7 +13,7 @@ router.get('/', (_req: ExpressRequest, res: ExpressResponse) => { // General status router.get('/status', (_req: ExpressRequest, res: ExpressResponse) => { - res.send({ status: 'status' }); + res.send({ status: 'ok' }); }); //Healthy probe diff --git a/CommonServer/API/StatusPageAPI.ts b/CommonServer/API/StatusPageAPI.ts index 22c8e1938e..ba942ac67e 100644 --- a/CommonServer/API/StatusPageAPI.ts +++ b/CommonServer/API/StatusPageAPI.ts @@ -51,6 +51,9 @@ import ScheduledMaintenanceStateTimelineService from '../Services/ScheduledMaint import DatabaseCommonInteractionProps from 'Common/Types/Database/DatabaseCommonInteractionProps'; import Query from '../Types/Database/Query'; import JSONFunctions from 'Common/Types/JSONFunctions'; +import GreenlockChallenge from 'Model/Models/GreenlockChallenge'; +import GreenlockChallengeService from '../Services/GreenlockChallengeService'; +import NotFoundException from 'Common/Types/Exception/NotFoundException'; export default class StatusPageAPI extends BaseAPI< StatusPage, @@ -59,6 +62,75 @@ export default class StatusPageAPI extends BaseAPI< public constructor() { super(StatusPage, StatusPageService); + // CNAME verification api + this.router.get( + `${new this.entityType().getCrudApiPath()?.toString()}/status-page-api/cname-verification/:token`, + async (req: ExpressRequest, res: ExpressResponse) => { + const host: string | undefined = req.get('host'); + + if (!host) { + throw new BadDataException('Host not found'); + } + + const domain: StatusPageDomain | null = + await StatusPageDomainService.findOneBy({ + query: { + cnameVerificationToken: req.params['token'] as string, + fullDomain: host, + }, + select: { + _id: true, + }, + props: { + isRoot: true, + }, + }); + + if (!domain) { + return Response.sendErrorResponse( + req, + res, + new BadDataException('Invalid token.') + ); + } + + return Response.sendEmptyResponse(req, res); + } + ); + + // ACME Challenge Validation. + this.router.get( + `${new this.entityType().getCrudApiPath()?.toString()}/.well-known/acme-challenge/:token`, + async (req: ExpressRequest, res: ExpressResponse) => { + const challenge: GreenlockChallenge | null = + await GreenlockChallengeService.findOneBy({ + query: { + token: req.params['token'] as string, + }, + select: { + challenge: true, + }, + props: { + isRoot: true, + }, + }); + + if (!challenge) { + return Response.sendErrorResponse( + req, + res, + new NotFoundException('Challenge not found') + ); + } + + return Response.sendTextResponse( + req, + res, + challenge.challenge as string + ); + } + ); + this.router.post( `${new this.entityType().getCrudApiPath()?.toString()}/domain`, UserMiddleware.getUserMiddleware, diff --git a/Home/Index.ts b/Home/Index.ts index 739cb498ef..08be15163f 100755 --- a/Home/Index.ts +++ b/Home/Index.ts @@ -121,10 +121,6 @@ app.get( } ); -app.get('/status', (_req: ExpressRequest, res: ExpressResponse) => { - res.redirect('https://status.oneuptime.com'); -}); - app.get( '/product/uptime-monitoring', (_req: ExpressRequest, res: ExpressResponse) => { diff --git a/Nginx/default.tpl.conf b/Nginx/default.tpl.conf index 4f622e4873..6ad5f59f06 100644 --- a/Nginx/default.tpl.conf +++ b/Nginx/default.tpl.conf @@ -22,10 +22,6 @@ upstream status-page { server status-page:3105 weight=10 max_fails=3 fail_timeout=30s; } -upstream status-page-api { - server status-page:3106 weight=10 max_fails=3 fail_timeout=30s; -} - upstream home { server home:1444 weight=10 max_fails=3 fail_timeout=30s; } @@ -94,7 +90,7 @@ server { proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; - proxy_pass http://status-page-api; + proxy_pass http://dashboard-api/status-page/status-page-api; } # Acme Verification. @@ -109,8 +105,9 @@ server { proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; - proxy_pass http://status-page-api; + proxy_pass http://dashboard-api/status-page/.well-known; } + } server { diff --git a/StatusPage/.env.tpl b/StatusPage/.env.tpl index b4a12efe03..538147c0df 100644 --- a/StatusPage/.env.tpl +++ b/StatusPage/.env.tpl @@ -1 +1 @@ -PORT={{ .Env.STATUS_PAGE_API_PORT }} \ No newline at end of file +PORT={{ .Env.STATUS_PAGE_PORT }} \ No newline at end of file diff --git a/StatusPage/Index.ts b/StatusPage/Index.ts deleted file mode 100755 index 4fb9c7d632..0000000000 --- a/StatusPage/Index.ts +++ /dev/null @@ -1,107 +0,0 @@ -import App from 'CommonServer/Utils/StartServer'; -import Express, { - ExpressApplication, - ExpressRequest, - ExpressResponse, -} from 'CommonServer/Utils/Express'; -import logger from 'CommonServer/Utils/Logger'; -import { PostgresAppInstance } from 'CommonServer/Infrastructure/PostgresDatabase'; -import GreenlockChallengeService from 'CommonServer/Services/GreenlockChallengeService'; -import GreenlockChallenge from 'Model/Models/GreenlockChallenge'; -import Response from 'CommonServer/Utils/Response'; -import NotFoundException from 'Common/Types/Exception/NotFoundException'; -import BadDataException from 'Common/Types/Exception/BadDataException'; -import StatusPageDomain from 'Model/Models/StatusPageDomain'; -import StatusPageDomainService from 'CommonServer/Services/StatusPageDomainService'; -import Port from 'Common/Types/Port'; - -export const APP_NAME: string = 'status-page-api'; - -const app: ExpressApplication = Express.getExpressApp(); - -// ACME Challenge Validation. -app.get( - '/.well-known/acme-challenge/:token', - async (req: ExpressRequest, res: ExpressResponse) => { - const challenge: GreenlockChallenge | null = - await GreenlockChallengeService.findOneBy({ - query: { - token: req.params['token'] as string, - }, - select: { - challenge: true, - }, - props: { - isRoot: true, - }, - }); - - if (!challenge) { - return Response.sendErrorResponse( - req, - res, - new NotFoundException('Challenge not found') - ); - } - - return Response.sendTextResponse( - req, - res, - challenge.challenge as string - ); - } -); - -app.get( - '/status-page-api/cname-verification/:token', - async (req: ExpressRequest, res: ExpressResponse) => { - const host: string | undefined = req.get('host'); - - if (!host) { - throw new BadDataException('Host not found'); - } - - const domain: StatusPageDomain | null = - await StatusPageDomainService.findOneBy({ - query: { - cnameVerificationToken: req.params['token'] as string, - fullDomain: host, - }, - select: { - _id: true, - }, - props: { - isRoot: true, - }, - }); - - if (!domain) { - return Response.sendErrorResponse( - req, - res, - new BadDataException('Invalid token.') - ); - } - - return Response.sendEmptyResponse(req, res); - } -); - -const init: Function = async (): Promise => { - try { - // init the app - await App(APP_NAME, new Port(3106)); - - // connect to the database. - await PostgresAppInstance.connect( - PostgresAppInstance.getDatasourceOptions() - ); - } catch (err) { - logger.error('App Init Failed:'); - logger.error(err); - } -}; - -init(); - -export default app; diff --git a/StatusPage/Serve.ts b/StatusPage/Serve.ts index 1b592f2bed..61ded2d5b6 100644 --- a/StatusPage/Serve.ts +++ b/StatusPage/Serve.ts @@ -1,7 +1,6 @@ import App from 'CommonServer/Utils/StartServer'; import Express, { ExpressApplication } from 'CommonServer/Utils/Express'; import logger from 'CommonServer/Utils/Logger'; -import Port from 'Common/Types/Port'; import { PostgresAppInstance } from 'CommonServer/Infrastructure/PostgresDatabase'; export const APP_NAME: string = 'status-page'; @@ -10,7 +9,7 @@ const app: ExpressApplication = Express.getExpressApp(); const init: Function = async (): Promise => { try { // init the app - await App(APP_NAME, new Port(3105), true); + await App(APP_NAME, undefined, true); // connect to the database. await PostgresAppInstance.connect( diff --git a/StatusPage/nodemon.json b/StatusPage/nodemon.json index 5ca66ad778..1b5489a28e 100644 --- a/StatusPage/nodemon.json +++ b/StatusPage/nodemon.json @@ -1,5 +1,4 @@ { - "watch": ["./","../Common", "../CommonServer"], - "ext": "ts,json,tsx,env,js,jsx,hbs", - "exec": "node --inspect=0.0.0.0:9229 --require ts-node/register Index.ts" + "watch": ["webpack.config.js"], + "exec": "export DEBUG=express:* && webpack-dev-server --port=3105 --mode=development" } \ No newline at end of file diff --git a/StatusPage/package.json b/StatusPage/package.json index 17b66f4961..3cafbf6e51 100644 --- a/StatusPage/package.json +++ b/StatusPage/package.json @@ -20,12 +20,11 @@ "use-async-effect": "^2.2.6" }, "scripts": { - "dev": "webpack-dev-server --port=3105 --mode=development & nodemon", + "dev": "npx nodemon", "build": "webpack build --mode=production", - "test": "react-app-rewired test", - "eject": "webpack eject", + "test": "", "compile": "tsc", - "start": "node --require ts-node/register Serve.ts & node --require ts-node/register Index.ts", + "start": "node --require ts-node/register Serve.ts", "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'" diff --git a/config.tpl.env b/config.tpl.env index 1883724b64..524b89e87c 100644 --- a/config.tpl.env +++ b/config.tpl.env @@ -71,7 +71,6 @@ REALTIME_PORT=3300 WORKERS_PORT=3452 ACCOUNTS_PORT=3003 STATUS_PAGE_PORT=3105 -STATUS_PAGE_API_PORT=3106 DASHBOARD_PORT=3009 # Internal SMTP Server - Haraka diff --git a/docker-compose.tpl.yml b/docker-compose.tpl.yml index 2aea14eac9..b6cd9de2bd 100644 --- a/docker-compose.tpl.yml +++ b/docker-compose.tpl.yml @@ -150,7 +150,6 @@ services: status-page: ports: - '3105:3105' # HTTP UI Port - - '3106:3106' # HTTP API Port {{ if eq .Env.ENVIRONMENT "development" }} - 9764:9229 # Debugging port. {{ end }} @@ -165,7 +164,6 @@ services: restart: always env_file: - ./Common/.env - - ./CommonServer/.env - ./CommonUI/.env - ./StatusPage/.env diff --git a/install.sh b/install.sh index f8374831a9..a355693f7b 100755 --- a/install.sh +++ b/install.sh @@ -22,13 +22,23 @@ echo "We will need to wait ~5-10 minutes for things to settle down, migrations t echo "" echo "⏳ Waiting for OneUptime to boot (this will take a few minutes)" bash -c 'while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' localhost/api/status)" != "200" ]]; do sleep 5; done' -echo "Progress 1/5" +echo "Progress 1/10" bash -c 'while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' localhost/dashboard/status)" != "200" ]]; do sleep 5; done' -echo "Progress 2/5" -bash -c 'while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' localhost/status)" != "200" ]]; do sleep 5; done' -echo "Progress 3/5" +echo "Progress 2/10" +bash -c 'while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' localhost/file/status)" != "200" ]]; do sleep 5; done' +echo "Progress 3/10" bash -c 'while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' localhost/staus-page/status)" != "200" ]]; do sleep 5; done' -echo "Progress 4/5" +echo "Progress 4/10" +bash -c 'while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' localhost/status)" != "200" ]]; do sleep 5; done' +echo "Progress 5/10" +bash -c 'while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' localhost/accounts/status)" != "200" ]]; do sleep 5; done' +echo "Progress 6/10" +bash -c 'while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' localhost/mail/status)" != "200" ]]; do sleep 5; done' +echo "Progress 7/10" +bash -c 'while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' localhost/workers/status)" != "200" ]]; do sleep 5; done' +echo "Progress 8/10" +bash -c 'while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' localhost/identity/status)" != "200" ]]; do sleep 5; done' +echo "Progress 9/10" echo "⌛️ OneUptime is up!" echo "" echo "🎉🎉🎉 Done! 🎉🎉🎉"