@opengis/fastify-table 1.4.52 → 1.4.53
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/index.js
CHANGED
|
@@ -105,12 +105,14 @@ async function plugin(fastify, opt) {
|
|
|
105
105
|
cronPlugin(fastify, opt);
|
|
106
106
|
loggerPlugin(fastify, opt);
|
|
107
107
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
108
|
+
if (config.rateLimit !== false) {
|
|
109
|
+
await fastify.register(import('@fastify/rate-limit'), {
|
|
110
|
+
max: config.rateLimit?.max || 100,
|
|
111
|
+
timeWindow: config.rateLimit?.timeWindow || '1 minute',
|
|
112
|
+
global: true,
|
|
113
|
+
keyGenerator: (req) => `${req.ip}-${req.raw.url.split('?')[0]}`,
|
|
114
|
+
});
|
|
115
|
+
}
|
|
114
116
|
|
|
115
117
|
if (config.dblist) {
|
|
116
118
|
dblistRoutes(fastify, opt);
|
package/package.json
CHANGED
|
@@ -22,7 +22,7 @@ function getExtraQuery(mainColumns, schema, table, pk) {
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
export default async function getFilterSQL({
|
|
25
|
-
table, filter, pg = pgClients.client, search, filterList, query, custom, state, uid, objectId,
|
|
25
|
+
table, filter, pg = pgClients.client, search, filterList, query, custom, state, uid, objectId, order,
|
|
26
26
|
}) {
|
|
27
27
|
if (!table) return { error: 'param table is required', status: 400 };
|
|
28
28
|
|
|
@@ -141,7 +141,7 @@ export default async function getFilterSQL({
|
|
|
141
141
|
body, extraSqlColumns, table, q,
|
|
142
142
|
};
|
|
143
143
|
|
|
144
|
-
const optimizedSQL = `select * from ${getOptimizedQuery(obj)} `;
|
|
144
|
+
const optimizedSQL = `select * from ${getOptimizedQuery(obj)} ${order ? `order by ${order}` : ''}`;
|
|
145
145
|
const tableCount = getOptimizedQuery(obj, true);
|
|
146
146
|
|
|
147
147
|
return {
|
|
@@ -15,7 +15,7 @@ export default function formatValue({
|
|
|
15
15
|
if (filterType === 'text' && value && filter?.columns) {
|
|
16
16
|
const columns = filter.columns.split(',');
|
|
17
17
|
const sval = `ilike '%${decodeURIComponent(value.replace(/%/g, '%25')).replace(/%/g, '\\%')}%'`;
|
|
18
|
-
const query =
|
|
18
|
+
const query = `(${columns.map(el => `"${el}" ${sval}`).join(' or ')})`;
|
|
19
19
|
return { op: '~', query };
|
|
20
20
|
}
|
|
21
21
|
|
|
@@ -30,10 +30,10 @@ async function plugin(app, config = {}) {
|
|
|
30
30
|
app.get(`${prefix}/suggest/:data`, {
|
|
31
31
|
config: {
|
|
32
32
|
policy,
|
|
33
|
-
rateLimit: {
|
|
34
|
-
max: 10000,
|
|
35
|
-
timeWindow: '1 minute',
|
|
36
|
-
},
|
|
33
|
+
rateLimit: config.rateLimit ? {
|
|
34
|
+
max: config.rateLimit?.suggest?.max || 10000,
|
|
35
|
+
timeWindow: config.rateLimit?.suggest?.timeWindow || '1 minute',
|
|
36
|
+
} : undefined,
|
|
37
37
|
},
|
|
38
38
|
schema: suggestSchema,
|
|
39
39
|
}, suggest);
|