diff --git a/packages/create/src/gather-user-responses.ts b/packages/create/src/gather-user-responses.ts index 4481d6c4b1..d156116cc5 100644 --- a/packages/create/src/gather-user-responses.ts +++ b/packages/create/src/gather-user-responses.ts @@ -14,6 +14,7 @@ interface PromptAnswers { dbSchema?: string | symbol; dbUserName: string | symbol; dbPassword: string | symbol; + dbSSL?: boolean | symbol; superadminIdentifier: string | symbol; superadminPassword: string | symbol; populateProducts: boolean | symbol; @@ -72,6 +73,18 @@ export async function gatherUserResponses( }) : ''; checkCancel(dbSchema); + const dbSSL = + dbType === 'postgres' + ? await select({ + message: 'Use SSL to connect to the database?', + options: [ + { label: 'no', value: false }, + { label: 'yes', value: true }, + ], + initialValue: false, + }) + : false; + checkCancel(dbSSL); const dbUserName = hasConnection ? await text({ message: "What's the database user name?", @@ -113,6 +126,7 @@ export async function gatherUserResponses( dbSchema, dbUserName, dbPassword, + dbSSL, superadminIdentifier, superadminPassword, populateProducts, diff --git a/packages/create/src/helpers.ts b/packages/create/src/helpers.ts index 84b8f0ec52..0bb21e5700 100644 --- a/packages/create/src/helpers.ts +++ b/packages/create/src/helpers.ts @@ -352,6 +352,7 @@ async function checkPostgresDbExists(options: any, root: string): Promise port: options.port, database: options.database, schema: options.schema, + ssl: options.ssl, }; const client = new Client(connectionOptions); diff --git a/packages/create/templates/vendure-config.hbs b/packages/create/templates/vendure-config.hbs index 0ba38b8204..94a08b1ce2 100644 --- a/packages/create/templates/vendure-config.hbs +++ b/packages/create/templates/vendure-config.hbs @@ -52,6 +52,9 @@ export const config: VendureConfig = { {{#if dbSchema}} schema: process.env.DB_SCHEMA, {{/if}} + {{#if dbSSL}} + ssl: true, + {{/if}} {{#if isSQLjs}} location: path.join(__dirname, 'vendure.sqlite'), autoSave: true,