diff --git a/client/src/class/ClientService.ts b/client/src/class/ClientService.ts index bdd92ed..13bb77b 100644 --- a/client/src/class/ClientService.ts +++ b/client/src/class/ClientService.ts @@ -4,7 +4,7 @@ import { Sensor } from './Sensor'; export class ClientService { private clientSocket: ClientSocket = new ClientSocket( process.env.SERVER_URL!, - 'temp' + 'measurement' ); private sensor: Sensor = new Sensor(); @@ -12,13 +12,13 @@ export class ClientService { tempService(): void { setInterval(() => { - this.clientSocket.sendTemp(this.sensor.takeMeasure, 'temperature'); + this.clientSocket.sendMeasure(this.sensor.takeMeasure, 'temperature'); }, 5 * 60000); } tempTestService(): void { setInterval(() => { - this.clientSocket.sendTemp(this.sensor.takeTestMeasure, 'temperature'); + this.clientSocket.sendMeasure(this.sensor.takeTestMeasure, 'temperature'); }, 5 * 60000); } } diff --git a/client/src/class/ClientSocket.ts b/client/src/class/ClientSocket.ts index b75c751..f02cf05 100644 --- a/client/src/class/ClientSocket.ts +++ b/client/src/class/ClientSocket.ts @@ -1,5 +1,5 @@ -import chalk from 'chalk'; import { exit } from 'process'; +import chalk from 'chalk'; import io from 'socket.io-client'; export class ClientSocket { @@ -31,7 +31,7 @@ export class ClientSocket { if (reason === 'io server disconnect') this.socket.connect(); if (reason === 'io client disconnect') { - console.log(chalk.red('Server kicked you out!')); + console.log(chalk.red('Server kicked you!')); exit(1); } @@ -48,7 +48,7 @@ export class ClientSocket { this.socket.disconnect(); } - sendTemp(measurement: number, pointName: string): void { + sendMeasure(measurement: number, pointName: string): void { this.socket.emit(this.eventName, { measurement, pointName }); } } diff --git a/server/src/AppRouter.ts b/server/src/AppRouter.ts deleted file mode 100644 index 59bb530..0000000 --- a/server/src/AppRouter.ts +++ /dev/null @@ -1,11 +0,0 @@ -import express from 'express'; - -export class AppRouter { - private static instance: express.Router; - - static getInstance(): express.Router { - if (!AppRouter.instance) AppRouter.instance = express.Router(); - - return AppRouter.instance; - } -} diff --git a/server/src/class/Service.ts b/server/src/class/Service.ts index 86eb80b..2f5e016 100644 --- a/server/src/class/Service.ts +++ b/server/src/class/Service.ts @@ -16,6 +16,6 @@ export class Service { } private initSocket() { - this.socket = new Socket('temp', this.http, this.database); + this.socket = new Socket('measurement', this.http, this.database); } } diff --git a/server/src/index.ts b/server/src/index.ts index d279587..2279ac6 100644 --- a/server/src/index.ts +++ b/server/src/index.ts @@ -3,7 +3,7 @@ import express from 'express'; import chalk from 'chalk'; var cors = require('cors'); import { Service } from './class/Service'; -import { AppRouter } from './AppRouter'; +// import { AppRouter } from './AppRouter'; import { Routes } from './routes/Routes'; console.log(chalk.cyan('Started Anchiale Server...')); @@ -13,7 +13,6 @@ const http = require('http').Server(app); const service = new Service(http); app.use(cors()); -app.use(AppRouter.getInstance()); const route = new Routes(app, service); route.routes(); diff --git a/server/src/routes/Routes.ts b/server/src/routes/Routes.ts index 1c1bc15..5831efe 100644 --- a/server/src/routes/Routes.ts +++ b/server/src/routes/Routes.ts @@ -38,7 +38,7 @@ export class Routes { private measurements(): void { this.app.get('/measurements', async (req, res) => { - const points = await this.service.database.query('temperature', '1h'); + const points = await this.service.database.query('temperature', '1h'); // make temperature to something more abstract res.header('Content-Type', 'application/json'); if (points) { diff --git a/web/.eslintrc.json b/web/.eslintrc.json new file mode 100644 index 0000000..014f4e2 --- /dev/null +++ b/web/.eslintrc.json @@ -0,0 +1,5 @@ +{ + "rules": { + "quotes": ["error", "single"] + } +} \ No newline at end of file