@@ -2,7 +2,7 @@ import * as path from 'path'
22import express from 'express'
33import cors from 'cors'
44import { ZenStackMiddleware } from '@zenstackhq/server/express'
5- import { GeneratorConfig , ZModelConfig } from './zmodel-parser'
5+ import { ZModelConfig } from './zmodel-parser'
66import { getNodeModulesFolder , getPrismaVersion , getZenStackVersion } from './utils/version-utils'
77import { blue , grey } from 'colors'
88import semver from 'semver'
@@ -46,6 +46,22 @@ function resolveSQLitePath(filePath: string, prismaSchemaDir: string): string {
4646 return path . join ( prismaSchemaDir , filePath )
4747}
4848
49+ function redactDatabaseUrl ( url : string ) : string {
50+ try {
51+ const parsedUrl = new URL ( url )
52+ if ( parsedUrl . password ) {
53+ parsedUrl . password = '***'
54+ }
55+ if ( parsedUrl . username ) {
56+ parsedUrl . username = '***'
57+ }
58+ return parsedUrl . toString ( )
59+ } catch {
60+ // If URL parsing fails, return the original (might be a file path for SQLite)
61+ return url
62+ }
63+ }
64+
4965/**
5066 * Create database adapter based on provider
5167 */
@@ -79,7 +95,7 @@ function createAdapter(config: ZModelConfig, zmodelSchemaDir: string): any {
7995 case 'postgresql' : {
8096 try {
8197 const { PrismaPg } = require ( '@prisma/adapter-pg' )
82- console . log ( grey ( `Connecting to PostgreSQL database at: ${ url } ` ) )
98+ console . log ( grey ( `Connecting to PostgreSQL database at: ${ redactDatabaseUrl ( url ) } ` ) )
8399 return new PrismaPg ( { connectionString : url } )
84100 } catch ( error ) {
85101 throw new CliError (
@@ -90,7 +106,7 @@ function createAdapter(config: ZModelConfig, zmodelSchemaDir: string): any {
90106 case 'mysql' : {
91107 try {
92108 const { PrismaMariaDB } = require ( '@prisma/adapter-mariadb' )
93- console . log ( grey ( `Connecting to MySQL/MariaDB database at: ${ url } ` ) )
109+ console . log ( grey ( `Connecting to MySQL/MariaDB database at: ${ redactDatabaseUrl ( url ) } ` ) )
94110 return new PrismaMariaDB ( {
95111 url,
96112 } )
0 commit comments