dev-config.ts 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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. /**
  16. * Config settings used during development
  17. */
  18. export const devConfig: VendureConfig = {
  19. authOptions: {
  20. disableAuth: false,
  21. sessionSecret: 'some-secret',
  22. requireVerification: true,
  23. },
  24. port: API_PORT,
  25. adminApiPath: ADMIN_API_PATH,
  26. shopApiPath: SHOP_API_PATH,
  27. dbConnectionOptions: {
  28. synchronize: false,
  29. logging: false,
  30. migrations: [path.join(__dirname, 'migrations/*.ts')],
  31. ...getDbConfig(),
  32. },
  33. paymentOptions: {
  34. paymentMethodHandlers: [examplePaymentHandler],
  35. },
  36. customFields: {
  37. /*Product: [
  38. { name: 'rating', type: 'float', readonly: true },
  39. { name: 'markup', type: 'float', internal: true },
  40. ],*/
  41. },
  42. logger: new DefaultLogger({ level: LogLevel.Info }),
  43. importExportOptions: {
  44. importAssetsDir: path.join(__dirname, 'import-assets'),
  45. },
  46. plugins: [
  47. AssetServerPlugin.init({
  48. route: 'assets',
  49. assetUploadDir: path.join(__dirname, 'assets'),
  50. port: 5002,
  51. }),
  52. DefaultSearchPlugin,
  53. // ElasticsearchPlugin.init({
  54. // host: 'http://192.168.99.100',
  55. // port: 9200,
  56. // }),
  57. EmailPlugin.init({
  58. devMode: true,
  59. handlers: defaultEmailHandlers,
  60. templatePath: path.join(__dirname, '../email-plugin/templates'),
  61. outputPath: path.join(__dirname, 'test-emails'),
  62. mailboxPort: 5003,
  63. globalTemplateVars: {
  64. verifyEmailAddressUrl: 'http://localhost:4201/verify',
  65. passwordResetUrl: 'http://localhost:4201/reset-password',
  66. changeEmailAddressUrl: 'http://localhost:4201/change-email-address',
  67. },
  68. }),
  69. AdminUiPlugin.init({
  70. port: 5001,
  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: true,
  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: true,
  108. type: 'mysql',
  109. host: '192.168.99.100',
  110. port: 3306,
  111. username: 'root',
  112. password: '',
  113. database: 'vendure-dev',
  114. };
  115. }
  116. }