1
1
import { FastifyInstance } from 'fastify'
2
2
import { PostgresMeta } from '../../lib'
3
+ import { DEFAULT_POOL_CONFIG } from '../constants'
3
4
4
5
export default async ( fastify : FastifyInstance ) => {
5
6
fastify . get < {
@@ -11,7 +12,7 @@ export default async (fastify: FastifyInstance) => {
11
12
const connectionString = request . headers . pg
12
13
const includeSystemSchemas = request . query . include_system_schemas === 'true'
13
14
14
- const pgMeta = new PostgresMeta ( { connectionString , max : 1 } )
15
+ const pgMeta = new PostgresMeta ( { ... DEFAULT_POOL_CONFIG , connectionString } )
15
16
const { data, error } = await pgMeta . columns . list ( {
16
17
includeSystemSchemas,
17
18
} )
@@ -33,7 +34,7 @@ export default async (fastify: FastifyInstance) => {
33
34
} > ( '/:id(\\d+\\.\\d+)' , async ( request , reply ) => {
34
35
const connectionString = request . headers . pg
35
36
36
- const pgMeta = new PostgresMeta ( { connectionString , max : 1 } )
37
+ const pgMeta = new PostgresMeta ( { ... DEFAULT_POOL_CONFIG , connectionString } )
37
38
const { data, error } = await pgMeta . columns . retrieve ( { id : request . params . id } )
38
39
await pgMeta . end ( )
39
40
if ( error ) {
@@ -52,7 +53,7 @@ export default async (fastify: FastifyInstance) => {
52
53
} > ( '/' , async ( request , reply ) => {
53
54
const connectionString = request . headers . pg
54
55
55
- const pgMeta = new PostgresMeta ( { connectionString , max : 1 } )
56
+ const pgMeta = new PostgresMeta ( { ... DEFAULT_POOL_CONFIG , connectionString } )
56
57
const { data, error } = await pgMeta . columns . create ( request . body )
57
58
await pgMeta . end ( )
58
59
if ( error ) {
@@ -74,7 +75,7 @@ export default async (fastify: FastifyInstance) => {
74
75
} > ( '/:id(\\d+\\.\\d+)' , async ( request , reply ) => {
75
76
const connectionString = request . headers . pg
76
77
77
- const pgMeta = new PostgresMeta ( { connectionString , max : 1 } )
78
+ const pgMeta = new PostgresMeta ( { ... DEFAULT_POOL_CONFIG , connectionString } )
78
79
const { data, error } = await pgMeta . columns . update ( request . params . id , request . body )
79
80
await pgMeta . end ( )
80
81
if ( error ) {
@@ -98,7 +99,7 @@ export default async (fastify: FastifyInstance) => {
98
99
} > ( '/:id(\\d+\\.\\d+)' , async ( request , reply ) => {
99
100
const connectionString = request . headers . pg
100
101
101
- const pgMeta = new PostgresMeta ( { connectionString , max : 1 } )
102
+ const pgMeta = new PostgresMeta ( { ... DEFAULT_POOL_CONFIG , connectionString } )
102
103
const { data, error } = await pgMeta . columns . remove ( request . params . id )
103
104
await pgMeta . end ( )
104
105
if ( error ) {
0 commit comments