-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
33 lines (31 loc) · 842 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
const arvish = require('arvish');
const encodeurl = require('encodeurl');
module.exports = async function ({ inputStr }) {
const data = await arvish.fetch('http://ac.search.naver.com/nx/ac', {
query: {
st: 100,
r_format: 'json',
r_enc: 'UTF-8',
r_unicode: 0,
t_koreng: 1,
ans: 1,
run: 2,
rev: 4,
q: inputStr
},
maxAge: 86400000,
transform: (resp) => {
return resp.items[0].map((item) => {
const word = item[0];
const encodedUrl = encodeurl(word.split(' ').join('%20'));
return {
title: word,
arg: encodedUrl,
autocomplete: item[0],
quicklookurl: `http://search.naver.com/search.naver?ie=utf8&sm=stp_hty&where=se&query=${encodedUrl}`
};
});
}
});
return arvish.output(data);
};