diff --git a/src/PrinterRepository.mts b/src/PrinterRepository.mts index 10f4d41..d53066f 100644 --- a/src/PrinterRepository.mts +++ b/src/PrinterRepository.mts @@ -1,5 +1,6 @@ import { Printer } from './Printer.mjs' import fs from 'fs' +import { PrinterJSON } from './types.mjs' export class PrinterRepository { constructor() { @@ -13,9 +14,12 @@ export class PrinterRepository { static instance: PrinterRepository loadFromJSON() { - const json = JSON.parse(fs.readFileSync('./data/printers.json', 'utf8')) + const json: PrinterJSON[] = JSON.parse( + fs.readFileSync('./data/printers.json', 'utf8') + ) + this.printers = json.map( - ({ name, ip, model }: Printer) => new Printer(name, ip, model) + ({ name, ip, model }) => new Printer(name, ip, model) ) } diff --git a/src/types.mts b/src/types.mts index 1085ff1..49ea348 100644 --- a/src/types.mts +++ b/src/types.mts @@ -59,7 +59,7 @@ export type PrinterInfo = { } } -export type Printer = { +export type PrinterJSON = { name: string ip: string model: PrinterModel