dev-config.ts 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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. type: 'postgres',
  68. host: '127.0.0.1',
  69. port: 5432,
  70. username: 'postgres',
  71. password: 'Be70',
  72. database: 'vendure',
  73. };
  74. case 'sqlite':
  75. console.log('Using sqlite connection');
  76. return {
  77. type: 'sqlite',
  78. database: path.join(__dirname, 'vendure.sqlite'),
  79. };
  80. case 'mysql':
  81. default:
  82. console.log('Using mysql connection');
  83. return {
  84. type: 'mysql',
  85. host: '192.168.99.100',
  86. port: 3306,
  87. username: 'root',
  88. password: '',
  89. database: 'vendure-dev',
  90. };
  91. }
  92. }