dev-config.ts 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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 match = process.argv
  66. .filter(arg => arg.match(/--db=/))
  67. .map(arg => arg.replace(/^--db=/, ''));
  68. const dbType = match.length ? match[0] : 'mysql';
  69. switch (dbType) {
  70. case 'postgres':
  71. console.log('Using postgres connection');
  72. return {
  73. synchronize: true,
  74. type: 'postgres',
  75. host: '127.0.0.1',
  76. port: 5432,
  77. username: 'postgres',
  78. password: 'Be70',
  79. database: 'vendure',
  80. };
  81. case 'sqlite':
  82. console.log('Using sqlite connection');
  83. return {
  84. type: 'sqlite',
  85. database: path.join(__dirname, 'vendure.sqlite'),
  86. };
  87. case 'sqljs':
  88. console.log('Using sql.js connection');
  89. return {
  90. type: 'sqljs',
  91. autoSave: true,
  92. database: new Uint8Array([]),
  93. location: path.join(__dirname, 'vendure.sqlite'),
  94. };
  95. case 'mysql':
  96. default:
  97. console.log('Using mysql connection');
  98. return {
  99. synchronize: true,
  100. type: 'mysql',
  101. host: '192.168.99.100',
  102. port: 3306,
  103. username: 'root',
  104. password: '',
  105. database: 'vendure-dev',
  106. };
  107. }
  108. }