dev-config.ts 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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. tokenMethod: 'cookie',
  42. sessionSecret: 'some-secret',
  43. requireVerification: true,
  44. },
  45. dbConnectionOptions: {
  46. synchronize: false,
  47. logging: false,
  48. migrations: [path.join(__dirname, 'migrations/*.ts')],
  49. ...getDbConfig(),
  50. },
  51. paymentOptions: {
  52. paymentMethodHandlers: [examplePaymentHandler],
  53. },
  54. customFields: {},
  55. logger: new DefaultLogger({ level: LogLevel.Info }),
  56. importExportOptions: {
  57. importAssetsDir: path.join(__dirname, 'import-assets'),
  58. },
  59. plugins: [
  60. AssetServerPlugin.init({
  61. route: 'assets',
  62. assetUploadDir: path.join(__dirname, 'assets'),
  63. port: 5002,
  64. }),
  65. DefaultSearchPlugin,
  66. DefaultJobQueuePlugin,
  67. // ElasticsearchPlugin.init({
  68. // host: 'http://192.168.99.100',
  69. // port: 9200,
  70. // }),
  71. EmailPlugin.init({
  72. devMode: true,
  73. handlers: defaultEmailHandlers,
  74. templatePath: path.join(__dirname, '../email-plugin/templates'),
  75. outputPath: path.join(__dirname, 'test-emails'),
  76. mailboxPort: 5003,
  77. globalTemplateVars: {
  78. verifyEmailAddressUrl: 'http://localhost:4201/verify',
  79. passwordResetUrl: 'http://localhost:4201/reset-password',
  80. changeEmailAddressUrl: 'http://localhost:4201/change-email-address',
  81. },
  82. }),
  83. AdminUiPlugin.init({
  84. port: 5001,
  85. }),
  86. ],
  87. };
  88. function getDbConfig(): ConnectionOptions {
  89. const dbType = process.env.DB || 'mysql';
  90. switch (dbType) {
  91. case 'postgres':
  92. console.log('Using postgres connection');
  93. return {
  94. synchronize: true,
  95. type: 'postgres',
  96. host: '127.0.0.1',
  97. port: 5432,
  98. username: 'admin',
  99. password: 'secret',
  100. database: 'vendure-dev',
  101. };
  102. case 'sqlite':
  103. console.log('Using sqlite connection');
  104. return {
  105. synchronize: false,
  106. type: 'sqlite',
  107. database: path.join(__dirname, 'vendure.sqlite'),
  108. };
  109. case 'sqljs':
  110. console.log('Using sql.js connection');
  111. return {
  112. type: 'sqljs',
  113. autoSave: true,
  114. database: new Uint8Array([]),
  115. location: path.join(__dirname, 'vendure.sqlite'),
  116. };
  117. case 'mysql':
  118. default:
  119. console.log('Using mysql connection');
  120. return {
  121. synchronize: false,
  122. type: 'mysql',
  123. host: '127.0.0.1',
  124. port: 3306,
  125. username: 'root',
  126. password: '',
  127. database: 'vendure-dev',
  128. };
  129. }
  130. }