dev-config.ts 3.7 KB

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