Files
docx-js/ts/export/packer/express.ts

26 lines
753 B
TypeScript
Raw Normal View History

2016-03-31 19:28:12 +01:00
import * as express from "express";
2017-03-08 21:54:52 +00:00
import * as fs from "fs";
import { Document } from "../../docx/document";
import { Numbering } from "../../numbering";
import { Properties } from "../../properties";
import { Packer } from "./packer";
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
});
}
2017-03-08 21:54:52 +00:00
public pack(name: string): void {
2016-03-31 19:28:12 +01:00
this.res.attachment(name + ".docx");
super.pack(this.res);
}
2017-03-08 21:54:52 +00:00
}