refact(global): token to env
This commit is contained in:
parent
eb92a92b7b
commit
bedd6ccb1b
2
.gitignore
vendored
2
.gitignore
vendored
@ -32,3 +32,5 @@ report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json
|
||||
|
||||
# Finder (MacOS) folder config
|
||||
.DS_Store
|
||||
|
||||
src/config.ts
|
||||
|
||||
@ -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
5
src/config.example.ts
Normal file
@ -0,0 +1,5 @@
|
||||
import type { Config } from "./types";
|
||||
|
||||
export const config: Config = {
|
||||
KAIQIUCC_TOKEN: '',
|
||||
};
|
||||
@ -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,
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
export * from './profile';
|
||||
export * from './tag';
|
||||
export interface Config {
|
||||
KAIQIUCC_TOKEN: string;
|
||||
}
|
||||
export interface IEventInfo {
|
||||
title: string;
|
||||
info: string[];
|
||||
|
||||
@ -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',
|
||||
|
||||
Loading…
Reference in New Issue
Block a user