config.self.ts 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. import { MidwayConfig } from '@midwayjs/core';
  2. import { DbSubscriber } from '../event/dbSubscriber';
  3. /**数据库ip */
  4. const ip = 'localhost'; //localhost
  5. /**数据库名 */
  6. const dbName = 'cxyy';
  7. /**日志数据库名 */
  8. const logsDB = 'cxyy_logs';
  9. /**数据库用户名 */
  10. const dbUsername = 'system';
  11. /**数据库密码 */
  12. const dbPwd = '1234qwer!@#$';
  13. /**redis ip */
  14. const redisHost = 'localhost';
  15. /**redis 密码 */
  16. const redisPwd = '1234qwer!@#$';
  17. /**redis 使用第几个数据库 */
  18. const redisDB = 0;
  19. /**redis 记录登录的key */
  20. const loginSign = 'cxyy';
  21. export default {
  22. // use for cookie sign key, should change to your own and keep security
  23. keys: '1697684406848_4978',
  24. loginSign,
  25. // 请求记录在redis留存时间,超过时间.数据变化将不会记录.以秒为单位--5分钟
  26. requestTimeLimit: 300,
  27. jwt: {
  28. secret: 'Ziyouyanfa!@#',
  29. expiresIn: 3600, // 3600
  30. },
  31. koa: {
  32. port: 9700,
  33. globalPrefix: '/cxyy/api',
  34. queryParseMode: 'extended',
  35. },
  36. swagger: {
  37. swaggerPath: '/doc/api',
  38. },
  39. typeorm: {
  40. dataSource: {
  41. default: {
  42. database: dbName,
  43. username: dbUsername,
  44. password: dbPwd,
  45. host: ip,
  46. port: 54321,
  47. entities: ['./entity'],
  48. type: 'postgres',
  49. synchronize: false, // 如果第一次使用,不存在表,有同步的需求可以写 true,注意会丢数据
  50. logging: false,
  51. subscribers: [DbSubscriber],
  52. },
  53. logs: {
  54. database: logsDB,
  55. username: dbUsername,
  56. password: dbPwd,
  57. host: ip,
  58. port: 54321,
  59. entities: ['./entityLogs'],
  60. type: 'postgres',
  61. synchronize: false, // 如果第一次使用,不存在表,有同步的需求可以写 true,注意会丢数据
  62. logging: false,
  63. },
  64. },
  65. },
  66. redis: {
  67. client: {
  68. port: 6379, // Redis port
  69. host: redisHost, // Redis host
  70. password: redisPwd,
  71. db: redisDB,
  72. },
  73. },
  74. upload: {
  75. whitelist: null,
  76. },
  77. } as MidwayConfig;