@opengis/fastify-table 1.5.0 → 1.5.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/dist/index.js CHANGED
@@ -89,8 +89,9 @@ async function plugin(fastify, opt) {
89
89
  loggerPlugin(fastify, opt);
90
90
  if (config.rateLimit !== false) {
91
91
  await fastify.register(import("@fastify/rate-limit"), {
92
- max: config.rateLimit?.max || 100,
93
- timeWindow: config.rateLimit?.timeWindow || "1 minute",
92
+ max: parseInt(config.rateLimit?.max || 100),
93
+ timeWindow: config.rateLimit?.timeWindow || 60000,
94
+ hook: "preHandler",
94
95
  global: true,
95
96
  keyGenerator: (req) => `${req.ip}-${req.raw.url.split("?")[0]}`,
96
97
  });
@@ -1,7 +1,8 @@
1
1
  /* eslint-disable prefer-rest-params */
2
2
  import handlebarsSync from "handlebars";
3
- // import promisedHandlebars from "promised-handlebars";
4
- const promisedHandlebars = require("promised-handlebars");
3
+ // @ts-expect-error hb cjs module
4
+ import promisedHandlebars from "promised-handlebars";
5
+ // const promisedHandlebars = require("promised-handlebars");
5
6
  import logger from "../plugins/logger/getLogger.js";
6
7
  const handlebars = promisedHandlebars(handlebarsSync);
7
8
  // funcs
@@ -0,0 +1,137 @@
1
+ syntax = "proto3";
2
+
3
+ service Convert {
4
+ rpc csvToXls(csvToXlsParams) returns (FileBase64) {}
5
+ rpc jsonToXls(jsonToXlsParams) returns (FileBase64) {}
6
+ rpc pdfMerge(pdfMergeParams) returns (FileBase64) {}
7
+ rpc htmlToPdf(htmlToPdfParams) returns (FileBase64) {}
8
+ rpc excelToJson(excelToJsonParams) returns (FileBase64) {}
9
+ rpc xmlToJson(xmlToJsonParams) returns (FileBase64) {}
10
+ rpc htmlToDoc(htmlToDocParams) returns (FileBase64) {}
11
+ rpc htmlToImage(htmlToImageParams) returns (FileBase64) {}
12
+ rpc geojsonToShp(geojsonToShpParams) returns (FileBase64) {}
13
+ rpc shpToGeojson(shpToGeojsonParams) returns (FileBase64) {}
14
+ rpc docToPDF(docToPDFParams) returns (FileBase64) {}
15
+ rpc mergeImages(mergeImagesIn) returns (FileBase64) {}
16
+ rpc resizeImage(resizeImageIn) returns (FileBase64) {}
17
+ rpc jsonToYaml(jsonToYamlIn) returns (FileBase64) {}
18
+ rpc yamlToJson(yamlToJsonIn) returns (FileBase64) {}
19
+ rpc log(log_in) returns (log_out) {}
20
+ rpc geojsonToGpkg(geojsonToShpParams) returns (FileBase64) {}
21
+ }
22
+
23
+ message jsonToYamlIn {
24
+ string json = 1;
25
+ }
26
+
27
+ message yamlToJsonIn {
28
+ string yaml = 1;
29
+ }
30
+
31
+ message resizeImageIn {
32
+ string base64 = 1;
33
+ uint64 width = 2;
34
+ uint64 height = 3;
35
+ uint32 quality = 4;
36
+ uint32 subsampling = 5;
37
+ }
38
+
39
+ message pdfToImgIn {
40
+ string pdfPath = 1;
41
+ string imgPath = 2;
42
+ }
43
+
44
+ message pdfToImgOut {
45
+ string imgPath = 1;
46
+ }
47
+
48
+ message log_in {
49
+ uint32 rows = 1;
50
+ string level = 2;
51
+ }
52
+
53
+ message log_out {
54
+ repeated string logs = 1;
55
+ }
56
+
57
+ enum mergeImageFormat {
58
+ VERTICAL = 0;
59
+ HORIZONTAL = 1;
60
+ OVERLAY = 2;
61
+ }
62
+
63
+ message imageMeta {
64
+ string base64 = 1;
65
+ mergeImageFormat mergeFormat = 2;
66
+ }
67
+
68
+ message mergeImagesIn {
69
+ repeated string images = 1;
70
+ repeated imageMeta imagesMeta = 2;
71
+ string background = 3;
72
+ string mergeFormat = 4;
73
+ }
74
+
75
+ message docToPDFParams {
76
+ string base64 = 1;
77
+ string to = 2;
78
+ string ext = 3;
79
+ }
80
+
81
+ message shpToGeojsonParams {
82
+ string base64 = 1;
83
+ }
84
+
85
+ message geojsonToShpParams {
86
+ string geojson = 1;
87
+ string proj = 2;
88
+ }
89
+
90
+ message xmlToJsonParams {
91
+ string xml = 1;
92
+ }
93
+
94
+ message jsonToXlsParams {
95
+ string json = 1;
96
+ string header = 2;
97
+ string subheader = 3;
98
+ string colmodel = 4;
99
+ }
100
+
101
+ message csvToXlsParams {
102
+ string csv = 1;
103
+ string header = 2;
104
+ string subheader = 3;
105
+ string separator = 4;
106
+ }
107
+
108
+ message excelToJsonParams {
109
+ string base64 = 1;
110
+ string type = 2;
111
+ string delimiter = 3;
112
+ string encoding = 4;
113
+ }
114
+
115
+ message htmlToPdfParams {
116
+ string html = 1;
117
+ string pdfPageConfig = 2;
118
+ }
119
+
120
+ message pdfMergeParams {
121
+ repeated string mergeFiles = 1;
122
+ }
123
+
124
+ message htmlToImageParams {
125
+ string html = 1;
126
+ string format = 2;
127
+ uint64 width = 3;
128
+ uint64 height = 4;
129
+ }
130
+
131
+ message htmlToDocParams {
132
+ string html = 1;
133
+ }
134
+
135
+ message FileBase64 {
136
+ string result = 1;
137
+ }
@@ -0,0 +1,14 @@
1
+ syntax = "proto3";
2
+
3
+ service OfficeConverterService {
4
+ rpc OfficeToPdf(OfficeToPdfRequest) returns (OfficeToPdfResponse) {}
5
+ }
6
+
7
+ message OfficeToPdfRequest {
8
+ string file = 1;
9
+ string ext = 2;
10
+ }
11
+
12
+ message OfficeToPdfResponse {
13
+ string file = 1;
14
+ }
@@ -143,18 +143,18 @@ export default function checkPolicy(req, reply) {
143
143
  return reply.status(403).send("access restricted: 4");
144
144
  }
145
145
  /* === 5. policy: site auth === */
146
- if (!validToken && !policy.includes("site") && !isAdmin) {
146
+ /* if (!validToken && !policy.includes("site") && !isAdmin) {
147
147
  logger.file("policy/site", {
148
- path,
149
- method,
150
- params,
151
- query,
152
- body,
153
- message: "access restricted: 5",
154
- uid: user?.uid,
148
+ path,
149
+ method,
150
+ params,
151
+ query,
152
+ body,
153
+ message: "access restricted: 5",
154
+ uid: user?.uid,
155
155
  });
156
156
  return reply.status(403).send("access restricted: 5");
157
- }
157
+ }*/
158
158
  /* === 6. base policy: block non-public api w/ out authorization === */
159
159
  if (!validToken && isAdmin && !config.debug && user?.uid && isServer) {
160
160
  logger.file("policy/api", {
@@ -1,5 +1,6 @@
1
1
  import { pgClients, getAdminAccess } from "../../../../utils.js";
2
2
  export default async function accessGroup({ pg = pgClients.client, params, user = {}, unittest, }, reply) {
3
+ debugger;
3
4
  if (!params?.id) {
4
5
  return reply.status(400).send("not enough params: id");
5
6
  }
@@ -1,18 +1,18 @@
1
- import loggerFile from './controllers/logger.file.js';
1
+ import loggerFile from "./controllers/logger.file.js";
2
2
  // import loggerTest from './controllers/logger.test.api.js';
3
3
  const loggerSchema = {
4
4
  querystring: {
5
- type: 'object',
5
+ type: "object",
6
6
  properties: {
7
- download: { type: 'string', pattern: '^(\\d)$' },
8
- full: { type: 'string', pattern: '^(\\d)$' },
9
- dir: { type: 'string', pattern: '^(\\d)$' },
10
- token: { type: 'string' },
7
+ download: { type: "string", pattern: "^(\\d)$" },
8
+ full: { type: "string", pattern: "^(\\d)$" },
9
+ dir: { type: "string", pattern: "^(\\d)$" },
10
+ token: { type: "string" },
11
11
  },
12
12
  additionalProperties: false,
13
13
  },
14
14
  };
15
15
  async function plugin(app) {
16
- app.get('/logger-file/*', { config: { policy: ['public'], rateLimit: false }, schema: loggerSchema }, loggerFile);
16
+ app.get("/logger-file/*", { config: { policy: ["public"], rateLimit: false }, schema: loggerSchema }, loggerFile);
17
17
  }
18
18
  export default plugin;
package/package.json CHANGED
@@ -1,71 +1,72 @@
1
- {
2
- "name": "@opengis/fastify-table",
3
- "version": "1.5.0",
4
- "type": "module",
5
- "description": "core-plugins",
6
- "keywords": [
7
- "fastify",
8
- "table",
9
- "crud",
10
- "pg",
11
- "backend"
12
- ],
13
- "main": "dist/index.js",
14
- "exports": {
15
- ".": "./dist/index.js",
16
- "./utils.js": "./dist/utils.js"
17
- },
18
- "files": [
19
- "dist/*"
20
- ],
21
- "scripts": {
22
- "prepublishOnly": "npm run build",
23
- "build": "rmdir /s /q \".\/dist\" && tsc && cp -r server/plugins/grpc/utils/*.proto dist/server/plugins/grpc/utils",
24
- "patch": "npm version patch && git push && npm publish",
25
- "lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore",
26
- "test": "node --test",
27
- "compress": "node compress.js",
28
- "dev1": "set NODE_ENV=local&& node server.js",
29
- "dev": "bun start",
30
- "start": "bun server"
31
- },
32
- "dependencies": {
33
- "@aws-sdk/client-s3": "3.879.0",
34
- "@aws-sdk/lib-storage": "3.879.0",
35
- "@fastify/http-proxy": "11.1.2",
36
- "@fastify/multipart": "9.0.3",
37
- "@fastify/rate-limit": "10.3.0",
38
- "@grpc/grpc-js": "1.10.6",
39
- "@grpc/proto-loader": "0.7.12",
40
- "better-sqlite3": "12.2.0",
41
- "dotenv": "16.5.0",
42
- "fastify": "5.3.3",
43
- "fastify-plugin": "5.0.1",
44
- "handlebars": "4.7.8",
45
- "image-size": "1.2.0",
46
- "ioredis": "5.3.2",
47
- "js-yaml": "4.1.0",
48
- "markdown-it": "14.1.0",
49
- "pg": "8.11.3",
50
- "pino": "9.5.0",
51
- "pino-abstract-transport": "2.0.0",
52
- "promised-handlebars": "2.0.1",
53
- "qrcode": "1.5.4",
54
- "uglify-js": "3.19.3"
55
- },
56
- "devDependencies": {
57
- "@types/better-sqlite3": "^7.6.13",
58
- "@types/bun": "^1.2.21",
59
- "@types/js-yaml": "^4.0.9",
60
- "@types/markdown-it": "^14.1.2",
61
- "@types/node": "^24.3.1",
62
- "@types/pg": "^8.15.5",
63
- "@types/qrcode": "^1.5.5",
64
- "eslint": "^9.35.0",
65
- "eslint-config-airbnb-extended": "^2.3.1",
66
- "ts-migrate": "^0.1.35",
67
- "typescript": "^5.9.2"
68
- },
69
- "author": "Softpro",
70
- "license": "ISC"
1
+ {
2
+ "name": "@opengis/fastify-table",
3
+ "version": "1.5.2",
4
+ "type": "module",
5
+ "description": "core-plugins",
6
+ "keywords": [
7
+ "fastify",
8
+ "table",
9
+ "crud",
10
+ "pg",
11
+ "backend"
12
+ ],
13
+ "main": "dist/index.js",
14
+ "exports": {
15
+ ".": "./dist/index.js",
16
+ "./utils.js": "./dist/utils.js"
17
+ },
18
+ "files": [
19
+ "dist/*"
20
+ ],
21
+ "scripts": {
22
+ "prepublishOnly": "npm run build",
23
+ "build": "tsc -b --clean && tsc && copyfiles server/plugins/grpc/utils/*.proto dist/server/plugins/grpc/utils",
24
+ "patch": "npm version patch && git push && npm publish",
25
+ "lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore",
26
+ "test": "node --test",
27
+ "compress": "node compress.js",
28
+ "dev1": "set NODE_ENV=local&& node server.js",
29
+ "dev": "bun start",
30
+ "start": "bun server"
31
+ },
32
+ "dependencies": {
33
+ "@aws-sdk/client-s3": "3.879.0",
34
+ "@aws-sdk/lib-storage": "3.879.0",
35
+ "@fastify/http-proxy": "11.1.2",
36
+ "@fastify/multipart": "9.0.3",
37
+ "@fastify/rate-limit": "10.3.0",
38
+ "@grpc/grpc-js": "1.10.6",
39
+ "@grpc/proto-loader": "0.7.12",
40
+ "better-sqlite3": "12.2.0",
41
+ "copyfiles": "^2.4.1",
42
+ "dotenv": "16.5.0",
43
+ "fastify": "5.3.3",
44
+ "fastify-plugin": "5.0.1",
45
+ "handlebars": "4.7.8",
46
+ "image-size": "1.2.0",
47
+ "ioredis": "5.3.2",
48
+ "js-yaml": "4.1.0",
49
+ "markdown-it": "14.1.0",
50
+ "pg": "8.11.3",
51
+ "pino": "9.5.0",
52
+ "pino-abstract-transport": "2.0.0",
53
+ "promised-handlebars": "2.0.1",
54
+ "qrcode": "1.5.4",
55
+ "uglify-js": "3.19.3"
56
+ },
57
+ "devDependencies": {
58
+ "@types/better-sqlite3": "^7.6.13",
59
+ "@types/bun": "^1.2.21",
60
+ "@types/js-yaml": "^4.0.9",
61
+ "@types/markdown-it": "^14.1.2",
62
+ "@types/node": "^24.3.1",
63
+ "@types/pg": "^8.15.5",
64
+ "@types/qrcode": "^1.5.5",
65
+ "eslint": "^9.35.0",
66
+ "eslint-config-airbnb-extended": "^2.3.1",
67
+ "ts-migrate": "^0.1.35",
68
+ "typescript": "^5.9.2"
69
+ },
70
+ "author": "Softpro",
71
+ "license": "ISC"
71
72
  }