dev-config.ts 3.7 KB

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