dev-config.ts 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. /* tslint:disable:no-console */
  2. import { AdminUiPlugin } from '@vendure/admin-ui-plugin';
  3. import { AssetServerPlugin } from '@vendure/asset-server-plugin';
  4. import { ADMIN_API_PATH, API_PORT, SHOP_API_PATH } from '@vendure/common/lib/shared-constants';
  5. import {
  6. DefaultJobQueuePlugin,
  7. DefaultLogger,
  8. DefaultSearchPlugin,
  9. dummyPaymentHandler,
  10. LogLevel,
  11. VendureConfig,
  12. } from '@vendure/core';
  13. import { ElasticsearchPlugin } from '@vendure/elasticsearch-plugin';
  14. import { defaultEmailHandlers, EmailPlugin } from '@vendure/email-plugin';
  15. import { BullMQJobQueuePlugin } from '@vendure/job-queue-plugin/package/bullmq';
  16. import path from 'path';
  17. import { DataSourceOptions } from 'typeorm';
  18. import { MultivendorPlugin } from './test-plugins/multivendor-plugin/multivendor.plugin';
  19. /**
  20. * Config settings used during development
  21. */
  22. export const devConfig: VendureConfig = {
  23. apiOptions: {
  24. port: API_PORT,
  25. adminApiPath: ADMIN_API_PATH,
  26. adminApiPlayground: {
  27. settings: {
  28. 'request.credentials': 'include',
  29. } as any,
  30. },
  31. adminApiDebug: true,
  32. shopApiPath: SHOP_API_PATH,
  33. shopApiPlayground: {
  34. settings: {
  35. 'request.credentials': 'include',
  36. } as any,
  37. },
  38. shopApiDebug: true,
  39. },
  40. authOptions: {
  41. disableAuth: false,
  42. tokenMethod: ['bearer', 'cookie'] as const,
  43. requireVerification: true,
  44. customPermissions: [],
  45. cookieOptions: {
  46. secret: 'abc',
  47. },
  48. },
  49. dbConnectionOptions: {
  50. synchronize: false,
  51. logging: false,
  52. migrations: [path.join(__dirname, 'migrations/*.ts')],
  53. ...getDbConfig(),
  54. },
  55. paymentOptions: {
  56. paymentMethodHandlers: [dummyPaymentHandler],
  57. },
  58. customFields: {},
  59. logger: new DefaultLogger({ level: LogLevel.Verbose }),
  60. importExportOptions: {
  61. importAssetsDir: path.join(__dirname, 'import-assets'),
  62. },
  63. plugins: [
  64. // MultivendorPlugin,
  65. AssetServerPlugin.init({
  66. route: 'assets',
  67. assetUploadDir: path.join(__dirname, 'assets'),
  68. }),
  69. DefaultSearchPlugin.init({ bufferUpdates: false, indexStockStatus: false }),
  70. BullMQJobQueuePlugin.init({}),
  71. // DefaultJobQueuePlugin.init({}),
  72. // JobQueueTestPlugin.init({ queueCount: 10 }),
  73. // ElasticsearchPlugin.init({
  74. // host: 'http://localhost',
  75. // port: 9200,
  76. // bufferUpdates: true,
  77. // }),
  78. EmailPlugin.init({
  79. devMode: true,
  80. route: 'mailbox',
  81. handlers: defaultEmailHandlers,
  82. templatePath: path.join(__dirname, '../email-plugin/templates'),
  83. outputPath: path.join(__dirname, 'test-emails'),
  84. globalTemplateVars: {
  85. verifyEmailAddressUrl: 'http://localhost:4201/verify',
  86. passwordResetUrl: 'http://localhost:4201/reset-password',
  87. changeEmailAddressUrl: 'http://localhost:4201/change-email-address',
  88. },
  89. }),
  90. AdminUiPlugin.init({
  91. route: 'admin',
  92. port: 5001,
  93. }),
  94. ],
  95. };
  96. function getDbConfig(): DataSourceOptions {
  97. const dbType = process.env.DB || 'mysql';
  98. switch (dbType) {
  99. case 'postgres':
  100. console.log('Using postgres connection');
  101. return {
  102. synchronize: true,
  103. type: 'postgres',
  104. host: '127.0.0.1',
  105. port: 5432,
  106. username: 'admin',
  107. password: 'secret',
  108. database: 'vendure-dev',
  109. };
  110. case 'sqlite':
  111. console.log('Using sqlite connection');
  112. return {
  113. synchronize: false,
  114. type: 'better-sqlite3',
  115. database: path.join(__dirname, 'vendure.sqlite'),
  116. };
  117. case 'sqljs':
  118. console.log('Using sql.js connection');
  119. return {
  120. type: 'sqljs',
  121. autoSave: true,
  122. database: new Uint8Array([]),
  123. location: path.join(__dirname, 'vendure.sqlite'),
  124. };
  125. case 'mysql':
  126. default:
  127. console.log('Using mysql connection');
  128. return {
  129. synchronize: true,
  130. type: 'mariadb',
  131. host: '127.0.0.1',
  132. port: 3306,
  133. username: 'root',
  134. password: '',
  135. database: 'vendure-dev',
  136. };
  137. }
  138. }