Compare commits
3 commits
ac70429e69
...
6848a5a4c9
Author | SHA1 | Date | |
---|---|---|---|
6848a5a4c9 | |||
0f0dc0c836 | |||
b442cb7f4f |
10 changed files with 39 additions and 38 deletions
|
@ -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"]
|
||||
|
|
30
angular.json
30
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"
|
||||
}
|
||||
|
|
|
@ -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 () => {
|
||||
|
|
|
@ -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
|
||||
},
|
||||
|
|
12
package.json
12
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",
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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!');
|
||||
});
|
||||
});
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>grafana-statuspage</title>
|
||||
<title>universal-statuspage</title>
|
||||
<base href="/">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link id="favicon" rel="icon" type="image/x-icon" href="">
|
||||
|
|
|
@ -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';
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
"outDir": "./out-tsc/app-server",
|
||||
"types": [
|
||||
"node"
|
||||
]
|
||||
, "target": "es2016"
|
||||
],
|
||||
"target": "es2016"
|
||||
},
|
||||
"files": [
|
||||
"src/main.server.ts",
|
||||
|
|
Reference in a new issue