dev-config.ts 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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. dummyPaymentHandler,
  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. requireVerification: true,
  41. customPermissions: [],
  42. cookieOptions: {
  43. secret: 'abc',
  44. },
  45. },
  46. dbConnectionOptions: {
  47. synchronize: false,
  48. logging: false,
  49. migrations: [path.join(__dirname, 'migrations/*.ts')],
  50. ...getDbConfig(),
  51. },
  52. paymentOptions: {
  53. paymentMethodHandlers: [dummyPaymentHandler],
  54. },
  55. customFields: {},
  56. logger: new DefaultLogger({ level: LogLevel.Info }),
  57. importExportOptions: {
  58. importAssetsDir: path.join(__dirname, 'import-assets'),
  59. },
  60. plugins: [
  61. AssetServerPlugin.init({
  62. route: 'assets',
  63. assetUploadDir: path.join(__dirname, 'assets'),
  64. }),
  65. DefaultSearchPlugin,
  66. DefaultJobQueuePlugin,
  67. // ElasticsearchPlugin.init({
  68. // host: 'http://localhost',
  69. // port: 9200,
  70. // }),
  71. EmailPlugin.init({
  72. devMode: true,
  73. route: 'mailbox',
  74. handlers: defaultEmailHandlers,
  75. templatePath: path.join(__dirname, '../email-plugin/templates'),
  76. outputPath: path.join(__dirname, 'test-emails'),
  77. globalTemplateVars: {
  78. verifyEmailAddressUrl: 'http://localhost:4201/verify',
  79. passwordResetUrl: 'http://localhost:4201/reset-password',
  80. changeEmailAddressUrl: 'http://localhost:4201/change-email-address',
  81. },
  82. }),
  83. AdminUiPlugin.init({
  84. route: 'admin',
  85. port: 5001,
  86. }),
  87. ],
  88. };
  89. function getDbConfig(): ConnectionOptions {
  90. const dbType = process.env.DB || 'mysql';
  91. switch (dbType) {
  92. case 'postgres':
  93. console.log('Using postgres connection');
  94. return {
  95. synchronize: true,
  96. type: 'postgres',
  97. host: '127.0.0.1',
  98. port: 5432,
  99. username: 'admin',
  100. password: 'secret',
  101. database: 'vendure-dev',
  102. };
  103. case 'sqlite':
  104. console.log('Using sqlite connection');
  105. return {
  106. synchronize: false,
  107. type: 'better-sqlite3',
  108. database: path.join(__dirname, 'vendure.sqlite'),
  109. };
  110. case 'sqljs':
  111. console.log('Using sql.js connection');
  112. return {
  113. type: 'sqljs',
  114. autoSave: true,
  115. database: new Uint8Array([]),
  116. location: path.join(__dirname, 'vendure.sqlite'),
  117. };
  118. case 'mysql':
  119. default:
  120. console.log('Using mysql connection');
  121. return {
  122. synchronize: true,
  123. type: 'mariadb',
  124. host: '127.0.0.1',
  125. port: 3306,
  126. username: 'root',
  127. password: '',
  128. database: 'vendure-dev',
  129. };
  130. }
  131. }