vendure-config.hbs 4.1 KB

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