refact(global): token to env

This commit is contained in:
kyuuseiryuu 2026-01-29 14:21:16 +09:00
parent eb92a92b7b
commit bedd6ccb1b
6 changed files with 21 additions and 4 deletions

2
.gitignore vendored
View File

@ -32,3 +32,5 @@ report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json
# Finder (MacOS) folder config
.DS_Store
src/config.ts

View File

@ -1,5 +1,5 @@
{
"name": "bun-react-template",
"name": "my-kaiqiuwang",
"version": "0.1.0",
"private": true,
"type": "module",

5
src/config.example.ts Normal file
View File

@ -0,0 +1,5 @@
import type { Config } from "./types";
export const config: Config = {
KAIQIUCC_TOKEN: '',
};

View File

@ -1,6 +1,12 @@
import { serve } from "bun";
import index from "./index.html";
import { getAdvProfile, getMatchInfo, getMemberDetail, getPlayerTags, listEvent } from "./utils";
import { config } from "./config";
if (!config.KAIQIUCC_TOKEN) {
console.error('env KAIQIUCC_TOKEN not found');
process.exit(1);
}
const server = serve({
port: process.env.PORT || 3000,

View File

@ -1,5 +1,8 @@
export * from './profile';
export * from './tag';
export interface Config {
KAIQIUCC_TOKEN: string;
}
export interface IEventInfo {
title: string;
info: string[];

View File

@ -1,4 +1,3 @@
// import { fetch } from 'bun';
import type { IEventInfo, Player, XCXMember } from "./types";
import * as cheerio from "cheerio";
import fs from 'fs';
@ -6,12 +5,14 @@ import path from 'path';
import { chunk } from 'lodash';
import type { XCXProfile } from "./types/profile";
import type { XCXTag } from "./types/tag";
import { config } from './config';
const BASE_URL = `https://kaiqiuwang.cc`;
const XCX_BASE_URL = `${BASE_URL}/xcx/public/index.php`;
/**
* token:
*
token:
XX-Device-Type: wxapp
content-type: application/json
Accept-Encoding: gzip,compress,br,deflate
@ -19,7 +20,7 @@ User-Agent: Mozilla/5.0 (iPhone; CPU iPhone OS 18_7 like Mac OS X) AppleWebKit/6
Referer: https://servicewechat.com/wxff09fb0e92aa456a/464/page-frame.html
*/
const xcxDefaultHeaders = {
'token': 'e72b91bb-a690-44fe-9274-6a4a251f611b',
'token': config.KAIQIUCC_TOKEN,
'XX-Device-Type': 'wxapp',
'content-type': 'application/json',
'Accept-Encoding': 'gzip,compress,br,deflate',