vendure-config.hbs 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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 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. AssetServerPlugin.init({
  72. route: 'assets',
  73. assetUploadDir: path.join(__dirname, '../static/assets'),
  74. // For local dev, the correct value for assetUrlPrefix should
  75. // be guessed correctly, but for production it will usually need
  76. // to be set manually to match your production url.
  77. assetUrlPrefix: IS_DEV ? undefined : 'https://www.my-shop.com/assets/',
  78. }),
  79. DefaultJobQueuePlugin.init({ useDatabaseForBuffer: true }),
  80. DefaultSearchPlugin.init({ bufferUpdates: false, indexStockStatus: true }),
  81. EmailPlugin.init({
  82. devMode: true,
  83. outputPath: path.join(__dirname, '../static/email/test-emails'),
  84. route: 'mailbox',
  85. handlers: defaultEmailHandlers,
  86. templatePath: path.join(__dirname, '../static/email/templates'),
  87. globalTemplateVars: {
  88. // The following variables will change depending on your storefront implementation.
  89. // Here we are assuming a storefront running at http://localhost:8080.
  90. fromAddress: '"example" <noreply@example.com>',
  91. verifyEmailAddressUrl: 'http://localhost:8080/verify',
  92. passwordResetUrl: 'http://localhost:8080/password-reset',
  93. changeEmailAddressUrl: 'http://localhost:8080/verify-email-address-change'
  94. },
  95. }),
  96. AdminUiPlugin.init({
  97. route: 'admin',
  98. port: 3002,
  99. adminUiConfig: {
  100. apiPort: 3000,
  101. },
  102. }),
  103. ],
  104. };