dev-config.ts 3.7 KB

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