page2pdf_server 1.1.1 → 1.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "page2pdf_server",
3
- "version": "1.1.1",
3
+ "version": "1.1.2",
4
4
  "description": "文书打印转换器",
5
5
  "private": false,
6
6
  "authors": "herzhang",
@@ -1,8 +1,8 @@
1
1
  import { OK } from "http-status/lib";
2
- import { HomeServices } from "./services";
2
+ import { Request, Response, NextFunction } from "express";
3
3
  import { getAppInfoQuery } from "../../types/request/home";
4
4
  import { apiResponse } from "../../helpers/apiResponse";
5
- import { Request, Response, NextFunction } from "express";
5
+ import { HomeServices } from "./services";
6
6
 
7
7
  /**
8
8
  * 为何为了保证单步模式调试运行"test:watchAll": "cross-env NODE_ENV=development jest --watchAll --runInBand --detectOpenHandles",
@@ -1,9 +1,10 @@
1
1
  import { OK } from "http-status/lib";
2
+ import { NextFunction, Request, Response } from "express";
2
3
  import { HeadFooter } from "../../types/request/config";
3
4
  import { apiResponse } from "../../helpers/apiResponse";
4
5
  import { RenderPDF } from "../../utils/pdfgen";
5
6
  import CONFIG from "../../configEnv";
6
- import { ConfigRoot, FileTransform } from "@/types";
7
+ import { ConfigRoot, FileTransform } from "../../types";
7
8
 
8
9
  export class PdfController {
9
10
  /** node.js对比前端App 太严格了,一点小毛病页不行啊。
@@ -13,7 +14,11 @@ export class PdfController {
13
14
  * 正常分解成两大步:task.files每一个文件生成,最后才是task.merge合并(包括页码生成)。
14
15
  * @param next
15
16
  */
16
- static postMakePdf = async (req: Req, res: Res, next: NextFn) => {
17
+ static postMakePdf = async (
18
+ req: Request,
19
+ res: Response,
20
+ next: NextFunction,
21
+ ) => {
17
22
  try {
18
23
  // const appInfoKey1 = req.query.key as getAppInfoQuery; 所有打印都走ConfigRoot配置包=task:可能有多个URL合并输出的。
19
24
  const task = req.body as ConfigRoot<FileTransform>;
@@ -1,12 +1,13 @@
1
1
  import fs from "fs";
2
2
  import { OK } from "http-status/lib";
3
+ import { NextFunction, Request, Response } from "express";
3
4
  import { HeadFooter } from "../../types/request/config";
4
5
  import { apiResponse } from "../../helpers/apiResponse";
5
6
 
6
7
  import { RenderPDF } from "../../utils/pdfgen";
7
8
  import CONFIG from "../../configEnv";
8
9
  import { SplitConfig, SplitPdfFile } from "../../types/request/split";
9
- import { ConfigRoot, FileTransform } from "@/types";
10
+ import { ConfigRoot, FileTransform } from "../../types";
10
11
  // import CONFIG from "@/configEnv";
11
12
  // eslint-disable-next-line @typescript-eslint/no-var-requires
12
13
  const { PDFDocument } = require("pdf-lib");
@@ -24,7 +25,11 @@ export class SplitController {
24
25
  * @param next
25
26
  */
26
27
  //仅仅测试的
27
- static postMakePdf = async (req: Req, res: Res, next: NextFn) => {
28
+ static postMakePdf = async (
29
+ req: Request,
30
+ res: Response,
31
+ next: NextFunction,
32
+ ) => {
28
33
  try {
29
34
  // const appInfoKey1 = req.query.key as getAppInfoQuery;
30
35
  const task = req.body as ConfigRoot<FileTransform>;
@@ -73,7 +78,11 @@ export class SplitController {
73
78
  };
74
79
 
75
80
  /**拆分需要:支持pdf源文件的,抽取部分纸张页生成新文件*/
76
- static postSplitPdf = async (req: Req, res: Res, next: NextFn) => {
81
+ static postSplitPdf = async (
82
+ req: Request,
83
+ res: Response,
84
+ next: NextFunction,
85
+ ) => {
77
86
  try {
78
87
  //也可能?用CDP:printPDF()来进行部分打印的后保存,就等于拆分pdf;
79
88
  const task = req.body as SplitConfig;
@@ -1,13 +1,14 @@
1
1
  import { Result, ValidationChain, validationResult } from "express-validator";
2
2
  // @ts-ignore
3
3
  import { Middleware as ValidatorMiddleware } from "express-validator/src/base";
4
+ import { NextFunction, Request, Response } from "express";
4
5
  import ValidationError from "./error/ValidationError";
5
6
 
6
7
  type MultiValidatorChain = ValidatorMiddleware & {
7
8
  run: (req: Request) => Promise<Result>;
8
9
  };
9
10
 
10
- const catchValidatorError = (req: Req, _: Res, next: NextFn): void => {
11
+ const catchValidatorError = (req: Request, _: Response, next: NextFunction): void => {
11
12
  const errors = validationResult(req);
12
13
  if (!errors.isEmpty()) {
13
14
  const validationErrors = errors
package/src/index.ts CHANGED
@@ -14,5 +14,5 @@ if (process.env.NODE_ENV !== "test") {
14
14
 
15
15
  //关键文档Chrome DevTools Protocol资料, https://chromedevtools.github.io/devtools-protocol/tot/Page
16
16
  export * from "./types/request/config";
17
- export { FileTransform } from "@/types";
18
- export { ConfigRoot } from "@/types";
17
+ export { FileTransform } from "./types";
18
+ export { ConfigRoot } from "./types";
@@ -8,7 +8,7 @@ import config from "config";
8
8
  import CONFIG from "../configEnv";
9
9
  import { MyPaperSize } from "../types/request/config";
10
10
  import { filePathToUrl } from "../utils/url";
11
- import { ConfigRoot, FileTransform } from "@/types";
11
+ import { ConfigRoot, FileTransform } from "../types";
12
12
 
13
13
  //自定义纸张系列的:
14
14
  const paperSZs = config.get("size") as MyPaperSize[];
package/tsconfig.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "compilerOptions": {
3
- "declaration": false, // 关闭自动生成声明文件
3
+ "rootDir": "./src", // 输入文件根目录
4
4
  "outDir": "./dist",
5
- "rootDir": "./src",
6
5
  "pretty": true,
7
6
  "removeComments": true,
8
7
 
9
- // "declarationDir": "./dist/types", // 声明文件输出目录
8
+ "declaration": true,
9
+ "declarationDir": "./dist/types", // 声明文件输出目录
10
10
  // "emitDeclarationOnly": true, // 仅生成声明文件
11
11
  "module": "ESNext",
12
12
  "target": "ES2021",