@opengis/fastify-table 1.2.63 → 1.2.65

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.63",
3
+ "version": "1.2.65",
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
 
@@ -205,7 +205,7 @@ function formatValue({
205
205
  return { op: 'ilike', query, extra };
206
206
  }
207
207
 
208
- const query = data && sql
208
+ const query = data && sql && filterType == 'text'
209
209
  ? `${name || filter?.id} in ( ( with q(id,name) as (${sql}) select id from q where ${filterType === 'autocomplete' ? 'id' : 'name'}::text ${match}) )` // filter with cls
210
210
  : `${name}::text ${match}`; // simple filter
211
211
  // console.log(query);