1
0

dev-config.ts 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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. DefaultLogger,
  7. DefaultSearchPlugin,
  8. examplePaymentHandler,
  9. LogLevel,
  10. VendureConfig,
  11. } from '@vendure/core';
  12. import { defaultEmailHandlers, EmailPlugin } from '@vendure/email-plugin';
  13. import path from 'path';
  14. import { ConnectionOptions } from 'typeorm';
  15. import { UiPlugin } from './ui-plugin/ui-plugin';
  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. // ElasticsearchPlugin.init({
  55. // host: 'http://192.168.99.100',
  56. // port: 9200,
  57. // }),
  58. EmailPlugin.init({
  59. devMode: true,
  60. handlers: defaultEmailHandlers,
  61. templatePath: path.join(__dirname, '../email-plugin/templates'),
  62. outputPath: path.join(__dirname, 'test-emails'),
  63. mailboxPort: 5003,
  64. globalTemplateVars: {
  65. verifyEmailAddressUrl: 'http://localhost:4201/verify',
  66. passwordResetUrl: 'http://localhost:4201/reset-password',
  67. changeEmailAddressUrl: 'http://localhost:4201/change-email-address',
  68. },
  69. }),
  70. UiPlugin,
  71. AdminUiPlugin.init({
  72. port: 5001,
  73. extensions: UiPlugin.uiExtensions,
  74. watch: true,
  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. }