dev-config.ts 3.8 KB

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