dev-config.ts 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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. 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: true,
  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. type: 'sqlite',
  91. database: path.join(__dirname, 'vendure.sqlite'),
  92. };
  93. case 'sqljs':
  94. console.log('Using sql.js connection');
  95. return {
  96. type: 'sqljs',
  97. autoSave: true,
  98. database: new Uint8Array([]),
  99. location: path.join(__dirname, 'vendure.sqlite'),
  100. };
  101. case 'mysql':
  102. default:
  103. console.log('Using mysql connection');
  104. return {
  105. synchronize: true,
  106. type: 'mysql',
  107. host: '192.168.99.100',
  108. port: 3306,
  109. username: 'root',
  110. password: '',
  111. database: 'vendure-dev',
  112. };
  113. }
  114. }