page2pdf_server 1.1.2 → 2.0.0

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.
Files changed (70) hide show
  1. package/README.md +6 -5
  2. package/package.json +5 -70
  3. package/src/index.ts +10 -18
  4. package/src/types.d.ts +161 -97
  5. package/.github/ISSUE_TEMPLATE/bug_report.md +0 -28
  6. package/.github/ISSUE_TEMPLATE/feature_request.md +0 -15
  7. package/.github/ISSUE_TEMPLATE/refactoring.md +0 -15
  8. package/.github/PULL_REQUEST_TEMPLATE.md +0 -18
  9. package/.github/stale.yml +0 -17
  10. package/.github/workflows/cd.yml +0 -75
  11. package/.github/workflows/ci.yml +0 -36
  12. package/.prettierrc +0 -8
  13. package/.vscode/settings.json +0 -3
  14. package/config/default.json +0 -10
  15. package/config/development.json +0 -3
  16. package/config/production.json +0 -3
  17. package/config/test.json +0 -3
  18. package/ecosystem.config.js +0 -41
  19. package/jest.config.js +0 -35
  20. package/nodemon.json +0 -6
  21. package/src/CSS/345/205/274/345/256/271/346/200/247.txt +0 -125
  22. package/src/__tests__/UrltoPdf/generatePdf.test.d.ts +0 -1
  23. package/src/__tests__/UrltoPdf/generatePdf.test.ts +0 -207
  24. package/src/__tests__/UrltoPdf/pdfSplit.test.d.ts +0 -1
  25. package/src/__tests__/UrltoPdf/pdfSplit.test.ts +0 -69
  26. package/src/__tests__/helpers/index.d.ts +0 -2
  27. package/src/__tests__/helpers/index.ts +0 -21
  28. package/src/__tests__/home.test.d.ts +0 -1
  29. package/src/__tests__/home.test.ts +0 -77
  30. package/src/app.ts +0 -49
  31. package/src/components/home/controller.ts +0 -32
  32. package/src/components/home/index.ts +0 -4
  33. package/src/components/home/pdfController.ts +0 -118
  34. package/src/components/home/services.ts +0 -31
  35. package/src/components/home/splitController.ts +0 -134
  36. package/src/components/home/validators.ts +0 -12
  37. package/src/configEnv/index.ts +0 -62
  38. package/src/db/home.ts +0 -14
  39. package/src/helpers/apiResponse.ts +0 -10
  40. package/src/helpers/dataSanitizers.ts +0 -33
  41. package/src/helpers/error/ApiError.ts +0 -25
  42. package/src/helpers/error/ForbiddenError.ts +0 -15
  43. package/src/helpers/error/NotFoundException.ts +0 -15
  44. package/src/helpers/error/TimeOutError.ts +0 -20
  45. package/src/helpers/error/UnauthorizedError.ts +0 -15
  46. package/src/helpers/error/ValidationError.ts +0 -20
  47. package/src/helpers/error/index.ts +0 -15
  48. package/src/helpers/index.ts +0 -2
  49. package/src/helpers/loggers.ts +0 -75
  50. package/src/middlewares/errorHandler.ts +0 -52
  51. package/src/new_tab1.mhtml +0 -722
  52. package/src/routes/index.ts +0 -22
  53. package/src/server.ts +0 -30
  54. package/src/testCSS.html +0 -241
  55. package/src/types/global.d.ts +0 -13
  56. package/src/types/request/config.ts +0 -70
  57. package/src/types/request/home.ts +0 -3
  58. package/src/types/request/split.ts +0 -18
  59. package/src/types/response/AppInformation.ts +0 -9
  60. package/src/types/response/index.ts +0 -5
  61. package/src/utils/array.ts +0 -19
  62. package/src/utils/auth.ts +0 -12
  63. package/src/utils/crypt.ts +0 -25
  64. package/src/utils/filter.ts +0 -59
  65. package/src/utils/object.ts +0 -58
  66. package/src/utils/pdfgen.ts +0 -1045
  67. package/src/utils/url.ts +0 -54
  68. package/src//346/265/213/350/257/225.txt +0 -268
  69. package/test//346/211/223/345/215/260/346/234/215/345/212/241.http +0 -17
  70. package//346/226/207/344/271/246/346/211/223/345/215/260/350/275/254/346/215/242/345/231/250.bat +0 -2
@@ -1,15 +0,0 @@
1
- import HttpStatus, { UNAUTHORIZED } from "http-status/lib";
2
-
3
- class UnauthorizedError {
4
- readonly status: number;
5
- readonly message: string;
6
-
7
- constructor(message: string) {
8
- Object.setPrototypeOf(this, new.target.prototype);
9
-
10
- this.status = UNAUTHORIZED;
11
- this.message = message || (HttpStatus[UNAUTHORIZED] as string);
12
- }
13
- }
14
-
15
- export default UnauthorizedError;
@@ -1,20 +0,0 @@
1
- import HttpStatus, { BAD_REQUEST } from "http-status/lib";
2
-
3
- class ValidationError extends Error {
4
- readonly status: number;
5
- readonly message: string;
6
- readonly details: Record<string, any>;
7
-
8
- constructor(validationErrors: Record<string, any>) {
9
- super();
10
- Object.setPrototypeOf(this, new.target.prototype);
11
-
12
- this.status = BAD_REQUEST;
13
- this.message = HttpStatus[BAD_REQUEST] as string;
14
- this.details = validationErrors;
15
-
16
- Error.captureStackTrace(this);
17
- }
18
- }
19
-
20
- export default ValidationError;
@@ -1,15 +0,0 @@
1
- import APIError from "./ApiError";
2
- import ValidationError from "./ValidationError";
3
- import ForbiddenError from "./ForbiddenError";
4
- import UnauthorizedError from "./UnauthorizedError";
5
- import NotFoundException from "./NotFoundException";
6
- import TimeOutError from "./TimeOutError";
7
-
8
- export {
9
- APIError,
10
- ValidationError,
11
- ForbiddenError,
12
- UnauthorizedError,
13
- NotFoundException,
14
- TimeOutError,
15
- };
@@ -1,2 +0,0 @@
1
- export { expressPinoLogger, exitLog } from "./loggers";
2
- export { sanitizer } from "./dataSanitizers";
@@ -1,75 +0,0 @@
1
- import httpStatus from "http-status/lib";
2
- import expressPino from "express-pino-logger";
3
- import { hidePassword } from "../utils/auth";
4
-
5
- const { OK, BAD_REQUEST } = httpStatus;
6
-
7
- // More info: https://github.com/pinojs/express-pino-logger
8
- export const expressPinoLogger = () =>
9
- expressPino({
10
- transport: {
11
- target: "pino-pretty",
12
- options: {
13
- colorize: true,
14
- translateTime: true,
15
- },
16
- },
17
- customLogLevel(res, err) {
18
- const status = res.statusCode!;
19
- if (status >= 400 && status < 500) {
20
- return "warn";
21
- }
22
- if (status >= 500 || err) {
23
- return "error";
24
- }
25
- return "silent";
26
- },
27
- customErrorMessage: (err) => ` : ${err}`,
28
- customSuccessMessage(res) {
29
- const status = res.statusCode!;
30
- if (status >= 400 && status < 500) {
31
- // @ts-ignore
32
- return `${status || BAD_REQUEST} : ${httpStatus[status || 400]}`;
33
- }
34
- if (status >= 500) {
35
- // @ts-ignore
36
- return `${status} : ${httpStatus[status || 500]}`;
37
- }
38
- return `${OK} : ${httpStatus[200].toUpperCase()}`;
39
- },
40
- serializers: {
41
- req: (req) => {
42
- // console.log('[ R E Q U E S T ] => ', req.raw);
43
- const {
44
- method,
45
- url,
46
- headers: { host },
47
- } = req;
48
- return {
49
- origin: host,
50
- method,
51
- url,
52
- query: req.query,
53
- params: req.params,
54
- body: hidePassword({ ...req.raw.body }),
55
- };
56
- },
57
- res: (res) => {
58
- // console.log("[ R E S P O N S E ] => ", res);
59
- return {
60
- status: res.statusCode,
61
- };
62
- },
63
- err: (err) => `${err.type} : ${err.message}`,
64
- },
65
- });
66
-
67
- export const exitLog = (err: any, evt: string) => {
68
- if (err) {
69
- process.stdout.write(`\n\n[!ERROR][${evt}] => ${err}\n\n`);
70
- } else {
71
- process.stdout.write(`\n\n![${evt}] EVENT CAUSE EXIT\n\n`);
72
- }
73
-
74
- process.exit(err ? 1 : 0);
75
- };
@@ -1,52 +0,0 @@
1
- import { NextFunction, Request, Response } from "express";
2
-
3
- import HttpStatus, {
4
- NOT_FOUND,
5
- INTERNAL_SERVER_ERROR,
6
- REQUEST_TIMEOUT,
7
- } from "http-status/lib";
8
- import { TimeOutError } from "../helpers/error";
9
-
10
- /**
11
- * @description Error response middleware for 404 not found. This middleware function should be at the very bottom of the stack.
12
- * @param req Express.Request
13
- * @param res Express.Response
14
- * @param _next Express.NextFunction
15
- */
16
- export const notFoundError = (
17
- req: Request,
18
- res: Response,
19
- _next: NextFunction,
20
- ) => {
21
- res.status(NOT_FOUND).json({
22
- error: {
23
- code: NOT_FOUND,
24
- message: HttpStatus[NOT_FOUND],
25
- path: req.originalUrl,
26
- },
27
- });
28
- };
29
-
30
- /**
31
- * @description Generic error response middleware for validation and internal server errors.
32
- * @param {*} err
33
- * @param {object} req Express.Request
34
- * @param {object} res Express.Response
35
- * @param {function} next Express.NextFunction
36
- */
37
- export const genericErrorHandler = (
38
- err: any,
39
- req: Request,
40
- res: Response,
41
- _next: NextFunction,
42
- ) => {
43
- let resCode: number = err.status || INTERNAL_SERVER_ERROR;
44
- let resBody = err;
45
-
46
- if (err.code === "ETIMEDOUT") {
47
- resCode = REQUEST_TIMEOUT;
48
- resBody = new TimeOutError(req.originalUrl);
49
- }
50
-
51
- res.status(resCode).json(resBody);
52
- };