dev-config.ts 3.4 KB

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