chore(): start moving some packages to the core directory (#7215)

This commit is contained in:
Adrien de Peretti
2024-05-03 13:37:41 +02:00
committed by GitHub
parent fdee748eed
commit bbccd6481d
1436 changed files with 275 additions and 756 deletions

View File

@@ -0,0 +1,29 @@
type ConnectionStringOptions = {
user?: string
password?: string
host?: string
db: string
}
export function encodeDbValue(value: string): string {
return encodeURIComponent(value)
}
export default ({ user, password, host, db }: ConnectionStringOptions) => {
let connection = `postgres://`
if (user) {
connection += encodeDbValue(user)
}
if (password) {
connection += `:${encodeDbValue(password)}`
}
if (user || password) {
connection += "@"
}
connection += `${host}/${db}`
return connection
}