2016-03-31 19:28:12 +01:00
|
|
|
import {Packer} from "./packer";
|
|
|
|
import * as fs from "fs";
|
|
|
|
import * as express from "express";
|
2016-03-31 23:36:42 +01:00
|
|
|
import {Document} from "../../docx/document";
|
2016-03-31 19:28:12 +01:00
|
|
|
|
|
|
|
export class ExpressPacker extends Packer {
|
|
|
|
private res: express.Response;
|
|
|
|
|
2016-03-31 23:36:42 +01:00
|
|
|
constructor(document: Document, res: express.Response) {
|
2016-04-03 01:44:18 +01:00
|
|
|
super(document, null, null);
|
2016-03-31 19:28:12 +01:00
|
|
|
this.res = res;
|
|
|
|
|
|
|
|
this.res.on('close', () => {
|
|
|
|
return res.status(200).send('OK').end();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
pack() {
|
|
|
|
this.res.attachment(name + ".docx");
|
|
|
|
super.pack(this.res);
|
|
|
|
}
|
|
|
|
}
|