page2pdf_server 1.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 (79) hide show
  1. package/.babelrc +3 -0
  2. package/.eslintrc +33 -0
  3. package/.github/ISSUE_TEMPLATE/bug_report.md +28 -0
  4. package/.github/ISSUE_TEMPLATE/feature_request.md +15 -0
  5. package/.github/ISSUE_TEMPLATE/refactoring.md +15 -0
  6. package/.github/PULL_REQUEST_TEMPLATE.md +18 -0
  7. package/.github/stale.yml +17 -0
  8. package/.github/workflows/cd.yml +75 -0
  9. package/.github/workflows/ci.yml +36 -0
  10. package/.husky/pre-commit +6 -0
  11. package/.husky/pre-push +4 -0
  12. package/.idea/codeStyles/Project.xml +58 -0
  13. package/.idea/codeStyles/codeStyleConfig.xml +5 -0
  14. package/.idea/encodings.xml +7 -0
  15. package/.idea/inspectionProfiles/Project_Default.xml +7 -0
  16. package/.idea/modules.xml +8 -0
  17. package/.idea/page2pdf-server.iml +12 -0
  18. package/.idea/tenstack-starter-main.iml +12 -0
  19. package/.idea/vcs.xml +6 -0
  20. package/.prettierrc +8 -0
  21. package/.vscode/settings.json +3 -0
  22. package/LICENSE +18 -0
  23. package/README.md +238 -0
  24. package/__tests__/UrltoPdf/generatePdf.test.ts +207 -0
  25. package/__tests__/UrltoPdf/pdfSplit.test.ts +69 -0
  26. package/__tests__/helpers/index.ts +21 -0
  27. package/__tests__/home.test.ts +77 -0
  28. package/config/default.json +10 -0
  29. package/config/development.json +3 -0
  30. package/config/production.json +3 -0
  31. package/config/test.json +3 -0
  32. package/ecosystem.config.js +41 -0
  33. package/eslintrc.json +14 -0
  34. package/jest.config.js +35 -0
  35. package/nodemon.json +6 -0
  36. package/package.json +105 -0
  37. package/src/CSS/345/205/274/345/256/271/346/200/247.txt +56 -0
  38. package/src/app.ts +41 -0
  39. package/src/components/home/controller.ts +27 -0
  40. package/src/components/home/index.ts +4 -0
  41. package/src/components/home/pdfController.ts +112 -0
  42. package/src/components/home/services.ts +31 -0
  43. package/src/components/home/splitController.ts +124 -0
  44. package/src/components/home/validators.ts +12 -0
  45. package/src/configEnv/index.ts +62 -0
  46. package/src/db/home.ts +14 -0
  47. package/src/helpers/apiResponse.ts +10 -0
  48. package/src/helpers/dataSanitizers.ts +31 -0
  49. package/src/helpers/error/ApiError.ts +25 -0
  50. package/src/helpers/error/ForbiddenError.ts +15 -0
  51. package/src/helpers/error/NotFoundException.ts +15 -0
  52. package/src/helpers/error/TimeOutError.ts +20 -0
  53. package/src/helpers/error/UnauthorizedError.ts +15 -0
  54. package/src/helpers/error/ValidationError.ts +20 -0
  55. package/src/helpers/error/index.ts +15 -0
  56. package/src/helpers/index.ts +2 -0
  57. package/src/helpers/loggers.ts +73 -0
  58. package/src/index.ts +13 -0
  59. package/src/middlewares/errorHandler.ts +52 -0
  60. package/src/new_tab1.mhtml +722 -0
  61. package/src/routes/index.ts +22 -0
  62. package/src/server.ts +30 -0
  63. package/src/testCSS.html +241 -0
  64. package/src/types/global.d.ts +13 -0
  65. package/src/types/request/home.ts +166 -0
  66. package/src/types/request/split.ts +18 -0
  67. package/src/types/response/AppInformation.ts +9 -0
  68. package/src/types/response/index.ts +5 -0
  69. package/src/utils/array.ts +19 -0
  70. package/src/utils/auth.ts +12 -0
  71. package/src/utils/crypt.ts +26 -0
  72. package/src/utils/filter.ts +59 -0
  73. package/src/utils/object.ts +58 -0
  74. package/src/utils/pdfgen.ts +998 -0
  75. package/src/utils/url.ts +54 -0
  76. package/src//346/265/213/350/257/225.txt +241 -0
  77. package/tsconfig.json +41 -0
  78. package/tslint.json +22 -0
  79. package//346/226/207/344/271/246/346/211/223/345/215/260/350/275/254/346/215/242/345/231/250.bat +2 -0
@@ -0,0 +1,58 @@
1
+ import { differenceBy, intersectionBy } from "lodash-es";
2
+
3
+ /**
4
+ * Get the copy of object without attributes.
5
+ *
6
+ * @param {Object} obj
7
+ * @param {Array} attrsToExclude
8
+ * @return {Object}
9
+ */
10
+ export const withoutAttrs = (obj: any, attrsToExclude: any[]) => {
11
+ const result: any = {};
12
+
13
+ Object.keys(obj).forEach((key: string) => {
14
+ if (!attrsToExclude.includes(key)) {
15
+ result[key] = obj[key];
16
+ }
17
+ });
18
+
19
+ return result;
20
+ };
21
+
22
+ /**
23
+ * Get the copy of object with only specified attributes.
24
+ *
25
+ * @param {Object} obj
26
+ * @param {Array} attrs
27
+ * @return {Object}
28
+ */
29
+ export const withOnlyAttrs = (obj: any, attrs: any[]) => {
30
+ const result: any = {};
31
+
32
+ Object.keys(obj).forEach((key) => {
33
+ if (attrs.includes(key)) {
34
+ result[key] = obj[key];
35
+ }
36
+ });
37
+
38
+ return result;
39
+ };
40
+
41
+ /**
42
+ * Compare array of two objects and find data that needs to be create, update
43
+ * and delete.
44
+ *
45
+ * @param {Array} list1
46
+ * @param {Array} list2
47
+ * @param {String} key
48
+ * @returns {Object}
49
+ */
50
+ export const difference = (list1: any[], list2: any[], key = "id") => {
51
+ return {
52
+ create: list2
53
+ .filter((obj) => obj.hasOwnProperty(key) && obj[key] === null)
54
+ .map((obj) => withoutAttrs(obj, [key])),
55
+ update: intersectionBy(list2, list1, key),
56
+ destroy: differenceBy(list1, list2, key).map((obj: any) => obj[key]),
57
+ };
58
+ };