dev-config.ts 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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. examplePaymentHandler,
  10. LanguageCode,
  11. LogLevel,
  12. VendureConfig,
  13. } from '@vendure/core';
  14. import { ElasticsearchPlugin } from '@vendure/elasticsearch-plugin';
  15. import { defaultEmailHandlers, EmailPlugin } from '@vendure/email-plugin';
  16. import path from 'path';
  17. import { ConnectionOptions } from 'typeorm';
  18. /**
  19. * Config settings used during development
  20. */
  21. export const devConfig: VendureConfig = {
  22. apiOptions: {
  23. port: API_PORT,
  24. adminApiPath: ADMIN_API_PATH,
  25. adminApiPlayground: {
  26. settings: {
  27. 'request.credentials': 'include',
  28. } as any,
  29. },
  30. adminApiDebug: true,
  31. shopApiPath: SHOP_API_PATH,
  32. shopApiPlayground: {
  33. settings: {
  34. 'request.credentials': 'include',
  35. } as any,
  36. },
  37. shopApiDebug: true,
  38. },
  39. authOptions: {
  40. disableAuth: false,
  41. sessionSecret: 'some-secret',
  42. requireVerification: true,
  43. },
  44. dbConnectionOptions: {
  45. synchronize: false,
  46. logging: false,
  47. migrations: [path.join(__dirname, 'migrations/*.ts')],
  48. ...getDbConfig(),
  49. },
  50. paymentOptions: {
  51. paymentMethodHandlers: [examplePaymentHandler],
  52. },
  53. customFields: {},
  54. logger: new DefaultLogger({ level: LogLevel.Info }),
  55. importExportOptions: {
  56. importAssetsDir: path.join(__dirname, 'import-assets'),
  57. },
  58. plugins: [
  59. AssetServerPlugin.init({
  60. route: 'assets',
  61. assetUploadDir: path.join(__dirname, 'assets'),
  62. port: 5002,
  63. }),
  64. DefaultSearchPlugin,
  65. DefaultJobQueuePlugin,
  66. // ElasticsearchPlugin.init({
  67. // host: 'http://192.168.99.100',
  68. // port: 9200,
  69. // }),
  70. EmailPlugin.init({
  71. devMode: true,
  72. handlers: defaultEmailHandlers,
  73. templatePath: path.join(__dirname, '../email-plugin/templates'),
  74. outputPath: path.join(__dirname, 'test-emails'),
  75. mailboxPort: 5003,
  76. globalTemplateVars: {
  77. verifyEmailAddressUrl: 'http://localhost:4201/verify',
  78. passwordResetUrl: 'http://localhost:4201/reset-password',
  79. changeEmailAddressUrl: 'http://localhost:4201/change-email-address',
  80. },
  81. }),
  82. AdminUiPlugin.init({
  83. port: 5001,
  84. }),
  85. ],
  86. };
  87. function getDbConfig(): ConnectionOptions {
  88. const dbType = process.env.DB || 'mysql';
  89. switch (dbType) {
  90. case 'postgres':
  91. console.log('Using postgres connection');
  92. return {
  93. synchronize: true,
  94. type: 'postgres',
  95. host: '127.0.0.1',
  96. port: 5432,
  97. username: 'admin',
  98. password: 'secret',
  99. database: 'vendure-dev',
  100. };
  101. case 'sqlite':
  102. console.log('Using sqlite connection');
  103. return {
  104. synchronize: false,
  105. type: 'sqlite',
  106. database: path.join(__dirname, 'vendure.sqlite'),
  107. };
  108. case 'sqljs':
  109. console.log('Using sql.js connection');
  110. return {
  111. type: 'sqljs',
  112. autoSave: true,
  113. database: new Uint8Array([]),
  114. location: path.join(__dirname, 'vendure.sqlite'),
  115. };
  116. case 'mysql':
  117. default:
  118. console.log('Using mysql connection');
  119. return {
  120. synchronize: true,
  121. type: 'mysql',
  122. host: '127.0.0.1',
  123. port: 3306,
  124. username: 'root',
  125. password: '',
  126. database: 'vendure-dev',
  127. };
  128. }
  129. }