Skip to content

Commit 8d53913

Browse files
committed
feat: included_schemas for typegen
1 parent e5e7a82 commit 8d53913

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/server/routes/generators/typescript.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,14 @@ export default async (fastify: FastifyInstance) => {
99
Headers: { pg: string }
1010
Querystring: {
1111
excluded_schemas?: string
12+
included_schemas?: string
1213
}
1314
}>('/', async (request, reply) => {
1415
const connectionString = request.headers.pg
1516
const excludedSchemas =
1617
request.query.excluded_schemas?.split(',').map((schema) => schema.trim()) ?? []
18+
const includedSchemas =
19+
request.query.included_schemas?.split(',').map((schema) => schema.trim()) ?? []
1720

1821
const pgMeta: PostgresMeta = new PostgresMeta({ ...DEFAULT_POOL_CONFIG, connectionString })
1922
const { data: schemas, error: schemasError } = await pgMeta.schemas.list()
@@ -46,7 +49,11 @@ export default async (fastify: FastifyInstance) => {
4649
}
4750

4851
return applyTypescriptTemplate({
49-
schemas: schemas.filter(({ name }) => !excludedSchemas.includes(name)),
52+
schemas: schemas.filter(
53+
({ name }) =>
54+
!excludedSchemas.includes(name) &&
55+
(includedSchemas.length === 0 || includedSchemas.includes(name))
56+
),
5057
tables,
5158
functions,
5259
types,

0 commit comments

Comments
 (0)