dev-config.ts 4.1 KB

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