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 { ElasticsearchPlugin } from '@vendure/elasticsearch-plugin';
  13. import { defaultEmailHandlers, EmailPlugin } from '@vendure/email-plugin';
  14. import path from 'path';
  15. import { ConnectionOptions } from 'typeorm';
  16. import { RestPlugin } from './rest-plugin';
  17. import { UiPlugin } from './ui-plugin/ui-plugin';
  18. /**
  19. * Config settings used during development
  20. */
  21. export const devConfig: VendureConfig = {
  22. authOptions: {
  23. disableAuth: false,
  24. sessionSecret: 'some-secret',
  25. requireVerification: true,
  26. },
  27. port: API_PORT,
  28. adminApiPath: ADMIN_API_PATH,
  29. shopApiPath: SHOP_API_PATH,
  30. dbConnectionOptions: {
  31. synchronize: false,
  32. logging: false,
  33. ...getDbConfig(),
  34. },
  35. paymentOptions: {
  36. paymentMethodHandlers: [examplePaymentHandler],
  37. },
  38. customFields: {
  39. /*Product: [
  40. { type: 'string', name: 'name' },
  41. { type: 'datetime', name: 'expires' },
  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. // 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. UiPlugin,
  72. AdminUiPlugin.init({
  73. port: 5001,
  74. extensions: UiPlugin.uiExtensions,
  75. watch: true,
  76. }),
  77. ],
  78. };
  79. function getDbConfig(): ConnectionOptions {
  80. const dbType = process.env.DB || 'mysql';
  81. switch (dbType) {
  82. case 'postgres':
  83. console.log('Using postgres connection');
  84. return {
  85. synchronize: true,
  86. type: 'postgres',
  87. host: '127.0.0.1',
  88. port: 5432,
  89. username: 'postgres',
  90. password: 'Be70',
  91. database: 'vendure',
  92. };
  93. case 'sqlite':
  94. console.log('Using sqlite connection');
  95. return {
  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. }