blob: ae73d27cd3b6f097b231bd93399f7e7c99c839f3 (
plain) (
blame)
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
|
const searchQuery = require('search-query-parser');
const chrono = require('chrono-node');
const Route = require('../../structures/Route');
const options = { keywords: ['album', 'tag', 'user', 'before', 'after'], offsets: false };
class configGET extends Route {
constructor() {
super('/search/:q', 'get', { bypassAuth: true });
}
run(req, res) {
const { q } = req.params;
const parsed = searchQuery.parse(q, options);
if (parsed.before) {
parsed.before = chrono.parse(parsed.before);
}
if (parsed.after) {
parsed.after = chrono.parse(parsed.after);
}
return res.json(parsed);
}
}
module.exports = configGET;
|