-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathalias.js
37 lines (35 loc) · 786 Bytes
/
alias.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
34
35
36
37
'use strict';
const alfy = require('alfy');
const dateFormat = require('date-format');
const nowUrl = 'https://api.zeit.co/v2/now/';
const Authorization = 'Bearer ' + process.env.token;
alfy.fetch(nowUrl + 'aliases', {
headers: {
Authorization
}
}).then(data => {
let aliases = data.aliases;
if (alfy.input) {
aliases = alfy.inputMatches(aliases, 'alias');
}
alfy.output(aliases.map(alias => {
let subtitle;
if (alias.rules) {
subtitle = alias.alias;
} else {
subtitle = alias.deployment.url;
}
return {
uid: alias.uid,
title: alias.alias,
subtitle: subtitle,
arg: 'https://' + subtitle,
autocomplete: alias.alias,
mods: {
cmd: {
subtitle: `Created at ${dateFormat('yyyy-dd-MM', new Date(alias.created))}`
}
}
}
}));
});