Skip to content

Instantly share code, notes, and snippets.

@avivshafir
Last active February 19, 2018 21:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save avivshafir/eaf350441e754285b47319330496a491 to your computer and use it in GitHub Desktop.
Save avivshafir/eaf350441e754285b47319330496a491 to your computer and use it in GitHub Desktop.
Alfy | Alfred workflow node example
const alfy = require("alfy");
const alfyFetchOptions = {
auth: auth,
maxAge: requestCacheInMilis
};
const auth = "username:password";
const requestCacheInMilis = 1000 * 60 * 60 * 24; //24 hours
const buildTypesUrl = "TCHOSTNAME/httpAuth/app/rest/buildTypes"
const projectTypesUrl = "TCHOSTNAME/httpAuth/app/rest/projects";
(async () => {
const p1 = alfy.fetch(buildTypesUrl, alfyFetchOptions);
const p2 = alfy.fetch(projectTypesUrl, alfyFetchOptions);
const [res1, res2] = await Promise.all([p1, p2]);
const responses = [...res1.buildType, ...res2.project];
alfy.output(
responses.map(({ name: title, description: subtitle, webUrl: arg }) => ({
title,
subtitle,
arg
}))
);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment