Browse Source

Merge pull request #945 from hastic/fix-build-errors

Fix build errors
pull/1/head
rozetko 4 years ago committed by GitHub
parent
commit
c8c3b223a3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      server/build/webpack.base.conf.js
  2. 4
      server/package.json
  3. 10
      server/src/routes/analytic_units_router.ts
  4. 14
      server/src/routes/data_router.ts
  5. 2
      server/src/routes/detections_router.ts
  6. 2
      server/src/routes/panel_router.ts
  7. 2
      server/src/routes/segments_router.ts
  8. 2
      server/src/services/data_layer/nedb.ts
  9. 2
      server/src/services/json_service.ts

3
server/build/webpack.base.conf.js

@ -42,7 +42,8 @@ module.exports = {
stats: {
warningsFilter: [
'mongodb-client-encryption',
'saslprep',
/ws\/lib/,
/mongodb\/lib\/core/,
/require_optional/
]
},

4
server/package.json

@ -48,13 +48,13 @@
"koa-bodyparser": "^4.2.0",
"koa-router": "^7.0.31",
"lodash": "^4.17.10",
"mongodb": "^3.3.2",
"mongodb": "3.3.2",
"nedb": "^1.8.0",
"node-loader": "^0.6.0",
"nodemon": "^1.17.5",
"ts-jest": "^23.1.1",
"ts-loader": "^4.4.1",
"typescript": "^3.9.5",
"typescript": "^4.3.2",
"url": "^0.11.0",
"webpack": "^4.12.0",
"webpack-cli": "^3.0.8",

10
server/src/routes/analytic_units_router.ts

@ -8,7 +8,7 @@ import * as _ from 'lodash';
async function getStatus(ctx: Router.IRouterContext) {
let analyticUnitId = ctx.request.query.id;
let analyticUnitId = ctx.request.query.id as string;
if(analyticUnitId === undefined) {
throw new Error('Cannot get status of undefined id');
}
@ -23,12 +23,14 @@ async function getStatus(ctx: Router.IRouterContext) {
};
if(analyticUnit.status === AnalyticUnit.AnalyticUnitStatus.FAILED) {
ctx.response.body.errorMessage = analyticUnit.error;
ctx.response.body = {
errorMessage: analyticUnit.error
};
}
}
async function getUnits(ctx: Router.IRouterContext) {
const panelId = ctx.request.query.panelId;
const panelId = ctx.request.query.panelId as string;
if(panelId === undefined) {
throw new Error('Cannot get units of undefined panelId');
}
@ -118,7 +120,7 @@ async function updateAlert(ctx: Router.IRouterContext) {
}
async function deleteUnit(ctx: Router.IRouterContext) {
const analyticUnitId = ctx.request.query.id;
const analyticUnitId = ctx.request.query.id as string;
if(analyticUnitId === undefined) {
throw new Error('Cannot delete undefined id');
}

14
server/src/routes/data_router.ts

@ -6,24 +6,24 @@ import * as Router from 'koa-router';
async function query(ctx: Router.IRouterContext) {
let from = ctx.request.query.from;
let to = ctx.request.query.to;
const analyticUnitId = ctx.request.query.analyticUnitId;
let queryFrom = ctx.request.query.from as string;
let queryTo = ctx.request.query.to as string;
const analyticUnitId = ctx.request.query.analyticUnitId as string;
if(analyticUnitId === undefined) {
throw new Error(`data router error: request must contain analyticUnitId`);
}
if(from === undefined) {
if(queryFrom === undefined) {
throw new Error(`data router error: request must contain 'from'`)
}
if(to === undefined) {
if(queryTo === undefined) {
throw new Error(`data router error: request must contain 'to'`)
}
from = +from;
to = +to;
const from = +queryFrom;
const to = +queryTo;
if(from === NaN) {
throw new Error(`from must be not NaN`);

2
server/src/routes/detections_router.ts

@ -10,7 +10,7 @@ declare type DetectionSpansResponse = {
}
export async function getDetectionSpans(ctx: Router.IRouterContext) {
let id: AnalyticUnitId = ctx.request.query.id;
const id = ctx.request.query.id as string;
if(id === undefined || id === '') {
throw new Error('analyticUnitId (id) is missing');
}

2
server/src/routes/panel_router.ts

@ -5,7 +5,7 @@ import * as Router from 'koa-router';
async function exportGrafanaPanelTemplate(ctx: Router.IRouterContext) {
let panelId = ctx.request.query.panelId;
const panelId = ctx.request.query.panelId as string;
if(panelId === undefined) {
throw new Error('Cannot export analytic units with undefined panelId');
}

2
server/src/routes/segments_router.ts

@ -7,7 +7,7 @@ import * as Router from 'koa-router';
export async function getSegments(ctx: Router.IRouterContext) {
let id: AnalyticUnitId = ctx.request.query.id;
const id = ctx.request.query.id as string;
if(id === undefined || id === '') {
throw new Error('analyticUnitId (id) is missing');
}

2
server/src/services/data_layer/nedb.ts

@ -36,7 +36,7 @@ export class NeDbQueryWrapper implements DbQueryWrapper {
// https://github.com/louischatriot/nedb#updating-documents
let nedbUpdateQuery = { $set: updateQuery }
query = wrapIdToQuery(query);
return new Promise<any>((resolve, reject) => {
return new Promise<void>((resolve, reject) => {
nd.update(
query,
nedbUpdateQuery,

2
server/src/services/json_service.ts

@ -22,7 +22,7 @@ async function getJsonData(filename: string): Promise<Object> {
}
function writeJsonData(filename: string, data: Object) {
return new Promise((resolve, reject) => {
return new Promise<void>((resolve, reject) => {
fs.writeFile(filename, JSON.stringify(data), 'utf8', (err) => {
if(err) {
console.error(err);

Loading…
Cancel
Save