import { Application } from '@feathersjs/express'; import { ServiceMethods, Id } from '@feathersjs/feathers'; import ExcelJS from 'exceljs'; import { WaybillSchema } from '../models/waybill/waybill.schema'; class Spreadsheets implements Partial> { app!: Application; setup(app: Application) { this.app = app; } async get(id: Id) { const waybill: WaybillSchema = await this.app.service('waybills').get(id); const workbook = new ExcelJS.Workbook(); const sheet = workbook.addWorksheet('Накладная'); waybill.records.forEach(record => { sheet.addRow([record.productId, record.quantity, record.price]); }); await workbook.xlsx.writeFile('./documents/waybill.xlsx'); return 'written!'; } } export default (app: Application): void => { app.use('/spreadsheets', new Spreadsheets); };