vendure-config.hbs 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. import {
  2. dummyPaymentHandler,
  3. DefaultJobQueuePlugin,
  4. DefaultSearchPlugin,
  5. VendureConfig,
  6. } from '@vendure/core';
  7. import { defaultEmailHandlers, EmailPlugin, FileBasedTemplateLoader } from '@vendure/email-plugin';
  8. import { AssetServerPlugin } from '@vendure/asset-server-plugin';
  9. import { AdminUiPlugin } from '@vendure/admin-ui-plugin';
  10. import 'dotenv/config';
  11. import path from 'path';
  12. const IS_DEV = process.env.APP_ENV === 'dev';
  13. const serverPort = +process.env.PORT || 3000;
  14. export const config: VendureConfig = {
  15. apiOptions: {
  16. port: serverPort,
  17. adminApiPath: 'admin-api',
  18. shopApiPath: 'shop-api',
  19. // The following options are useful in development mode,
  20. // but are best turned off for production for security
  21. // reasons.
  22. ...(IS_DEV ? {
  23. adminApiPlayground: {
  24. settings: { 'request.credentials': 'include' },
  25. },
  26. adminApiDebug: true,
  27. shopApiPlayground: {
  28. settings: { 'request.credentials': 'include' },
  29. },
  30. shopApiDebug: true,
  31. } : {}),
  32. },
  33. authOptions: {
  34. tokenMethod: ['bearer', 'cookie'],
  35. superadminCredentials: {
  36. identifier: process.env.SUPERADMIN_USERNAME,
  37. password: process.env.SUPERADMIN_PASSWORD,
  38. },
  39. cookieOptions: {
  40. secret: process.env.COOKIE_SECRET,
  41. },
  42. },
  43. dbConnectionOptions: {
  44. type: '{{ dbType }}',
  45. // See the README.md "Migrations" section for an explanation of
  46. // the `synchronize` and `migrations` options.
  47. synchronize: false,
  48. migrations: [path.join(__dirname, './migrations/*.+(js|ts)')],
  49. logging: false,
  50. database: {{#if isSQLjs}}new Uint8Array([]){{else if isSQLite}}path.join(__dirname, '../vendure.sqlite'){{else}}process.env.DB_NAME{{/if}},
  51. {{#if dbSchema}}
  52. schema: process.env.DB_SCHEMA,
  53. {{/if}}
  54. {{#if dbSSL}}
  55. ssl: true,
  56. {{/if}}
  57. {{#if isSQLjs}}
  58. location: path.join(__dirname, 'vendure.sqlite'),
  59. autoSave: true,
  60. {{/if}}
  61. {{#if requiresConnection}}
  62. host: process.env.DB_HOST,
  63. port: +process.env.DB_PORT,
  64. username: process.env.DB_USERNAME,
  65. password: process.env.DB_PASSWORD,
  66. {{/if}}
  67. },
  68. paymentOptions: {
  69. paymentMethodHandlers: [dummyPaymentHandler],
  70. },
  71. // When adding or altering custom field definitions, the database will
  72. // need to be updated. See the "Migrations" section in README.md.
  73. customFields: {},
  74. plugins: [
  75. AssetServerPlugin.init({
  76. route: 'assets',
  77. assetUploadDir: path.join(__dirname, '../static/assets'),
  78. // For local dev, the correct value for assetUrlPrefix should
  79. // be guessed correctly, but for production it will usually need
  80. // to be set manually to match your production url.
  81. assetUrlPrefix: IS_DEV ? undefined : 'https://www.my-shop.com/assets/',
  82. }),
  83. DefaultJobQueuePlugin.init({ useDatabaseForBuffer: true }),
  84. DefaultSearchPlugin.init({ bufferUpdates: false, indexStockStatus: true }),
  85. EmailPlugin.init({
  86. devMode: true,
  87. outputPath: path.join(__dirname, '../static/email/test-emails'),
  88. route: 'mailbox',
  89. handlers: defaultEmailHandlers,
  90. templateLoader: new FileBasedTemplateLoader(path.join(__dirname, '../static/email/templates')),
  91. globalTemplateVars: {
  92. // The following variables will change depending on your storefront implementation.
  93. // Here we are assuming a storefront running at http://localhost:8080.
  94. fromAddress: '"example" <noreply@example.com>',
  95. verifyEmailAddressUrl: 'http://localhost:8080/verify',
  96. passwordResetUrl: 'http://localhost:8080/password-reset',
  97. changeEmailAddressUrl: 'http://localhost:8080/verify-email-address-change'
  98. },
  99. }),
  100. AdminUiPlugin.init({
  101. route: 'admin',
  102. port: serverPort + 2,
  103. adminUiConfig: {
  104. apiPort: serverPort,
  105. },
  106. }),
  107. ],
  108. };