dev-config.ts 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  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. LanguageCode,
  11. LogLevel,
  12. VendureConfig,
  13. } from '@vendure/core';
  14. import { ElasticsearchPlugin } from '@vendure/elasticsearch-plugin';
  15. import { defaultEmailHandlers, EmailPlugin } from '@vendure/email-plugin';
  16. import path from 'path';
  17. import { ConnectionOptions } from 'typeorm';
  18. /**
  19. * Config settings used during development
  20. */
  21. export const devConfig: VendureConfig = {
  22. apiOptions: {
  23. port: API_PORT,
  24. adminApiPath: ADMIN_API_PATH,
  25. adminApiPlayground: {
  26. settings: {
  27. 'request.credentials': 'include',
  28. } as any,
  29. },
  30. adminApiDebug: true,
  31. shopApiPath: SHOP_API_PATH,
  32. shopApiPlayground: {
  33. settings: {
  34. 'request.credentials': 'include',
  35. } as any,
  36. },
  37. shopApiDebug: true,
  38. },
  39. authOptions: {
  40. disableAuth: false,
  41. sessionSecret: 'some-secret',
  42. requireVerification: true,
  43. },
  44. dbConnectionOptions: {
  45. synchronize: false,
  46. logging: false,
  47. migrations: [path.join(__dirname, 'migrations/*.ts')],
  48. ...getDbConfig(),
  49. },
  50. paymentOptions: {
  51. paymentMethodHandlers: [examplePaymentHandler],
  52. },
  53. customFields: {
  54. /*Product: [
  55. { name: 'rating', type: 'float', readonly: true },
  56. { name: 'markup', type: 'float', internal: true },
  57. ],*/
  58. ProductOptionGroup: [
  59. {
  60. name: 'linkUrl',
  61. type: 'string',
  62. },
  63. ],
  64. ProductOption: [
  65. /*{
  66. name: 'colorHex',
  67. description: [
  68. {
  69. languageCode: LanguageCode.en,
  70. value: 'Color',
  71. },
  72. {
  73. languageCode: LanguageCode.pt_BR,
  74. value: 'Cor',
  75. },
  76. ],
  77. type: 'string',
  78. nullable: true,
  79. public: true,
  80. pattern: '^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$',
  81. length: 7,
  82. },
  83. {
  84. name: 'colorName',
  85. type: 'localeString',
  86. },*/
  87. ],
  88. },
  89. logger: new DefaultLogger({ level: LogLevel.Info }),
  90. importExportOptions: {
  91. importAssetsDir: path.join(__dirname, 'import-assets'),
  92. },
  93. plugins: [
  94. AssetServerPlugin.init({
  95. route: 'assets',
  96. assetUploadDir: path.join(__dirname, 'assets'),
  97. port: 5002,
  98. }),
  99. DefaultSearchPlugin,
  100. DefaultJobQueuePlugin,
  101. // ElasticsearchPlugin.init({
  102. // host: 'http://192.168.99.100',
  103. // port: 9200,
  104. // }),
  105. EmailPlugin.init({
  106. devMode: true,
  107. handlers: defaultEmailHandlers,
  108. templatePath: path.join(__dirname, '../email-plugin/templates'),
  109. outputPath: path.join(__dirname, 'test-emails'),
  110. mailboxPort: 5003,
  111. globalTemplateVars: {
  112. verifyEmailAddressUrl: 'http://localhost:4201/verify',
  113. passwordResetUrl: 'http://localhost:4201/reset-password',
  114. changeEmailAddressUrl: 'http://localhost:4201/change-email-address',
  115. },
  116. }),
  117. AdminUiPlugin.init({
  118. port: 5001,
  119. }),
  120. ],
  121. };
  122. function getDbConfig(): ConnectionOptions {
  123. const dbType = process.env.DB || 'mysql';
  124. switch (dbType) {
  125. case 'postgres':
  126. console.log('Using postgres connection');
  127. return {
  128. synchronize: true,
  129. type: 'postgres',
  130. host: '127.0.0.1',
  131. port: 5432,
  132. username: 'admin',
  133. password: 'secret',
  134. database: 'vendure-dev',
  135. };
  136. case 'sqlite':
  137. console.log('Using sqlite connection');
  138. return {
  139. synchronize: false,
  140. type: 'sqlite',
  141. database: path.join(__dirname, 'vendure.sqlite'),
  142. };
  143. case 'sqljs':
  144. console.log('Using sql.js connection');
  145. return {
  146. type: 'sqljs',
  147. autoSave: true,
  148. database: new Uint8Array([]),
  149. location: path.join(__dirname, 'vendure.sqlite'),
  150. };
  151. case 'mysql':
  152. default:
  153. console.log('Using mysql connection');
  154. return {
  155. synchronize: true,
  156. type: 'mysql',
  157. host: '127.0.0.1',
  158. port: 3306,
  159. username: 'root',
  160. password: '',
  161. database: 'vendure-dev',
  162. };
  163. }
  164. }