dev-config.ts 3.8 KB

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