17 lines
388 B
TypeScript
17 lines
388 B
TypeScript
import { Injectable, OnApplicationShutdown } from '@nestjs/common';
|
|
import WS1080 from './module/ws1080';
|
|
|
|
@Injectable()
|
|
export class AppService implements OnApplicationShutdown {
|
|
public station?: WS1080;
|
|
|
|
async getWeather() {
|
|
if (!this.station) this.station = WS1080.fromDevice();
|
|
return this.station.read();
|
|
}
|
|
|
|
onApplicationShutdown() {
|
|
this.station?.close();
|
|
}
|
|
}
|