dev-config.ts 3.6 KB

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