dnf-api 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,39 +1,39 @@
1
- {
2
- "name": "dnf-api",
3
- "version": "1.0.0",
4
- "description": "던전 앤 파이터 API",
5
- "main": "./dist/index.js",
6
- "types": "./dist/src/index.d.ts",
7
- "dependencies": {
8
- "@types/bun": "1.1.6",
9
- "axios": "^0.18.1",
10
- "consola": "^2.15.3",
11
- "prototype-helper": "^0.4.2",
12
- "query-string": "^9.1.1",
13
- "undici": "^7.3.0"
14
- },
15
- "devDependencies": {
16
- "@biomejs/biome": "^1.9.4",
17
- "dotenv": "^16.4.7",
18
- "typescript": "5.5.3"
19
- },
20
- "scripts": {
21
- "dev": "bun --watch test.ts",
22
- "bundle": "tsc --declaration --emitDeclarationOnly --outDir dist && bun build src/index.ts --minify --target=bun --outfile dist/index.js",
23
- "dev:test": "bun --watch test.ts",
24
- "test": "jest"
25
- },
26
- "repository": {
27
- "type": "git",
28
- "url": "git+https://github.com/k22pr/dnf-api.git"
29
- },
30
- "keywords": [
31
- "dnf"
32
- ],
33
- "author": "서버지기",
34
- "license": "MIT",
35
- "bugs": {
36
- "url": "https://github.com/k22pr/dnf-api/issues"
37
- },
38
- "homepage": "https://github.com/k22pr/dnf-api#readme"
39
- }
1
+ {
2
+ "name": "dnf-api",
3
+ "version": "1.0.1",
4
+ "description": "던전 앤 파이터 API",
5
+ "main": "./dist/index.js",
6
+ "types": "./dist/src/index.d.ts",
7
+ "dependencies": {
8
+ "@types/bun": "1.1.6",
9
+ "axios": "^0.18.1",
10
+ "consola": "^2.15.3",
11
+ "prototype-helper": "^0.4.2",
12
+ "query-string": "^9.1.1",
13
+ "undici": "^7.3.0"
14
+ },
15
+ "devDependencies": {
16
+ "@biomejs/biome": "^1.9.4",
17
+ "dotenv": "^16.4.7",
18
+ "typescript": "5.5.3"
19
+ },
20
+ "scripts": {
21
+ "dev": "bun --watch test.ts",
22
+ "bundle": "tsc --declaration --emitDeclarationOnly --outDir dist && bun build src/index.ts --minify --target=bun --outfile dist/index.js",
23
+ "dev:test": "bun --watch test.ts",
24
+ "test": "jest"
25
+ },
26
+ "repository": {
27
+ "type": "git",
28
+ "url": "git+https://github.com/k22pr/dnf-api.git"
29
+ },
30
+ "keywords": [
31
+ "dnf"
32
+ ],
33
+ "author": "서버지기",
34
+ "license": "MIT",
35
+ "bugs": {
36
+ "url": "https://github.com/k22pr/dnf-api/issues"
37
+ },
38
+ "homepage": "https://github.com/k22pr/dnf-api#readme"
39
+ }
package/src/api/items.ts CHANGED
@@ -1,49 +1,49 @@
1
- import type * as model from "../model";
2
- import { type params, query, staticUtil } from "../util";
3
-
4
- /**
5
- * 현재 인게임에서 획득 가능한 아이템의 경우만 검색 가능합니다.
6
- *
7
- * @param {string} itemName 검색할 아이템의 명칭
8
- * @param {string} params 선택적 요청변수의 Object입니다.
9
- */
10
- export const item = async (itemName: string, params: params.IItem = {}) => {
11
- // if (params === undefined) params = {};
12
- params.itemName = itemName;
13
- // if (query) params.q = query.makeItemQuery(query);
14
- //let querystring =
15
- const opt = {
16
- base: query.UriBuilder(staticUtil.baseUri.Item),
17
- params: {
18
- ...params,
19
- ...(params.hashtag
20
- ? { hashtag: query.QueryBuilder(params.hashtag ?? []) }
21
- : {}),
22
- },
23
- };
24
- return await query.Request<model.IDnfResponse<model.item.IItem>>(opt);
25
- };
26
- /**
27
- * 해당하는 아이템의 상세정보를 요청합니다.
28
- *
29
- * @param {string} itemId 검색할 아이템의 ID
30
- */
31
- export const detail = (itemId: string) => {
32
- const opt = {
33
- base: query.UriBuilder(staticUtil.baseUri.Item, itemId),
34
- };
35
- return query.Request<model.IDnfResponse<model.item.IDetail>>(opt);
36
- };
37
-
38
- /**
39
- * 26. 아이템 상점 판매 정보 조회
40
- * 인게임 백과사전 기준의 상점 판매 95레벨 에픽, 100레벨 이상 유니크, 레전더리, 에픽 장비가 조회 가능 합니다.
41
- *
42
- * @param {string} itemId 검색할 아이템의 ID
43
- */
44
- // export const shop = (itemId: string) => {
45
- // const opt = {
46
- // base: query.UriBuilder(staticUtil.BaseUri.Item, itemId),
47
- // };
48
- // return query.Request<model.item.detail>(opt);
49
- // };
1
+ import type * as model from "../model";
2
+ import { type params, query, staticUtil } from "../util";
3
+
4
+ /**
5
+ * 현재 인게임에서 획득 가능한 아이템의 경우만 검색 가능합니다.
6
+ *
7
+ * @param {string} itemName 검색할 아이템의 명칭
8
+ * @param {string} params 선택적 요청변수의 Object입니다.
9
+ */
10
+ export const item = async (itemName: string, params: params.IItem = {}) => {
11
+ // if (params === undefined) params = {};
12
+ params.itemName = itemName;
13
+ // if (query) params.q = query.makeItemQuery(query);
14
+ //let querystring =
15
+ const opt = {
16
+ base: query.UriBuilder(staticUtil.baseUri.Item),
17
+ params: {
18
+ ...params,
19
+ ...(params.hashtag
20
+ ? { hashtag: query.QueryBuilder(params.hashtag ?? []) }
21
+ : {}),
22
+ },
23
+ };
24
+ return await query.Request<model.IDnfResponse<model.item.IItem>>(opt);
25
+ };
26
+ /**
27
+ * 해당하는 아이템의 상세정보를 요청합니다.
28
+ *
29
+ * @param {string} itemId 검색할 아이템의 ID
30
+ */
31
+ export const detail = (itemId: string) => {
32
+ const opt = {
33
+ base: query.UriBuilder(staticUtil.baseUri.Item, itemId),
34
+ };
35
+ return query.Request<model.IDnfResponse<model.item.IDetail>>(opt);
36
+ };
37
+
38
+ /**
39
+ * 26. 아이템 상점 판매 정보 조회
40
+ * 인게임 백과사전 기준의 상점 판매 95레벨 에픽, 100레벨 이상 유니크, 레전더리, 에픽 장비가 조회 가능 합니다.
41
+ *
42
+ * @param {string} itemId 검색할 아이템의 ID
43
+ */
44
+ // export const shop = (itemId: string) => {
45
+ // const opt = {
46
+ // base: query.UriBuilder(staticUtil.BaseUri.Item, itemId),
47
+ // };
48
+ // return query.Request<model.item.detail>(opt);
49
+ // };
@@ -1,98 +1,98 @@
1
- import type { staticUtil } from "../util";
2
- import type { INameValue } from "./";
3
-
4
- /** 캐릭터 정보 인터페이스 */
5
- export interface ICharacter {
6
- serverId: staticUtil.server;
7
- characterId: string;
8
- characterName: string;
9
- level: number;
10
- jobId: string;
11
- jobGrowId: string;
12
- jobName: string;
13
- jobGrowName: string;
14
- fame: number;
15
- }
16
-
17
- /** 캐릭터 상세 정보 인터페이스 */
18
- export interface IInfo {
19
- serverId: staticUtil.server;
20
- characterId: string;
21
- characterName: string;
22
- level: number;
23
- jobId: string;
24
- jobGrowId: string;
25
- jobName: string;
26
- jobGrowName: string;
27
- fame: number;
28
- adventureName: string;
29
- guildId: string | null;
30
- guildName: string | null;
31
- }
32
-
33
- /** 캐릭터 타임라인 인터페이스 */
34
- export interface ITimeline {
35
- serverId: staticUtil.server;
36
- characterId: string;
37
- characterName: string;
38
- level: number;
39
- jobId: string;
40
- jobGrowId: string;
41
- jobName: string;
42
- jobGrowName: string;
43
- adventureName: string;
44
- guildId: string;
45
- guildName: string;
46
- timeline: {
47
- date: {
48
- start: Date;
49
- end: Date;
50
- };
51
- next: string;
52
- rows: ITimeLineRow[];
53
- };
54
- }
55
-
56
- /** 타임라인 행 인터페이스 */
57
- export interface ITimeLineRow {
58
- code: number;
59
- name: string;
60
- date: string;
61
- data: ITimeLineRowData;
62
- }
63
-
64
- /** 타임라인 행 데이터 인터페이스 */
65
- export interface ITimeLineRowData {
66
- itemId: string;
67
- itemName: string;
68
- itemRarity: staticUtil.rarity;
69
- channelName: string;
70
- channelNo: number;
71
- dungeonName: string;
72
- mistGear: boolean;
73
- }
74
-
75
- /** 캐릭터 상태 인터페이스 */
76
- export interface ICharacterStatus {
77
- serverId: staticUtil.server;
78
- characterId: string;
79
- characterName: string;
80
- level: number;
81
- jobId: string;
82
- jobGrowId: string;
83
- jobName: string;
84
- jobGrowName: string;
85
- fame: number;
86
- adventureName: string;
87
- guildId: string | null;
88
- guildName: string | null;
89
- buff: IBuff[];
90
- status: INameValue[];
91
- }
92
-
93
- /** 버프 정보 인터페이스 */
94
- export interface IBuff {
95
- name: string;
96
- level?: number;
97
- status: INameValue[];
98
- }
1
+ import type { staticUtil } from "../util";
2
+ import type { INameValue } from "./";
3
+
4
+ /** 캐릭터 정보 인터페이스 */
5
+ export interface ICharacter {
6
+ serverId: staticUtil.server;
7
+ characterId: string;
8
+ characterName: string;
9
+ level: number;
10
+ jobId: string;
11
+ jobGrowId: string;
12
+ jobName: string;
13
+ jobGrowName: string;
14
+ fame: number;
15
+ }
16
+
17
+ /** 캐릭터 상세 정보 인터페이스 */
18
+ export interface IInfo {
19
+ serverId: staticUtil.server;
20
+ characterId: string;
21
+ characterName: string;
22
+ level: number;
23
+ jobId: string;
24
+ jobGrowId: string;
25
+ jobName: string;
26
+ jobGrowName: string;
27
+ fame: number;
28
+ adventureName: string;
29
+ guildId: string | null;
30
+ guildName: string | null;
31
+ }
32
+
33
+ /** 캐릭터 타임라인 인터페이스 */
34
+ export interface ITimeline {
35
+ serverId: staticUtil.server;
36
+ characterId: string;
37
+ characterName: string;
38
+ level: number;
39
+ jobId: string;
40
+ jobGrowId: string;
41
+ jobName: string;
42
+ jobGrowName: string;
43
+ adventureName: string;
44
+ guildId: string;
45
+ guildName: string;
46
+ timeline: {
47
+ date: {
48
+ start: Date;
49
+ end: Date;
50
+ };
51
+ next: string;
52
+ rows: ITimeLineRow[];
53
+ };
54
+ }
55
+
56
+ /** 타임라인 행 인터페이스 */
57
+ export interface ITimeLineRow {
58
+ code: number;
59
+ name: string;
60
+ date: string;
61
+ data: ITimeLineRowData;
62
+ }
63
+
64
+ /** 타임라인 행 데이터 인터페이스 */
65
+ export interface ITimeLineRowData {
66
+ itemId: string;
67
+ itemName: string;
68
+ itemRarity: staticUtil.rarity;
69
+ channelName: string;
70
+ channelNo: number;
71
+ dungeonName: string;
72
+ mistGear: boolean;
73
+ }
74
+
75
+ /** 캐릭터 상태 인터페이스 */
76
+ export interface ICharacterStatus {
77
+ serverId: staticUtil.server;
78
+ characterId: string;
79
+ characterName: string;
80
+ level: number;
81
+ jobId: string;
82
+ jobGrowId: string;
83
+ jobName: string;
84
+ jobGrowName: string;
85
+ fame: number;
86
+ adventureName: string;
87
+ guildId: string | null;
88
+ guildName: string | null;
89
+ buff: IBuff[];
90
+ status: INameValue[];
91
+ }
92
+
93
+ /** 버프 정보 인터페이스 */
94
+ export interface IBuff {
95
+ name: string;
96
+ level?: number;
97
+ status: INameValue[];
98
+ }
package/src/model/item.ts CHANGED
@@ -1,117 +1,117 @@
1
- import type * as Static from "../util/static";
2
- import type { INameValue } from "./";
3
-
4
- export enum ItemDetailKind {
5
- Material = "material",
6
- Equip = "equip",
7
- }
8
-
9
- /** 아이템 인터페이스 */
10
- export interface IItem {
11
- itemId: string;
12
- itemName: string;
13
- itemRarity: Static.rarity;
14
- itemType: string;
15
- itemTypeDetail: string;
16
- itemAvailableLevel: number;
17
- }
18
-
19
- /** 아이템 상세 인터페이스(합성 타입) */
20
- export type IDetail = IMaterialDetail | IEquipDetail;
21
-
22
- /** 재료 아이템 상세 인터페이스 */
23
- export interface IMaterialDetail {
24
- kind: ItemDetailKind.Material;
25
- itemId: string;
26
- itemName: string;
27
- itemRarity: string;
28
- itemTypeId: string;
29
- itemType: string;
30
- itemTypeDetailId: string;
31
- itemTypeDetail: string;
32
- itemAvailableLevel: number;
33
- itemExplain: string;
34
- itemExplainDetail: string;
35
- itemFlavorText: string;
36
- fame: number;
37
- setItemId: string | null;
38
- setItemName: string | null;
39
- obtainInfo: IObtainInfo;
40
- }
41
-
42
- /** 장비 아이템 상세 인터페이스 */
43
- export interface IEquipDetail {
44
- kind: ItemDetailKind.Equip;
45
- itemId: string;
46
- itemName: string;
47
- itemRarity: string;
48
- itemTypeId: string;
49
- itemType: string;
50
- itemTypeDetailId: string;
51
- itemTypeDetail: string;
52
- itemAvailableLevel: number;
53
- itemExplain: string;
54
- itemExplainDetail: string;
55
- itemFlavorText: string;
56
- fame: number;
57
- setItemId: string | null;
58
- setItemName: string | null;
59
- itemStatus: INameValue[];
60
- tune: ITune;
61
- itemBuff: IItemBuff;
62
- hashtag: string[];
63
- obtainInfo: IObtainInfoDetail;
64
- }
65
-
66
- /** 튠 정보 인터페이스 */
67
- export interface ITune {
68
- level: number;
69
- setPoint: number;
70
- }
71
-
72
- /** 아이템 버프 인터페이스 */
73
- export interface IItemBuff {
74
- explain: string;
75
- explainDetail: string;
76
- reinforceSkill: any[];
77
- status: any | null;
78
- }
79
-
80
- /** 획득 정보 인터페이스 */
81
- export interface IObtainInfo {
82
- dungeon: string | null;
83
- shop: IShopInfo[];
84
- }
85
-
86
- /** 획득 상세 정보 인터페이스 */
87
- export interface IObtainInfoDetail {
88
- dungeon: IDungeon[];
89
- shop: IShopDetail[];
90
- }
91
-
92
- /** 던전 정보 인터페이스 */
93
- export interface IDungeon {
94
- type: string;
95
- rows: IDungeonRow[];
96
- }
97
-
98
- /** 던전 행 인터페이스 */
99
- export interface IDungeonRow {
100
- name: string;
101
- }
102
-
103
- /** 상점 정보 인터페이스 */
104
- export interface IShopInfo {
105
- type: string;
106
- }
107
-
108
- /** 상점 상세 정보 인터페이스 */
109
- export interface IShopDetail {
110
- rows: IShopRow[];
111
- }
112
-
113
- /** 상점 행 인터페이스 */
114
- export interface IShopRow {
115
- name: string;
116
- details: string[];
117
- }
1
+ import type * as Static from "../util/static";
2
+ import type { INameValue } from "./";
3
+
4
+ export enum ItemDetailKind {
5
+ Material = "material",
6
+ Equip = "equip",
7
+ }
8
+
9
+ /** 아이템 인터페이스 */
10
+ export interface IItem {
11
+ itemId: string;
12
+ itemName: string;
13
+ itemRarity: Static.rarity;
14
+ itemType: string;
15
+ itemTypeDetail: string;
16
+ itemAvailableLevel: number;
17
+ }
18
+
19
+ /** 아이템 상세 인터페이스(합성 타입) */
20
+ export type IDetail = IMaterialDetail | IEquipDetail;
21
+
22
+ /** 재료 아이템 상세 인터페이스 */
23
+ export interface IMaterialDetail {
24
+ kind: ItemDetailKind.Material;
25
+ itemId: string;
26
+ itemName: string;
27
+ itemRarity: string;
28
+ itemTypeId: string;
29
+ itemType: string;
30
+ itemTypeDetailId: string;
31
+ itemTypeDetail: string;
32
+ itemAvailableLevel: number;
33
+ itemExplain: string;
34
+ itemExplainDetail: string;
35
+ itemFlavorText: string;
36
+ fame: number;
37
+ setItemId: string | null;
38
+ setItemName: string | null;
39
+ obtainInfo: IObtainInfo;
40
+ }
41
+
42
+ /** 장비 아이템 상세 인터페이스 */
43
+ export interface IEquipDetail {
44
+ kind: ItemDetailKind.Equip;
45
+ itemId: string;
46
+ itemName: string;
47
+ itemRarity: string;
48
+ itemTypeId: string;
49
+ itemType: string;
50
+ itemTypeDetailId: string;
51
+ itemTypeDetail: string;
52
+ itemAvailableLevel: number;
53
+ itemExplain: string;
54
+ itemExplainDetail: string;
55
+ itemFlavorText: string;
56
+ fame: number;
57
+ setItemId: string | null;
58
+ setItemName: string | null;
59
+ itemStatus: INameValue[];
60
+ tune: ITune;
61
+ itemBuff: IItemBuff;
62
+ hashtag: string[];
63
+ obtainInfo: IObtainInfoDetail;
64
+ }
65
+
66
+ /** 튠 정보 인터페이스 */
67
+ export interface ITune {
68
+ level: number;
69
+ setPoint: number;
70
+ }
71
+
72
+ /** 아이템 버프 인터페이스 */
73
+ export interface IItemBuff {
74
+ explain: string;
75
+ explainDetail: string;
76
+ reinforceSkill: any[];
77
+ status: any | null;
78
+ }
79
+
80
+ /** 획득 정보 인터페이스 */
81
+ export interface IObtainInfo {
82
+ dungeon: string | null;
83
+ shop: IShopInfo[];
84
+ }
85
+
86
+ /** 획득 상세 정보 인터페이스 */
87
+ export interface IObtainInfoDetail {
88
+ dungeon: IDungeon[];
89
+ shop: IShopDetail[];
90
+ }
91
+
92
+ /** 던전 정보 인터페이스 */
93
+ export interface IDungeon {
94
+ type: string;
95
+ rows: IDungeonRow[];
96
+ }
97
+
98
+ /** 던전 행 인터페이스 */
99
+ export interface IDungeonRow {
100
+ name: string;
101
+ }
102
+
103
+ /** 상점 정보 인터페이스 */
104
+ export interface IShopInfo {
105
+ type: string;
106
+ }
107
+
108
+ /** 상점 상세 정보 인터페이스 */
109
+ export interface IShopDetail {
110
+ rows: IShopRow[];
111
+ }
112
+
113
+ /** 상점 행 인터페이스 */
114
+ export interface IShopRow {
115
+ name: string;
116
+ details: string[];
117
+ }
@@ -1,81 +1,81 @@
1
- import type * as staticUtil from "./static";
2
- export interface QueryOptions<T = any> {
3
- base: string;
4
- params?: T;
5
- }
6
- export interface ICharParams {
7
- characterName?: string;
8
- jobId?: string;
9
- jobGrowId?: string;
10
- isAllJobGrow?: boolean;
11
- wordType?: staticUtil.charactersWordType;
12
- limit?: number;
13
- }
14
-
15
- export interface ITimeLine {
16
- serverId?: staticUtil.server;
17
- characterId?: string;
18
- startDate?: Date;
19
- endDate?: Date;
20
- limit?: number;
21
- code?: string[];
22
- next?: string;
23
- }
24
-
25
- export interface IAuction {
26
- limit?: number;
27
- sort?: IAuctionSort;
28
- itemId?: string;
29
- itemName?: string;
30
- wordType?: staticUtil.auctionWordType;
31
- wordShort?: boolean;
32
- q?: IAuctionQuery;
33
- }
34
- export interface IAuctionSort {
35
- unitPrice?: staticUtil.sort;
36
- reinforce?: staticUtil.sort;
37
- auctionNo?: staticUtil.sort;
38
- }
39
- export interface IAuctionQuery {
40
- minLevel?: number;
41
- maxLevel?: number;
42
- raity?: staticUtil.rarity;
43
- reinforceTypeId: staticUtil.reinforceType;
44
- minReinforce?: number;
45
- maxReinforce?: number;
46
- minRefine?: number;
47
- maxRefine?: number;
48
- minFame?: number;
49
- maxFame?: number;
50
- }
51
-
52
- export interface IActionSoldOption {
53
- limit?: number;
54
- wordType?: staticUtil.auctionWordType;
55
- wordShort?: boolean;
56
- itemId?: string;
57
- itemName?: string;
58
- }
59
-
60
- export interface IItem {
61
- limit?: number;
62
- itemName?: string;
63
- hashtag?: string[];
64
- wordType?: staticUtil.auctionWordType;
65
- q?: IItemQuery;
66
- }
67
- export interface IItemQuery {
68
- minLevel?: number;
69
- maxLevel?: number;
70
- rarity?: staticUtil.rarity;
71
- // trade?: boolean;
72
- }
73
-
74
- export interface ISetItem {
75
- setItemName?: string;
76
- limit?: number;
77
- wordType?: staticUtil.auctionWordType;
78
- }
79
- export interface ISkill {
80
- jobGrowId: string;
81
- }
1
+ import type * as staticUtil from "./static";
2
+ export interface QueryOptions<T = any> {
3
+ base: string;
4
+ params?: T;
5
+ }
6
+ export interface ICharParams {
7
+ characterName?: string;
8
+ jobId?: string;
9
+ jobGrowId?: string;
10
+ isAllJobGrow?: boolean;
11
+ wordType?: staticUtil.charactersWordType;
12
+ limit?: number;
13
+ }
14
+
15
+ export interface ITimeLine {
16
+ serverId?: staticUtil.server;
17
+ characterId?: string;
18
+ startDate?: Date;
19
+ endDate?: Date;
20
+ limit?: number;
21
+ code?: string[];
22
+ next?: string;
23
+ }
24
+
25
+ export interface IAuction {
26
+ limit?: number;
27
+ sort?: IAuctionSort;
28
+ itemId?: string;
29
+ itemName?: string;
30
+ wordType?: staticUtil.auctionWordType;
31
+ wordShort?: boolean;
32
+ q?: IAuctionQuery;
33
+ }
34
+ export interface IAuctionSort {
35
+ unitPrice?: staticUtil.sort;
36
+ reinforce?: staticUtil.sort;
37
+ auctionNo?: staticUtil.sort;
38
+ }
39
+ export interface IAuctionQuery {
40
+ minLevel?: number;
41
+ maxLevel?: number;
42
+ raity?: staticUtil.rarity;
43
+ reinforceTypeId: staticUtil.reinforceType;
44
+ minReinforce?: number;
45
+ maxReinforce?: number;
46
+ minRefine?: number;
47
+ maxRefine?: number;
48
+ minFame?: number;
49
+ maxFame?: number;
50
+ }
51
+
52
+ export interface IActionSoldOption {
53
+ limit?: number;
54
+ wordType?: staticUtil.auctionWordType;
55
+ wordShort?: boolean;
56
+ itemId?: string;
57
+ itemName?: string;
58
+ }
59
+
60
+ export interface IItem {
61
+ limit?: number;
62
+ itemName?: string;
63
+ hashtag?: string[];
64
+ wordType?: staticUtil.auctionWordType;
65
+ q?: IItemQuery;
66
+ }
67
+ export interface IItemQuery {
68
+ minLevel?: number;
69
+ maxLevel?: number;
70
+ rarity?: staticUtil.rarity;
71
+ // trade?: boolean;
72
+ }
73
+
74
+ export interface ISetItem {
75
+ setItemName?: string;
76
+ limit?: number;
77
+ wordType?: staticUtil.auctionWordType;
78
+ }
79
+ export interface ISkill {
80
+ jobGrowId: string;
81
+ }
package/src/util/query.ts CHANGED
@@ -1,103 +1,93 @@
1
- import consola from "consola";
2
- import querystring from "query-string";
3
- import { request } from "undici";
4
-
5
- import type * as model from "../model";
6
- import * as Util from "./";
7
-
8
- const apiUrl = new URL("https://api.neople.co.kr");
9
- // const client = new Client("https://api.neople.co.kr", {
10
- // connectTimeout: Util.Config.timeout,
11
- // // allowH2: true,
12
- // });
13
-
14
- const sender = async <T>(path: string, method: "GET" | "POST", query: any) => {
15
- // const res = await client.request<model.DnfResponse<T>>({
16
- // const res = await client.request<T>({
17
- // path,
18
- // method,
19
- // query,
20
- // });
21
- apiUrl.pathname = path;
22
- apiUrl.search = querystring.stringify(query);
23
-
24
- const res = await request<model.IDnfResponse<T>>(apiUrl.href, {
25
- method,
26
- });
27
- return res;
28
- };
29
- const showUrl = (url: string): string => {
30
- if (Util.config.key) {
31
- return url?.replace(Util.config.key, Util.config.hideKeyText);
32
- } else {
33
- return url;
34
- }
35
- };
36
-
37
- // biome-ignore lint/complexity/noStaticOnlyClass: <explanation>
38
- export default class Request {
39
- public static UriBuilder(...args: any[]): string {
40
- return args.join("/");
41
- }
42
- public static QueryBuilder(query: string[] | number[]): string {
43
- const qString: string[] = [];
44
- for (const key in query) {
45
- qString.push(`${key}:${query[key]},`);
46
- }
47
- return qString.join(",");
48
- }
49
-
50
- /**
51
- * 던전앤파이터 API 서버에 응답을 요청하는 함수 입니다.
52
- * 해당 함수를 직접 호출 하는것을 권장하지 않습니다.
53
- *
54
- * @param {object} opt (요청을 보낼 Parameter값)
55
- * @returns
56
- */
57
- public static async Request<T>(
58
- opt: any = {},
59
- method: "GET" | "POST" = "GET"
60
- ): Promise<model.IDnfResponse<T>> {
61
- if (!Util.config.key || Util.config.key === "") {
62
- consola.error("Please change to your api key. ");
63
- }
64
-
65
- if (opt.params === undefined) opt.params = {};
66
- if (opt.params.q) opt.params.q = Request.QueryBuilder(opt.params.q);
67
-
68
- opt.params.apikey = Util.config.key;
69
-
70
- if (Util.config.showURL)
71
- consola.log(
72
- "request url:",
73
- showUrl(`${opt.base}?${querystring.stringify(opt.params)}`)
74
- );
75
-
76
- const res = await sender<model.IDnfResponse<T>>(
77
- opt.base,
78
- method,
79
- opt.params
80
- );
81
- if (res.statusCode !== 200) {
82
- const resBody = (await res.body.json()) as model.IDnfResponse<T>;
83
- const error: model.IDnfErrorResponse = {
84
- url: showUrl(opt.url ?? ""),
85
- status: res.statusCode || 0,
86
- statusText: "",
87
- code: resBody.error?.code || "",
88
- message: resBody.error?.message || "",
89
- };
90
- return { error };
91
- } else {
92
- const resBody = (await res.body.json()) as T;
93
- return {
94
- data: resBody,
95
- };
96
- }
97
- }
98
-
99
- public static makeItemQuery(query: any) {
100
- // return JSON.stringify(query).replace(/\"|\{|\}/gi, "");
101
- return encodeURI(query);
102
- }
103
- }
1
+ import consola from "consola";
2
+ import querystring from "query-string";
3
+ import { request } from "undici";
4
+
5
+ import type * as model from "../model";
6
+ import * as Util from "./";
7
+
8
+ const apiUrl = new URL("https://api.neople.co.kr");
9
+ // const client = new Client("https://api.neople.co.kr", {
10
+ // connectTimeout: Util.Config.timeout,
11
+ // // allowH2: true,
12
+ // });
13
+
14
+ const sender = async <T>(path: string, method: "GET" | "POST", query: any) => {
15
+ apiUrl.pathname = path;
16
+ apiUrl.search = querystring.stringify(query);
17
+ const res = await request<model.IDnfResponse<T>>(apiUrl.href, {
18
+ method,
19
+ });
20
+ return res;
21
+ };
22
+
23
+ const showUrl = (url: string): string => {
24
+ if (Util.config.key) {
25
+ return url?.replace(Util.config.key, Util.config.hideKeyText);
26
+ } else {
27
+ return url;
28
+ }
29
+ };
30
+
31
+ // biome-ignore lint/complexity/noStaticOnlyClass: <explanation>
32
+ export default class Request {
33
+ public static UriBuilder(...args: any[]): string {
34
+ return args.join("/");
35
+ }
36
+ public static QueryBuilder(query: string[] | number[]): string {
37
+ const qString: string[] = [];
38
+ for (const key in query) {
39
+ qString.push(`${key}:${query[key]},`);
40
+ }
41
+ return qString.join(",");
42
+ }
43
+
44
+ /**
45
+ * 던전앤파이터 API 서버에 응답을 요청하는 함수 입니다.
46
+ * 해당 함수를 직접 호출 하는것을 권장하지 않습니다.
47
+ *
48
+ * @param {object} opt (요청을 보낼 Parameter값)
49
+ * @returns
50
+ */
51
+ public static async Request<T>(
52
+ opt: any = {},
53
+ method: "GET" | "POST" = "GET"
54
+ ): Promise<model.IDnfResponse<T>> {
55
+ if (!Util.config.key || Util.config.key === "") {
56
+ consola.error("Please change to your api key. ");
57
+ }
58
+
59
+ if (opt.params === undefined) opt.params = {};
60
+ if (opt.params.q) opt.params.q = Request.QueryBuilder(opt.params.q);
61
+
62
+ opt.params.apikey = Util.config.key;
63
+
64
+ if (Util.config.showURL)
65
+ consola.log(
66
+ "request url:",
67
+ showUrl(`${opt.base}?${querystring.stringify(opt.params)}`)
68
+ );
69
+
70
+ const res = await sender<T>(opt.base, method, opt.params);
71
+ if (res.statusCode !== 200) {
72
+ const resBody = (await res.body.json()) as model.IDnfResponse<T>;
73
+ const error: model.IDnfErrorResponse = {
74
+ url: showUrl(opt.url ?? ""),
75
+ status: res.statusCode || 0,
76
+ statusText: "",
77
+ code: resBody.error?.code || "",
78
+ message: resBody.error?.message || "",
79
+ };
80
+ return { error };
81
+ } else {
82
+ const resBody = (await res.body.json()) as T;
83
+ return {
84
+ data: resBody,
85
+ };
86
+ }
87
+ }
88
+
89
+ public static makeItemQuery(query: any) {
90
+ // return JSON.stringify(query).replace(/\"|\{|\}/gi, "");
91
+ return encodeURI(query);
92
+ }
93
+ }