Skip to content

Commit

Permalink
refactor: 共用 got 实例
Browse files Browse the repository at this point in the history
  • Loading branch information
SALTWOOD committed Sep 15, 2024
1 parent b2453f7 commit ff2c430
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
6 changes: 1 addition & 5 deletions src/Server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,7 @@ export class Server {
})
.catch(error => console.error(error));

this.got = got.extend({
headers: {
'User-Agent': `93AtHome-V3/${Config.version}`
}
});
this.got = Utilities.got;

this.files = [];
this.avroBytes = new Uint8Array();
Expand Down
7 changes: 6 additions & 1 deletion src/Utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { ClusterEntity } from './database/Cluster.js';
import { SQLiteHelper } from './SQLiteHelper.js';
import { UserEntity } from './database/User.js';
import got, { Got } from 'got';
import { Config } from './Config.js';

export const FileListSchema = avsc.Type.forSchema({
type: 'array',
Expand All @@ -27,7 +28,11 @@ export const FileListSchema = avsc.Type.forSchema({
})

export class Utilities {
public static got: Got = got.extend();
public static got: Got = got.extend({
headers: {
'User-Agent': `93AtHome-V3/${Config.version}`
}
});

public static isRunningInDocker(): boolean {
return process.env.IS_IN_DOCKER === 'true';
Expand Down

0 comments on commit ff2c430

Please sign in to comment.