import { CoolConfig } from '@cool-midway/core';
import { MidwayConfig } from '@midwayjs/core';
import { CoolCacheStore } from '@cool-midway/core';
import * as path from 'path';
import { pCachePath, pUploadPath } from '../comm/path';
import { availablePort } from '../comm/port';

export default {
  keys: 'f65bcafd-b72c-4f01-a451-333155097148',
  koa: {
    port: availablePort(8001),
    rawBody: true,    
  },
  asyncContextManager: {
    enable: true,
  },
  staticFile: {
    buffer: true,
    dirs: {
      default: {
        prefix: '/',
        dir: path.join(__dirname, '..', '..', 'public'),
      },
      static: {
        prefix: '/upload',
        dir: pUploadPath(),
      },
    },
  },
  upload: {
    fileSize: '200mb',
    whitelist: null,
    ignore: ['/open/push/yingshiyun', "/open/push/cameraEvent"],    
  },
  cacheManager: {
    clients: {
      default: {
        store: CoolCacheStore,
        options: {
          path: pCachePath(),
          ttl: 0,
        },
      },
    },
  },
  cool: {
    file: {},
    tenant: {
      enable: true,
      urls: [],
    },
    i18n: {
      enable: true,
      languages: ['zh-cn', 'zh-tw', 'en'],
    },
    crud: {
      upsert: 'save',
      softDelete: true,
    },  
  } as CoolConfig,
} as MidwayConfig;