Move ts to src folder for standards
This commit is contained in:
31
src/export/packer/express.ts
Normal file
31
src/export/packer/express.ts
Normal file
@ -0,0 +1,31 @@
|
||||
import * as express from "express";
|
||||
|
||||
import { Document } from "../../docx/document";
|
||||
import { Media } from "../../media";
|
||||
import { Numbering } from "../../numbering";
|
||||
import { Properties } from "../../properties";
|
||||
import { Styles } from "../../styles";
|
||||
import { Compiler } from "./compiler";
|
||||
import { IPacker } from "./packer";
|
||||
|
||||
export class ExpressPacker implements IPacker {
|
||||
private res: express.Response;
|
||||
private packer: Compiler;
|
||||
|
||||
constructor(document: Document, res: express.Response, styles?: Styles, properties?: Properties, numbering?: Numbering, media?: Media) {
|
||||
this.packer = new Compiler(document, styles, properties, numbering, media);
|
||||
|
||||
this.res = res;
|
||||
|
||||
this.res.on("close", () => {
|
||||
return res.status(200).send("OK").end();
|
||||
});
|
||||
}
|
||||
|
||||
public async pack(name: string): Promise<void> {
|
||||
name = name.replace(/.docx$/, "");
|
||||
|
||||
this.res.attachment(`${name}.docx`);
|
||||
await this.packer.compile(this.res);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user