dev-config.ts 4.0 KB

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