dev-config.ts 3.7 KB

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