dev-config.ts 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  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 { ElasticsearchPlugin } from '@vendure/elasticsearch-plugin';
  14. import { defaultEmailHandlers, EmailPlugin } from '@vendure/email-plugin';
  15. import path from 'path';
  16. import { ConnectionOptions } from 'typeorm';
  17. import { GoogleAuthPlugin } from './test-plugins/google-auth/google-auth-plugin';
  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. tokenMethod: 'bearer',
  42. sessionSecret: 'some-secret',
  43. requireVerification: true,
  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. /*Product: [
  56. { name: 'rating', type: 'float', readonly: true },
  57. { name: 'markup', type: 'float', internal: true },
  58. ],*/
  59. },
  60. logger: new DefaultLogger({ level: LogLevel.Info }),
  61. importExportOptions: {
  62. importAssetsDir: path.join(__dirname, 'import-assets'),
  63. },
  64. plugins: [
  65. GoogleAuthPlugin.init({
  66. // See https://developers.google.com/identity/sign-in/web/sign-in
  67. // for details on how to obtain a client id
  68. clientId: '<< google client id >>',
  69. }),
  70. AssetServerPlugin.init({
  71. route: 'assets',
  72. assetUploadDir: path.join(__dirname, 'assets'),
  73. port: 5002,
  74. }),
  75. DefaultSearchPlugin,
  76. DefaultJobQueuePlugin,
  77. // ElasticsearchPlugin.init({
  78. // host: 'http://192.168.99.100',
  79. // port: 9200,
  80. // }),
  81. EmailPlugin.init({
  82. devMode: true,
  83. handlers: defaultEmailHandlers,
  84. templatePath: path.join(__dirname, '../email-plugin/templates'),
  85. outputPath: path.join(__dirname, 'test-emails'),
  86. mailboxPort: 5003,
  87. globalTemplateVars: {
  88. verifyEmailAddressUrl: 'http://localhost:4201/verify',
  89. passwordResetUrl: 'http://localhost:4201/reset-password',
  90. changeEmailAddressUrl: 'http://localhost:4201/change-email-address',
  91. },
  92. }),
  93. AdminUiPlugin.init({
  94. port: 5001,
  95. }),
  96. ],
  97. };
  98. function getDbConfig(): ConnectionOptions {
  99. const dbType = process.env.DB || 'mysql';
  100. switch (dbType) {
  101. case 'postgres':
  102. console.log('Using postgres connection');
  103. return {
  104. synchronize: true,
  105. type: 'postgres',
  106. host: '127.0.0.1',
  107. port: 5432,
  108. username: 'admin',
  109. password: 'secret',
  110. database: 'vendure-dev',
  111. };
  112. case 'sqlite':
  113. console.log('Using sqlite connection');
  114. return {
  115. synchronize: false,
  116. type: 'sqlite',
  117. database: path.join(__dirname, 'vendure.sqlite'),
  118. };
  119. case 'sqljs':
  120. console.log('Using sql.js connection');
  121. return {
  122. type: 'sqljs',
  123. autoSave: true,
  124. database: new Uint8Array([]),
  125. location: path.join(__dirname, 'vendure.sqlite'),
  126. };
  127. case 'mysql':
  128. default:
  129. console.log('Using mysql connection');
  130. return {
  131. synchronize: true,
  132. type: 'mysql',
  133. host: '127.0.0.1',
  134. port: 3306,
  135. username: 'root',
  136. password: '',
  137. database: 'vendure-dev',
  138. };
  139. }
  140. }