dev-config.ts 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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 { DefaultLogger, DefaultSearchPlugin, examplePaymentHandler, LogLevel, VendureConfig } from '@vendure/core';
  6. import { ElasticsearchPlugin } from '@vendure/elasticsearch-plugin';
  7. import { defaultEmailHandlers, EmailPlugin } from '@vendure/email-plugin';
  8. import path from 'path';
  9. import { ConnectionOptions } from 'typeorm';
  10. /**
  11. * Config settings used during development
  12. */
  13. export const devConfig: VendureConfig = {
  14. authOptions: {
  15. disableAuth: false,
  16. sessionSecret: 'some-secret',
  17. requireVerification: true,
  18. },
  19. port: API_PORT,
  20. adminApiPath: ADMIN_API_PATH,
  21. shopApiPath: SHOP_API_PATH,
  22. dbConnectionOptions: {
  23. synchronize: false,
  24. logging: false,
  25. ...getDbConfig(),
  26. },
  27. paymentOptions: {
  28. paymentMethodHandlers: [examplePaymentHandler],
  29. },
  30. customFields: {},
  31. logger: new DefaultLogger({ level: LogLevel.Info }),
  32. importExportOptions: {
  33. importAssetsDir: path.join(__dirname, 'import-assets'),
  34. },
  35. plugins: [
  36. new AssetServerPlugin({
  37. route: 'assets',
  38. assetUploadDir: path.join(__dirname, 'assets'),
  39. // assetUploadDir: path.join(__dirname, '../../../../kbart/artsupplies-vendure/server/vendure/assets'),
  40. port: 5002,
  41. }),
  42. new DefaultSearchPlugin(),
  43. // new ElasticsearchPlugin({
  44. // host: 'http://192.168.99.100',
  45. // port: 9200,
  46. // }),
  47. new EmailPlugin({
  48. devMode: true,
  49. handlers: defaultEmailHandlers,
  50. templatePath: path.join(__dirname, '../email-plugin/templates'),
  51. outputPath: path.join(__dirname, 'test-emails'),
  52. mailboxPort: 5003,
  53. globalTemplateVars: {
  54. verifyEmailAddressUrl: 'http://localhost:4201/verify',
  55. passwordResetUrl: 'http://localhost:4201/reset-password',
  56. changeEmailAddressUrl: 'http://localhost:4201/change-email-address',
  57. },
  58. }),
  59. new AdminUiPlugin({
  60. port: 5001,
  61. }),
  62. ],
  63. };
  64. function getDbConfig(): ConnectionOptions {
  65. const dbType = process.env.DB || 'mysql';
  66. switch (dbType) {
  67. case 'postgres':
  68. console.log('Using postgres connection');
  69. return {
  70. synchronize: true,
  71. type: 'postgres',
  72. host: '127.0.0.1',
  73. port: 5432,
  74. username: 'postgres',
  75. password: 'Be70',
  76. database: 'vendure',
  77. };
  78. case 'sqlite':
  79. console.log('Using sqlite connection');
  80. return {
  81. type: 'sqlite',
  82. database: path.join(__dirname, 'vendure.sqlite'),
  83. };
  84. case 'sqljs':
  85. console.log('Using sql.js connection');
  86. return {
  87. type: 'sqljs',
  88. autoSave: true,
  89. database: new Uint8Array([]),
  90. location: path.join(__dirname, 'vendure.sqlite'),
  91. };
  92. case 'mysql':
  93. default:
  94. console.log('Using mysql connection');
  95. return {
  96. synchronize: true,
  97. type: 'mysql',
  98. host: '192.168.99.100',
  99. port: 3306,
  100. username: 'root',
  101. password: '',
  102. database: 'vendure-dev',
  103. };
  104. }
  105. }