-
-
Notifications
You must be signed in to change notification settings - Fork 112
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat(typegen): add route for go * feat(typegen): cleanup server.ts and set up local typegen for go * feat(typegen): create go table structs * feat(typegen): create go view/matview structs * feat(typegen): create go composite type structs * feat(typegen): go: handle range types * feat(typegen): go: test * feat(typegen): go: format * feat(typegen): separate go types by operation and add nullable types * feat(typegen): go: format * feat(typegen): go: handle empty tables * chore: update snapshot --------- Co-authored-by: Bobbie Soedirgo <[email protected]>
- Loading branch information
1 parent
e49ebcd
commit 9b6a6af
Showing
7 changed files
with
1,097 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import type { FastifyInstance } from 'fastify' | ||
import { PostgresMeta } from '../../../lib/index.js' | ||
import { DEFAULT_POOL_CONFIG } from '../../constants.js' | ||
import { extractRequestForLogging } from '../../utils.js' | ||
import { apply as applyGoTemplate } from '../../templates/go.js' | ||
import { getGeneratorMetadata } from '../../../lib/generators.js' | ||
|
||
export default async (fastify: FastifyInstance) => { | ||
fastify.get<{ | ||
Headers: { pg: string } | ||
Querystring: { | ||
excluded_schemas?: string | ||
included_schemas?: string | ||
} | ||
}>('/', async (request, reply) => { | ||
const connectionString = request.headers.pg | ||
const excludedSchemas = | ||
request.query.excluded_schemas?.split(',').map((schema) => schema.trim()) ?? [] | ||
const includedSchemas = | ||
request.query.included_schemas?.split(',').map((schema) => schema.trim()) ?? [] | ||
|
||
const pgMeta: PostgresMeta = new PostgresMeta({ ...DEFAULT_POOL_CONFIG, connectionString }) | ||
const { data: generatorMeta, error: generatorMetaError } = await getGeneratorMetadata(pgMeta, { | ||
includedSchemas, | ||
excludedSchemas, | ||
}) | ||
if (generatorMetaError) { | ||
request.log.error({ error: generatorMetaError, request: extractRequestForLogging(request) }) | ||
reply.code(500) | ||
return { error: generatorMetaError.message } | ||
} | ||
|
||
return applyGoTemplate(generatorMeta) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.