dev-config.ts 3.8 KB

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