dev-config.ts 3.9 KB

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