vendure-config.hbs 4.2 KB

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