dev-config.ts 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. /* tslint:disable:no-console */
  2. import { AdminUiPlugin } from '@vendure/admin-ui-plugin';
  3. import { LanguageCode } from '@vendure/admin-ui/src/app/common/generated-types';
  4. import { AssetServerPlugin } from '@vendure/asset-server-plugin';
  5. import { ADMIN_API_PATH, API_PORT, SHOP_API_PATH } from '@vendure/common/lib/shared-constants';
  6. import {
  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. import { UiPlugin } from './ui-plugin/ui-plugin';
  17. /**
  18. * Config settings used during development
  19. */
  20. export const devConfig: VendureConfig = {
  21. authOptions: {
  22. disableAuth: false,
  23. sessionSecret: 'some-secret',
  24. requireVerification: true,
  25. },
  26. port: API_PORT,
  27. adminApiPath: ADMIN_API_PATH,
  28. shopApiPath: SHOP_API_PATH,
  29. dbConnectionOptions: {
  30. synchronize: false,
  31. logging: false,
  32. ...getDbConfig(),
  33. },
  34. paymentOptions: {
  35. paymentMethodHandlers: [examplePaymentHandler],
  36. },
  37. customFields: {
  38. Product: [
  39. { name: 'length', type: 'int', min: 0, max: 100 },
  40. {
  41. name: 'offerImageId',
  42. label: [{ languageCode: LanguageCode.en, value: 'Offer image' }],
  43. type: 'string',
  44. },
  45. ],
  46. ProductVariant: [{ name: 'length', type: 'int', min: 0, max: 100 }],
  47. },
  48. logger: new DefaultLogger({ level: LogLevel.Info }),
  49. importExportOptions: {
  50. importAssetsDir: path.join(__dirname, 'import-assets'),
  51. },
  52. plugins: [
  53. AssetServerPlugin.init({
  54. route: 'assets',
  55. assetUploadDir: path.join(__dirname, 'assets'),
  56. port: 5002,
  57. }),
  58. DefaultSearchPlugin,
  59. // ElasticsearchPlugin.init({
  60. // host: 'http://192.168.99.100',
  61. // port: 9200,
  62. // }),
  63. EmailPlugin.init({
  64. devMode: true,
  65. handlers: defaultEmailHandlers as any,
  66. templatePath: path.join(__dirname, '../email-plugin/templates'),
  67. outputPath: path.join(__dirname, 'test-emails'),
  68. mailboxPort: 5003,
  69. globalTemplateVars: {
  70. verifyEmailAddressUrl: 'http://localhost:4201/verify',
  71. passwordResetUrl: 'http://localhost:4201/reset-password',
  72. changeEmailAddressUrl: 'http://localhost:4201/change-email-address',
  73. },
  74. }),
  75. UiPlugin,
  76. AdminUiPlugin.init({
  77. port: 5001,
  78. // extensions: UiPlugin.uiExtensions,
  79. // watch: true,
  80. }),
  81. ],
  82. };
  83. function getDbConfig(): ConnectionOptions {
  84. const dbType = process.env.DB || 'mysql';
  85. switch (dbType) {
  86. case 'postgres':
  87. console.log('Using postgres connection');
  88. return {
  89. synchronize: true,
  90. type: 'postgres',
  91. host: '127.0.0.1',
  92. port: 5432,
  93. username: 'postgres',
  94. password: 'Be70',
  95. database: 'vendure',
  96. };
  97. case 'sqlite':
  98. console.log('Using sqlite connection');
  99. return {
  100. type: 'sqlite',
  101. database: path.join(__dirname, 'vendure.sqlite'),
  102. };
  103. case 'sqljs':
  104. console.log('Using sql.js connection');
  105. return {
  106. type: 'sqljs',
  107. autoSave: true,
  108. database: new Uint8Array([]),
  109. location: path.join(__dirname, 'vendure.sqlite'),
  110. };
  111. case 'mysql':
  112. default:
  113. console.log('Using mysql connection');
  114. return {
  115. synchronize: true,
  116. type: 'mysql',
  117. host: '192.168.99.100',
  118. port: 3306,
  119. username: 'root',
  120. password: '',
  121. database: 'vendure-dev',
  122. };
  123. }
  124. }