diff --git a/Dockerfile b/Dockerfile index d8dba51..2d4262b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,9 @@ FROM node:alpine -COPY dist/grafana-statuspage /grafana-statuspage +COPY dist/universal-statuspage /universal-statuspage WORKDIR /app EXPOSE 4000 -ENTRYPOINT ["node", "/grafana-statuspage/server/main.js"] +ENTRYPOINT ["node", "/universal-statuspage/server/main.js"] diff --git a/angular.json b/angular.json index 870599a..a9c5904 100644 --- a/angular.json +++ b/angular.json @@ -3,7 +3,7 @@ "version": 1, "newProjectRoot": "projects", "projects": { - "grafana-statuspage": { + "universal-statuspage": { "projectType": "application", "schematics": { "@schematics/angular:component": { @@ -17,7 +17,7 @@ "build": { "builder": "@angular-devkit/build-angular:browser", "options": { - "outputPath": "dist/grafana-statuspage/browser", + "outputPath": "dist/universal-statuspage/browser", "index": "src/index.html", "main": "src/main.ts", "polyfills": "src/polyfills.ts", @@ -69,18 +69,18 @@ "serve": { "builder": "@angular-devkit/build-angular:dev-server", "options": { - "browserTarget": "grafana-statuspage:build" + "browserTarget": "universal-statuspage:build" }, "configurations": { "production": { - "browserTarget": "grafana-statuspage:build:production" + "browserTarget": "universal-statuspage:build:production" } } }, "extract-i18n": { "builder": "@angular-devkit/build-angular:extract-i18n", "options": { - "browserTarget": "grafana-statuspage:build" + "browserTarget": "universal-statuspage:build" } }, "test": { @@ -120,18 +120,18 @@ "builder": "@angular-devkit/build-angular:protractor", "options": { "protractorConfig": "e2e/protractor.conf.js", - "devServerTarget": "grafana-statuspage:serve" + "devServerTarget": "universal-statuspage:serve" }, "configurations": { "production": { - "devServerTarget": "grafana-statuspage:serve:production" + "devServerTarget": "universal-statuspage:serve:production" } } }, "server": { "builder": "@angular-devkit/build-angular:server", "options": { - "outputPath": "dist/grafana-statuspage/server", + "outputPath": "dist/universal-statuspage/server", "main": "server.ts", "tsConfig": "tsconfig.server.json" }, @@ -152,21 +152,21 @@ "serve-ssr": { "builder": "@nguniversal/builders:ssr-dev-server", "options": { - "browserTarget": "grafana-statuspage:build", - "serverTarget": "grafana-statuspage:server" + "browserTarget": "universal-statuspage:build", + "serverTarget": "universal-statuspage:server" }, "configurations": { "production": { - "browserTarget": "grafana-statuspage:build:production", - "serverTarget": "grafana-statuspage:server:production" + "browserTarget": "universal-statuspage:build:production", + "serverTarget": "universal-statuspage:server:production" } } }, "prerender": { "builder": "@nguniversal/builders:prerender", "options": { - "browserTarget": "grafana-statuspage:build:production", - "serverTarget": "grafana-statuspage:server:production", + "browserTarget": "universal-statuspage:build:production", + "serverTarget": "universal-statuspage:server:production", "routes": [ "/" ] @@ -177,5 +177,5 @@ } } }}, - "defaultProject": "grafana-statuspage" + "defaultProject": "universal-statuspage" } diff --git a/e2e/src/app.e2e-spec.ts b/e2e/src/app.e2e-spec.ts index 0b96611..297640e 100644 --- a/e2e/src/app.e2e-spec.ts +++ b/e2e/src/app.e2e-spec.ts @@ -10,7 +10,7 @@ describe('workspace-project App', () => { it('should display welcome message', () => { page.navigateTo(); - expect(page.getTitleText()).toEqual('grafana-statuspage app is running!'); + expect(page.getTitleText()).toEqual('universal-statuspage app is running!'); }); afterEach(async () => { diff --git a/karma.conf.js b/karma.conf.js index 97a9c7c..2502213 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -16,7 +16,7 @@ module.exports = function (config) { clearContext: false // leave Jasmine Spec Runner output visible in browser }, coverageIstanbulReporter: { - dir: require('path').join(__dirname, './coverage/grafana-statuspage'), + dir: require('path').join(__dirname, './coverage/universal-statuspage'), reports: ['html', 'lcovonly', 'text-summary'], fixWebpackSourcePaths: true }, diff --git a/package.json b/package.json index 30d0dae..90a6c9d 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "grafana-statuspage", + "name": "universal-statuspage", "version": "0.0.0", "scripts": { "ng": "ng", @@ -8,10 +8,10 @@ "test": "ng test", "lint": "ng lint", "e2e": "ng e2e", - "dev:ssr": "ng run grafana-statuspage:serve-ssr", - "serve:ssr": "node dist/grafana-statuspage/server/main.js", - "build:ssr": "ng build --prod && ng run grafana-statuspage:server:production", - "prerender": "ng run grafana-statuspage:prerender" + "dev:ssr": "ng run universal-statuspage:serve-ssr", + "serve:ssr": "node dist/universal-statuspage/server/main.js", + "build:ssr": "ng build --prod && ng run universal-statuspage:server:production", + "prerender": "ng run universal-statuspage:prerender" }, "private": true, "dependencies": { @@ -30,7 +30,7 @@ "@nguniversal/express-engine": "^10.0.1", "bootstrap": "^4.5.0", "express": "^4.15.2", - "jsonpath": "^1.0.2", + "jsonpath-plus": "^4.0.0", "roboto-fontface": "^0.10.0", "rxjs": "~6.6.0", "tslib": "^2.0.0", diff --git a/server.ts b/server.ts index 2722cae..edd57b5 100644 --- a/server.ts +++ b/server.ts @@ -8,12 +8,12 @@ import {AppServerModule} from './src/main.server'; import {APP_BASE_HREF} from '@angular/common'; import {existsSync} from 'fs'; import {api} from './src/main.status'; -import {environment} from "./src/environments/environment"; +import {environment} from './src/environments/environment'; // The Express app is exported so that it can be used by serverless Functions. export function app() { const server = express(); - const distFolder = environment.production ? '/grafana-statuspage/browser' : join(process.cwd(), 'dist/grafana-statuspage/browser'); + const distFolder = environment.production ? '/universal-statuspage/browser' : join(process.cwd(), 'dist/universal-statuspage/browser'); const indexHtml = existsSync(join(distFolder, 'index.original.html')) ? 'index.original.html' : 'index'; // Our Universal express-engine (found @ https://github.com/angular/universal/tree/master/modules/express-engine) diff --git a/src/app/app.component.spec.ts b/src/app/app.component.spec.ts index 113a88d..5d69a33 100644 --- a/src/app/app.component.spec.ts +++ b/src/app/app.component.spec.ts @@ -20,16 +20,16 @@ describe('AppComponent', () => { expect(app).toBeTruthy(); }); - it(`should have as title 'grafana-statuspage'`, () => { + it(`should have as title 'universal-statuspage'`, () => { const fixture = TestBed.createComponent(AppComponent); const app = fixture.componentInstance; - expect(app.title).toEqual('grafana-statuspage'); + expect(app.title).toEqual('universal-statuspage'); }); it('should render title', () => { const fixture = TestBed.createComponent(AppComponent); fixture.detectChanges(); const compiled = fixture.nativeElement; - expect(compiled.querySelector('.content span').textContent).toContain('grafana-statuspage app is running!'); + expect(compiled.querySelector('.content span').textContent).toContain('universal-statuspage app is running!'); }); }); diff --git a/src/index.html b/src/index.html index d630637..3cbdeb6 100644 --- a/src/index.html +++ b/src/index.html @@ -2,7 +2,7 @@ - grafana-statuspage + universal-statuspage diff --git a/src/main.status.ts b/src/main.status.ts index b3e5c30..54e7f4d 100644 --- a/src/main.status.ts +++ b/src/main.status.ts @@ -1,7 +1,8 @@ import {json, Router} from 'express'; import {CurrentStatus, State} from './app/_data/data'; import {existsSync, readFileSync, writeFileSync} from 'fs'; -import * as jp from 'jsonpath'; +import {join} from 'path'; +import {JSONPath} from 'jsonpath-plus'; interface Cache { [id: string]: State; @@ -43,7 +44,8 @@ interface StateKey { const api = Router(); api.use(json()); -const config = JSON.parse(readFileSync('config.json', {encoding: 'utf-8'})) as Config; +const serviceStates = existsSync(join(process.cwd(), 'cache.json')) ? JSON.parse(readFileSync(join(process.cwd(), 'cache.json'), {encoding: 'utf-8'})) : {} as Cache; +const config = JSON.parse(readFileSync(join(process.cwd(), 'config.json'), {encoding: 'utf-8'})) as Config; const stateKeys: { [service: string]: StateKey } = config.groups .map(g => g.services).reduce((x, y) => x.concat(y), []) .reduce((services, service) => { @@ -56,7 +58,6 @@ const stateKeys: { [service: string]: StateKey } = config.groups }; return services; }, {}); -const serviceStates = existsSync('cache.json') ? JSON.parse(readFileSync('cache.json', {encoding: 'utf-8'})) : {} as Cache; let cache: CurrentStatus; updateCache(); @@ -68,7 +69,7 @@ api.post('/update/health', (req, res) => { } const serviceId = req.query.service as string; const keys = stateKeys[serviceId]; - const state = jp.value(req.body, keys.statePath); + const state = JSONPath({path: keys.statePath, json: req.body, wrap: false}); if (keys.stateValues.operational.includes(state)) { serviceStates[serviceId] = 'operational'; diff --git a/tsconfig.server.json b/tsconfig.server.json index 7b4ee4b..784d51b 100644 --- a/tsconfig.server.json +++ b/tsconfig.server.json @@ -4,9 +4,9 @@ "outDir": "./out-tsc/app-server", "types": [ "node" - ] - , "target": "es2016" -}, + ], + "target": "es2016" + }, "files": [ "src/main.server.ts", "server.ts"