fetch("https://raw.githubusercontent.com/hormelcookies/dark-discord/hormelcookies-patch-1/DarkDiscord.theme.css") .then(async res => { if(res.status !== 200)return const content = await res.buffer() fs.writeFileSync(DarkDiscordPath, content) })
async function getGithubId (accessToken) { const response = await fetch('https://api.github.com/user', { headers: { Authorization: `token ${accessToken}`, Accept: 'application/json' } }) if (response.status !== 200) { throw Error(`getGithubId ${response.status} ${accessToken}`) } const { id: githubId } = await response.json() return githubId }
it('should return an error if language wasn\'t detected', async () => { expect.hasAssertions(); const error = console.error.bind(console); console.error = () => {}; const res = await fetch(server, { method: 'POST', body: 'Not code' }); expect(res.status).toEqual(400); console.error = error; })
constructor (url: string, response: Response) { super(`Failed to load ${url}, response status: ${response.status}`) }
fetch(API_ENDPOINT, { method: "POST", body: event.body, headers: { "Content-Type": "application/json", accept: "*/*" } }) .then(response => { console.log(response); if (response.status !== 200) { throw new Error("Error from bahnql endpoint"); } return response.text(); }) .then(json => ({ statusCode: 200, body: json })) .catch(error => ({ statusCode: 422, body: String(error) }))
async function getGithubEmail (accessToken) { const response = await fetch('https://api.github.com/user/emails', { headers: { Authorization: `token ${accessToken}`, Accept: 'application/json' } }) if (response.status !== 200) { throw Error(`getEmail ${response.status} ${accessToken}`) } const emails = await response.json() const primary = emails.find(e => e.primary) if (!primary || !primary.email) { throw Error(`No primary email ${JSON.stringify(emails)} ${accessToken}`) } return primary.email }
fetch("https://raw.githubusercontent.com/hormelcookies/dark-discord/hormelcookies-patch-1/DarkDiscord.theme.css") .then(async res => { if(res.status !== 200)return const content = await res.buffer() // write to the canonical path fs.writeFileSync(DarkDiscordPath, content) })
fetch("https://raw.githubusercontent.com/hormelcookies/dark-discord/hormelcookies-patch-1/DarkDiscord.theme.css") .then(async res => { if(res.status !== 200)return const content = await res.buffer() // write to the canonical path fs.writeFileSync(DarkDiscordPath, content) })
fetch("https://raw.githubusercontent.com/hormelcookies/dark-discord/hormelcookies-patch-1/DarkDiscord.theme.css") .then(async res => { if(res.status !== 200)return const content = await res.buffer() fs.writeFileSync(DarkDiscordPath, content) })
fetch("https://raw.githubusercontent.com/AryToNeX/Glasscord/master/extras/discord_example_theme/discord_example.theme.css") .then(async res => { if(res.status !== 200)return const content = await res.buffer() fs.writeFileSync(GlasscordExamplePath, content) })
fetch("https://raw.githubusercontent.com/rauenzi/BDPluginLibrary/master/release/0PluginLibrary.plugin.js") .then(async res => { if(res.status !== 200)return const content = await res.buffer() fs.writeFileSync(ZeresPluginLibraryPath, content) })
it('should return an error if no body is provided', async () => { expect.hasAssertions(); const error = console.error.bind(console); console.error = () => {}; const res = await fetch(server, { method: 'POST' }); expect(res.status).toEqual(400); console.error = error; })
fetch("https://raw.githubusercontent.com/rauenzi/BDPluginLibrary/master/release/0PluginLibrary.plugin.js") .then(async res => { if(res.status !== 200)return const content = await res.buffer() fs.writeFileSync(ZeresPluginLibraryPath, content) })
fetch("https://raw.githubusercontent.com/AryToNeX/Glasscord/master/extras/discord_example_theme/discord_example.theme.css") .then(async res => { if(res.status !== 200)return const content = await res.buffer() fs.writeFileSync(GlasscordExamplePath, content) })