vendure-config.hbs 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. import {
  2. dummyPaymentHandler,
  3. DefaultJobQueuePlugin,
  4. DefaultSearchPlugin,
  5. VendureConfig,
  6. } from '@vendure/core';
  7. import { defaultEmailHandlers, EmailPlugin } 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. export const config: VendureConfig = {
  14. apiOptions: {
  15. port: 3000,
  16. adminApiPath: 'admin-api',
  17. shopApiPath: 'shop-api',
  18. // The following options are useful in development mode,
  19. // but are best turned off for production for security
  20. // reasons.
  21. ...(IS_DEV ? {
  22. adminApiPlayground: {
  23. settings: { 'request.credentials': 'include' },
  24. },
  25. adminApiDebug: true,
  26. shopApiPlayground: {
  27. settings: { 'request.credentials': 'include' },
  28. },
  29. shopApiDebug: true,
  30. } : {}),
  31. },
  32. authOptions: {
  33. tokenMethod: ['bearer', 'cookie'],
  34. superadminCredentials: {
  35. identifier: process.env.SUPERADMIN_USERNAME,
  36. password: process.env.SUPERADMIN_PASSWORD,
  37. },
  38. cookieOptions: {
  39. secret: process.env.COOKIE_SECRET,
  40. },
  41. },
  42. dbConnectionOptions: {
  43. type: '{{ dbType }}',
  44. // See the README.md "Migrations" section for an explanation of
  45. // the `synchronize` and `migrations` options.
  46. synchronize: false,
  47. migrations: [path.join(__dirname, './migrations/*.+(js|ts)')],
  48. logging: false,
  49. database: {{#if isSQLjs}}new Uint8Array([]){{else if isSQLite}}path.join(__dirname, '../vendure.sqlite'){{else}}process.env.DB_NAME{{/if}},
  50. {{#if dbSchema}}
  51. schema: process.env.DB_SCHEMA,
  52. {{/if}}
  53. {{#if dbSSL}}
  54. ssl: true,
  55. {{/if}}
  56. {{#if isSQLjs}}
  57. location: path.join(__dirname, 'vendure.sqlite'),
  58. autoSave: true,
  59. {{/if}}
  60. {{#if requiresConnection}}
  61. host: process.env.DB_HOST,
  62. port: +process.env.DB_PORT,
  63. username: process.env.DB_USERNAME,
  64. password: process.env.DB_PASSWORD,
  65. {{/if}}
  66. },
  67. paymentOptions: {
  68. paymentMethodHandlers: [dummyPaymentHandler],
  69. },
  70. // When adding or altering custom field definitions, the database will
  71. // need to be updated. See the "Migrations" section in README.md.
  72. customFields: {},
  73. plugins: [
  74. AssetServerPlugin.init({
  75. route: 'assets',
  76. assetUploadDir: path.join(__dirname, '../static/assets'),
  77. // For local dev, the correct value for assetUrlPrefix should
  78. // be guessed correctly, but for production it will usually need
  79. // to be set manually to match your production url.
  80. assetUrlPrefix: IS_DEV ? undefined : 'https://www.my-shop.com/assets/',
  81. }),
  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. templatePath: 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: 3002,
  102. adminUiConfig: {
  103. apiPort: 3000,
  104. },
  105. }),
  106. ],
  107. };