Skip to content

Commit

Permalink
Fix Generator (#5)
Browse files Browse the repository at this point in the history
* fixup

Signed-off-by: Matteo Collina <[email protected]>

* fixup

Signed-off-by: Matteo Collina <[email protected]>

---------

Signed-off-by: Matteo Collina <[email protected]>
  • Loading branch information
mcollina authored Feb 27, 2024
1 parent e41cf06 commit 83b3b41
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions lib/generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,6 @@ const defaultConnectionString = 'postgres://postgres:[email protected]:5432/pos
// We extend ServiceGenerator instead of DBGenerator because we
// do not want to allow users to have their own migrations.
class PlatformaticPgHooksGenerator extends ServiceGenerator {
getDefaultConfig () {
const defaultBaseConfig = super.getDefaultConfig()
const defaultConfig = {
db: {
connectionString: null
}
}
return Object.assign({}, defaultBaseConfig, defaultConfig)
}

getConfigFieldsDefinitions () {
const serviceConfigFieldsDefs = super.getConfigFieldsDefinitions()
return [
Expand All @@ -38,11 +28,12 @@ class PlatformaticPgHooksGenerator extends ServiceGenerator {
async _getConfigFileContents () {
const baseConfig = await super._getConfigFileContents()
const packageJson = await this.getStackablePackageJson()
const dbUrlEnvVar = this.getEnvVarName('DB_URL')
const config = {
$schema: './stackable.schema.json',
module: packageJson.name,
db: {
connectionString: '{DATABASE_URL}'
connectionString: `{${dbUrlEnvVar}}`
},
service: undefined
}
Expand All @@ -61,7 +52,7 @@ class PlatformaticPgHooksGenerator extends ServiceGenerator {
}

this.addEnvVars({
DATABASE_URL: this.config.connectionString || defaultConnectionString
DB_URL: this.config.connectionString || defaultConnectionString
}, { overwrite: false })

const packageJson = await this.getStackablePackageJson()
Expand Down

0 comments on commit 83b3b41

Please sign in to comment.