dnf-api 0.5.22 → 0.6.0
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/LICENSE +21 -21
- package/README.md +313 -313
- package/bun.lockb +0 -0
- package/jest.config.js +12 -12
- package/package.json +37 -41
- package/src/api/auction.ts +67 -61
- package/src/api/characters.equip.ts +81 -53
- package/src/api/characters.skill.ts +52 -52
- package/src/api/characters.ts +91 -60
- package/src/api/index.ts +9 -9
- package/src/api/items.ts +27 -9
- package/src/api/server.ts +9 -9
- package/src/api/setitems.ts +34 -29
- package/src/index.ts +29 -18
- package/src/model/character.ts +51 -3
- package/src/model/index.ts +86 -62
- package/src/model/item.ts +74 -22
- package/src/model/setitem.ts +31 -31
- package/src/util/config.ts +20 -19
- package/src/util/index.ts +6 -6
- package/src/util/params.ts +14 -5
- package/src/util/query.ts +103 -109
- package/src/util/static.ts +51 -45
- package/dist/api/auction.d.ts +0 -24
- package/dist/api/auction.js +0 -58
- package/dist/api/characters.d.ts +0 -32
- package/dist/api/characters.equip.d.ts +0 -29
- package/dist/api/characters.equip.js +0 -51
- package/dist/api/characters.js +0 -58
- package/dist/api/characters.skill.d.ts +0 -29
- package/dist/api/characters.skill.js +0 -51
- package/dist/api/index.d.ts +0 -8
- package/dist/api/index.js +0 -23
- package/dist/api/items.d.ts +0 -15
- package/dist/api/items.js +0 -40
- package/dist/api/server.d.ts +0 -2
- package/dist/api/server.js +0 -9
- package/dist/api/setitems.d.ts +0 -15
- package/dist/api/setitems.js +0 -28
- package/dist/index.d.ts +0 -14
- package/dist/index.js +0 -35
- package/dist/model/character.d.ts +0 -41
- package/dist/model/character.js +0 -2
- package/dist/model/index.d.ts +0 -56
- package/dist/model/index.js +0 -15
- package/dist/model/item.d.ts +0 -45
- package/dist/model/item.js +0 -2
- package/dist/model/setitem.d.ts +0 -24
- package/dist/model/setitem.js +0 -2
- package/dist/util/config.d.ts +0 -11
- package/dist/util/config.js +0 -12
- package/dist/util/index.d.ts +0 -5
- package/dist/util/index.js +0 -20
- package/dist/util/params.d.ts +0 -67
- package/dist/util/params.js +0 -2
- package/dist/util/query.d.ts +0 -14
- package/dist/util/query.js +0 -132
- package/dist/util/static.d.ts +0 -44
- package/dist/util/static.js +0 -53
- package/src/index.tmp.js +0 -48
package/dist/util/query.js
DELETED
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
-
if (mod && mod.__esModule) return mod;
|
|
16
|
-
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
|
18
|
-
result["default"] = mod;
|
|
19
|
-
return result;
|
|
20
|
-
};
|
|
21
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
const axios_1 = __importDefault(require("axios"));
|
|
23
|
-
const querystring_1 = __importDefault(require("querystring"));
|
|
24
|
-
// import urlencode from "urlencode";
|
|
25
|
-
// import consola from "consola";
|
|
26
|
-
const consola = require("consola");
|
|
27
|
-
const Util = __importStar(require("./"));
|
|
28
|
-
const sender = axios_1.default.create({
|
|
29
|
-
baseURL: "https://api.neople.co.kr",
|
|
30
|
-
timeout: Util.Config.axiosTimeout,
|
|
31
|
-
});
|
|
32
|
-
const showUrl = (url) => {
|
|
33
|
-
return url.replace(Util.Config.key, Util.Config.hidekeyText);
|
|
34
|
-
};
|
|
35
|
-
class Request {
|
|
36
|
-
static UriBuilder(...args) {
|
|
37
|
-
return args.join("/");
|
|
38
|
-
}
|
|
39
|
-
static queryBuilder(query) {
|
|
40
|
-
let qString = [];
|
|
41
|
-
for (let key in query) {
|
|
42
|
-
qString.push(`${key}:${query[key]},`);
|
|
43
|
-
}
|
|
44
|
-
return qString.join(",");
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* 던전앤파이터 API 서버에 응답을 요청하는 함수 입니다.
|
|
48
|
-
* 해당 함수를 직접 호출 하는것을 권장하지 않습니다.
|
|
49
|
-
*
|
|
50
|
-
* @param {object} opt (요청을 보낼 Parameter값)
|
|
51
|
-
* @returns
|
|
52
|
-
*/
|
|
53
|
-
static Request(opt = {}, method = "GET") {
|
|
54
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
55
|
-
if (!Util.Config.key || Util.Config.key == "") {
|
|
56
|
-
consola.error("Please change to your api key. ");
|
|
57
|
-
}
|
|
58
|
-
if (opt.params == undefined)
|
|
59
|
-
opt.params = {};
|
|
60
|
-
if (opt.params.q)
|
|
61
|
-
opt.params.q = this.queryBuilder(opt.params.q);
|
|
62
|
-
opt.params.apikey = Util.Config.key;
|
|
63
|
-
opt.url = `${opt.base}?${querystring_1.default.stringify(opt.params)}`;
|
|
64
|
-
if (Util.Config.showURL)
|
|
65
|
-
console.log(showUrl(opt.url));
|
|
66
|
-
let responseData;
|
|
67
|
-
switch (method.toLowerCase()) {
|
|
68
|
-
case "post":
|
|
69
|
-
responseData = yield sender
|
|
70
|
-
.post(opt.url)
|
|
71
|
-
.then((res) => {
|
|
72
|
-
let data;
|
|
73
|
-
if (res.data.rows)
|
|
74
|
-
data = res.data.rows;
|
|
75
|
-
else
|
|
76
|
-
data = res.data;
|
|
77
|
-
return { data };
|
|
78
|
-
})
|
|
79
|
-
.catch((err) => {
|
|
80
|
-
if (err.response) {
|
|
81
|
-
let error = {
|
|
82
|
-
url: showUrl(opt.url),
|
|
83
|
-
status: err.response.status || 0,
|
|
84
|
-
statusText: err.response.statusText,
|
|
85
|
-
code: err.response.data.error.code,
|
|
86
|
-
message: err.response.data.error.message,
|
|
87
|
-
};
|
|
88
|
-
return { error };
|
|
89
|
-
}
|
|
90
|
-
else {
|
|
91
|
-
return { err: err };
|
|
92
|
-
}
|
|
93
|
-
});
|
|
94
|
-
break;
|
|
95
|
-
case "get":
|
|
96
|
-
default:
|
|
97
|
-
responseData = yield sender
|
|
98
|
-
.get(opt.url)
|
|
99
|
-
.then((res) => {
|
|
100
|
-
let data;
|
|
101
|
-
if (res.data.rows)
|
|
102
|
-
data = res.data.rows;
|
|
103
|
-
else
|
|
104
|
-
data = res.data;
|
|
105
|
-
return { data };
|
|
106
|
-
})
|
|
107
|
-
.catch((err) => {
|
|
108
|
-
if (err.response) {
|
|
109
|
-
let error = {
|
|
110
|
-
url: showUrl(opt.url),
|
|
111
|
-
status: err.response.status || 0,
|
|
112
|
-
statusText: err.response.statusText,
|
|
113
|
-
code: err.response.data.error.code,
|
|
114
|
-
message: err.response.data.error.message,
|
|
115
|
-
};
|
|
116
|
-
return { error };
|
|
117
|
-
}
|
|
118
|
-
else {
|
|
119
|
-
return { err: err };
|
|
120
|
-
}
|
|
121
|
-
});
|
|
122
|
-
break;
|
|
123
|
-
}
|
|
124
|
-
return responseData;
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
static makeItemQuery(query) {
|
|
128
|
-
// return JSON.stringify(query).replace(/\"|\{|\}/gi, "");
|
|
129
|
-
return encodeURI(query);
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
exports.default = Request;
|
package/dist/util/static.d.ts
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
export declare enum Server {
|
|
2
|
-
Cain = "cain",
|
|
3
|
-
Diregie = "diregie",
|
|
4
|
-
Siroco = "siroco",
|
|
5
|
-
Prey = "prey",
|
|
6
|
-
Casillas = "casillas",
|
|
7
|
-
Hilder = "hilder",
|
|
8
|
-
Anton = "anton",
|
|
9
|
-
Bakal = "bakal"
|
|
10
|
-
}
|
|
11
|
-
export declare enum Sort {
|
|
12
|
-
Asc = "asc",
|
|
13
|
-
Desc = "desc"
|
|
14
|
-
}
|
|
15
|
-
export declare enum Rarity {
|
|
16
|
-
Common = "\uCEE4\uBA3C",
|
|
17
|
-
Uncommon = "\uC5B8\uCEE4\uBA3C",
|
|
18
|
-
Rare = "\uB808\uC5B4",
|
|
19
|
-
Unique = "\uC720\uB2C8\uD06C",
|
|
20
|
-
Eqic = "\uC5D0\uD53D",
|
|
21
|
-
Chronicle = "\uD06C\uB85C\uB2C8\uD074",
|
|
22
|
-
Legendary = "\uB808\uC804\uB354\uB9AC"
|
|
23
|
-
}
|
|
24
|
-
export declare enum AuctionWordType {
|
|
25
|
-
Match = "match",
|
|
26
|
-
Front = "front",
|
|
27
|
-
Full = "full"
|
|
28
|
-
}
|
|
29
|
-
export declare enum WordType {
|
|
30
|
-
Match = "match",
|
|
31
|
-
Front = "front",
|
|
32
|
-
Full = "full"
|
|
33
|
-
}
|
|
34
|
-
export declare enum CharactersWordType {
|
|
35
|
-
Match = "match",
|
|
36
|
-
Full = "full"
|
|
37
|
-
}
|
|
38
|
-
export declare enum BaseUri {
|
|
39
|
-
Servers = "df/servers",
|
|
40
|
-
Auction = "df/auction",
|
|
41
|
-
AuctionSold = "df/auction-sold",
|
|
42
|
-
Item = "df/items",
|
|
43
|
-
SetItem = "df/setitems"
|
|
44
|
-
}
|
package/dist/util/static.js
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
var Server;
|
|
4
|
-
(function (Server) {
|
|
5
|
-
Server["Cain"] = "cain";
|
|
6
|
-
Server["Diregie"] = "diregie";
|
|
7
|
-
Server["Siroco"] = "siroco";
|
|
8
|
-
Server["Prey"] = "prey";
|
|
9
|
-
Server["Casillas"] = "casillas";
|
|
10
|
-
Server["Hilder"] = "hilder";
|
|
11
|
-
Server["Anton"] = "anton";
|
|
12
|
-
Server["Bakal"] = "bakal";
|
|
13
|
-
})(Server = exports.Server || (exports.Server = {}));
|
|
14
|
-
var Sort;
|
|
15
|
-
(function (Sort) {
|
|
16
|
-
Sort["Asc"] = "asc";
|
|
17
|
-
Sort["Desc"] = "desc";
|
|
18
|
-
})(Sort = exports.Sort || (exports.Sort = {}));
|
|
19
|
-
var Rarity;
|
|
20
|
-
(function (Rarity) {
|
|
21
|
-
Rarity["Common"] = "\uCEE4\uBA3C";
|
|
22
|
-
Rarity["Uncommon"] = "\uC5B8\uCEE4\uBA3C";
|
|
23
|
-
Rarity["Rare"] = "\uB808\uC5B4";
|
|
24
|
-
Rarity["Unique"] = "\uC720\uB2C8\uD06C";
|
|
25
|
-
Rarity["Eqic"] = "\uC5D0\uD53D";
|
|
26
|
-
Rarity["Chronicle"] = "\uD06C\uB85C\uB2C8\uD074";
|
|
27
|
-
Rarity["Legendary"] = "\uB808\uC804\uB354\uB9AC";
|
|
28
|
-
})(Rarity = exports.Rarity || (exports.Rarity = {}));
|
|
29
|
-
var AuctionWordType;
|
|
30
|
-
(function (AuctionWordType) {
|
|
31
|
-
AuctionWordType["Match"] = "match";
|
|
32
|
-
AuctionWordType["Front"] = "front";
|
|
33
|
-
AuctionWordType["Full"] = "full";
|
|
34
|
-
})(AuctionWordType = exports.AuctionWordType || (exports.AuctionWordType = {}));
|
|
35
|
-
var WordType;
|
|
36
|
-
(function (WordType) {
|
|
37
|
-
WordType["Match"] = "match";
|
|
38
|
-
WordType["Front"] = "front";
|
|
39
|
-
WordType["Full"] = "full";
|
|
40
|
-
})(WordType = exports.WordType || (exports.WordType = {}));
|
|
41
|
-
var CharactersWordType;
|
|
42
|
-
(function (CharactersWordType) {
|
|
43
|
-
CharactersWordType["Match"] = "match";
|
|
44
|
-
CharactersWordType["Full"] = "full";
|
|
45
|
-
})(CharactersWordType = exports.CharactersWordType || (exports.CharactersWordType = {}));
|
|
46
|
-
var BaseUri;
|
|
47
|
-
(function (BaseUri) {
|
|
48
|
-
BaseUri["Servers"] = "df/servers";
|
|
49
|
-
BaseUri["Auction"] = "df/auction";
|
|
50
|
-
BaseUri["AuctionSold"] = "df/auction-sold";
|
|
51
|
-
BaseUri["Item"] = "df/items";
|
|
52
|
-
BaseUri["SetItem"] = "df/setitems";
|
|
53
|
-
})(BaseUri = exports.BaseUri || (exports.BaseUri = {}));
|
package/src/index.tmp.js
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import config from "./config/config";
|
|
2
|
-
|
|
3
|
-
import characters from "./api/characters";
|
|
4
|
-
import auction from "./api/auction";
|
|
5
|
-
import items from "./api/items";
|
|
6
|
-
import setitems from "./api/setitems";
|
|
7
|
-
|
|
8
|
-
import request from "./request";
|
|
9
|
-
|
|
10
|
-
const dnfApi = {
|
|
11
|
-
opt: {},
|
|
12
|
-
servers: () => {
|
|
13
|
-
let opt = {
|
|
14
|
-
base: "df/servers",
|
|
15
|
-
};
|
|
16
|
-
return request(opt);
|
|
17
|
-
},
|
|
18
|
-
characters: characters,
|
|
19
|
-
auction: auction,
|
|
20
|
-
items: items,
|
|
21
|
-
jobs: () => {
|
|
22
|
-
let opt = {
|
|
23
|
-
base: "df/jobs",
|
|
24
|
-
};
|
|
25
|
-
return request(opt);
|
|
26
|
-
},
|
|
27
|
-
setitems: setitems,
|
|
28
|
-
setOptions: function(opt) {
|
|
29
|
-
//자신의 API키
|
|
30
|
-
this.opt.key = opt.key || "";
|
|
31
|
-
//respone오류 에서 자신의 API KEY갑을 숨겨서 표시합니다.
|
|
32
|
-
this.opt.hideOnErrorApiKey = opt.hideOnErrorApiKey || true;
|
|
33
|
-
this.opt.hidekeyText = opt.hidekeyText || "{HIDEKEY}";
|
|
34
|
-
//요청후 기다리는 최대 시간입니다 (ms)
|
|
35
|
-
this.opt.axiosTimeout = opt.axiosTimeout || 5000;
|
|
36
|
-
//응답에 대한 정보를 JSON형태로 받습니다.
|
|
37
|
-
this.opt.returnJSON = opt.returnJSON || false;
|
|
38
|
-
//응답내용을 상세하게 출력하도록 변경합니다.
|
|
39
|
-
this.opt.responeHeader = opt.responeHeader || false;
|
|
40
|
-
},
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
dnfApi.config = config;
|
|
44
|
-
//dnfApi.prototype.config = config;
|
|
45
|
-
//console.log(dnfApi.opt);
|
|
46
|
-
//dnfApi.prototype.opt = dnfApi.opt;
|
|
47
|
-
|
|
48
|
-
export default dnfApi;
|