File tree Expand file tree Collapse file tree 2 files changed +7
-6
lines changed
Expand file tree Collapse file tree 2 files changed +7
-6
lines changed Original file line number Diff line number Diff line change 11import type { FastifyInstance } from 'fastify'
22import { PostgresMeta } from '../../../lib/index.js'
3- import { DEFAULT_POOL_CONFIG } from '../../constants.js'
4- import { extractRequestForLogging } from '../../utils.js'
3+ import { createConnectionConfig , extractRequestForLogging } from '../../utils.js'
54import { apply as applyPyTemplate } from '../../templates/python.js'
65import { getGeneratorMetadata } from '../../../lib/generators.js'
76
87export default async ( fastify : FastifyInstance ) => {
98 fastify . get < {
10- Headers : { pg : string }
9+ Headers : { pg : string ; 'x-pg-application-name' ?: string }
1110 Querystring : {
1211 excluded_schemas ?: string
1312 included_schemas ?: string
1413 }
1514 } > ( '/' , async ( request , reply ) => {
16- const connectionString = request . headers . pg
15+ const config = createConnectionConfig ( request )
1716 const excludedSchemas =
1817 request . query . excluded_schemas ?. split ( ',' ) . map ( ( schema ) => schema . trim ( ) ) ?? [ ]
1918 const includedSchemas =
2019 request . query . included_schemas ?. split ( ',' ) . map ( ( schema ) => schema . trim ( ) ) ?? [ ]
21-
22- const pgMeta : PostgresMeta = new PostgresMeta ( { ...DEFAULT_POOL_CONFIG , connectionString } )
20+ const pgMeta : PostgresMeta = new PostgresMeta ( config )
2321 const { data : generatorMeta , error : generatorMetaError } = await getGeneratorMetadata ( pgMeta , {
2422 includedSchemas,
2523 excludedSchemas,
Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ import {
1818import { apply as applyTypescriptTemplate } from './templates/typescript.js'
1919import { apply as applyGoTemplate } from './templates/go.js'
2020import { apply as applySwiftTemplate } from './templates/swift.js'
21+ import { apply as applyPythonTemplate } from './templates/python.js'
2122
2223const logger = pino ( {
2324 formatters : {
@@ -143,6 +144,8 @@ async function getTypeOutput(): Promise<string | null> {
143144 } )
144145 case 'go' :
145146 return applyGoTemplate ( config )
147+ case 'python' :
148+ return applyPythonTemplate ( config )
146149 default :
147150 throw new Error ( `Unsupported language for GENERATE_TYPES: ${ GENERATE_TYPES } ` )
148151 }
You can’t perform that action at this time.
0 commit comments