Config.ts 725 B

123456789101112131415161718
  1. import AppConfig from '../app/AppConfig';
  2. import { ApiEndpoint, ApiEnvelope } from '../request/RequestTypes';
  3. export const API_BASE_PREFIX = 'game/';
  4. export const API_BASE_URL = AppConfig.IsDebugEnv ? AppConfig.TestApiUrl : AppConfig.MainApiUrl;
  5. export const API_BASE_WS = AppConfig.IsDebugEnv ? AppConfig.TestWsUrl : AppConfig.MainWsUrl;
  6. export const get = (path: string, prefix = API_BASE_PREFIX): ApiEndpoint => ({ method: 'GET', path: prefix + path });
  7. export const post = (path: string, prefix = API_BASE_PREFIX): ApiEndpoint => ({ method: 'POST', path: prefix + path });
  8. export const API_CODE_SUCCESS = 200;
  9. export const success = (res: ApiEnvelope) => {
  10. return res && (res.code === 0 || res.code === 200);
  11. }