@opengis/fastify-table 1.2.62 → 1.2.64

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": "@opengis/fastify-table",
3
- "version": "1.2.62",
3
+ "version": "1.2.64",
4
4
  "type": "module",
5
5
  "description": "core-plugins",
6
6
  "keywords": [
@@ -1,4 +1,6 @@
1
1
  import errorMessage from './errorMessage.js';
2
+ import logger from './getLogger.js';
3
+ import pgClients from '../pg/pgClients.js';
2
4
 
3
5
  async function plugin(fastify) {
4
6
  fastify.setErrorHandler(async (error, request, reply) => {
@@ -17,5 +19,8 @@ async function plugin(fastify) {
17
19
 
18
20
  return reply.status(error.statusCode || 500).send(msg);
19
21
  });
22
+ fastify.addHook('onListen', async () => {
23
+ logger.file('init', { db: pgClients.client?.options?.database });
24
+ });
20
25
  }
21
26
  export default plugin;
@@ -1,6 +1,8 @@
1
1
  import pgClients from './pgClients.js';
2
2
  import getPGAsync from './funcs/getPGAsync.js';
3
3
 
4
+ import logger from '../logger/getLogger.js';
5
+
4
6
  function close() {
5
7
  Object.keys(pgClients).forEach((el) => {
6
8
  pgClients[el].end();
@@ -29,6 +31,12 @@ async function plugin(fastify, config) {
29
31
  }
30
32
  });
31
33
 
34
+ fastify.addHook('onError', async (req, reply, err) => {
35
+ if (err.message === 'canceling statement due to statement timeout') {
36
+ logger.file('timeout/request', { method: req.method, url: req.url, referer: req.headers?.referer, stack: err.stack });
37
+ }
38
+ });
39
+
32
40
  fastify.addHook('onClose', close);
33
41
  }
34
42
 
@@ -44,7 +44,7 @@ export default async function filterAPI(req) {
44
44
 
45
45
  filters?.forEach?.(el => Object.assign(el, { id: el.id || el.name }));
46
46
 
47
- await Promise.all(filters.filter((el) => el.data && el.id).map(async (el) => {
47
+ await Promise.all(filters.filter((el) => el.data && el.id && el.type !== 'Autocomplete').map(async (el) => {
48
48
  const cls = await getSelect(el.data, pg);
49
49
 
50
50
  if (!cls || !loadTable.table) return;