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-05-18 17:09:50 +01:00
|
|
|
import {Properties} from "../../properties";
|
2016-05-23 22:23:05 +01:00
|
|
|
import {Numbering} from "../../numbering";
|
2016-03-31 19:28:12 +01:00
|
|
|
|
|
|
|
export class ExpressPacker extends Packer {
|
|
|
|
private res: express.Response;
|
|
|
|
|
2016-05-23 22:23:05 +01:00
|
|
|
constructor(document: Document, res: express.Response, styles?: any, properties?: Properties, numbering?: Numbering) {
|
|
|
|
super(document, styles, properties, numbering);
|
2016-03-31 19:28:12 +01:00
|
|
|
this.res = res;
|
|
|
|
|
2016-05-26 15:08:34 +01:00
|
|
|
this.res.on("close", () => {
|
|
|
|
return res.status(200).send("OK").end();
|
2016-03-31 19:28:12 +01:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2016-05-18 17:09:50 +01:00
|
|
|
pack(name: string): void {
|
2016-03-31 19:28:12 +01:00
|
|
|
this.res.attachment(name + ".docx");
|
|
|
|
super.pack(this.res);
|
|
|
|
}
|
|
|
|
}
|