Skip to content

Commit 7a5bcf2

Browse files
committed
style: prettier
1 parent 24681c1 commit 7a5bcf2

File tree

8 files changed

+49
-48
lines changed

8 files changed

+49
-48
lines changed

.prettierrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
1-
import { makeBadge } from '../../../../lib/badge';
2-
import { html } from '../../../../lib/fetch';
1+
import { makeBadge } from "../../../../lib/badge";
2+
import { html } from "../../../../lib/fetch";
33

44
export default makeBadge(async ({ country, id }) => {
55
const url = `https://apps.apple.com/${country}/app/${id}`;
66
const dom = await html(url);
77
const schema = JSON.parse(
88
dom.window.document.querySelector(
9-
'script[name="schema:software-application"]',
10-
)?.textContent ?? '',
9+
'script[name="schema:software-application"]'
10+
)?.textContent ?? ""
1111
);
1212

1313
if (!schema.aggregateRating) {
1414
return {
15-
label: 'rating',
16-
color: 'gray',
17-
status: 'unavailable',
15+
label: "rating",
16+
color: "gray",
17+
status: "unavailable",
1818
};
1919
}
2020
const reviewCount = schema.aggregateRating.reviewCount;
2121

2222
return {
23-
label: 'rating count',
24-
color: '0070c9',
23+
label: "rating count",
24+
color: "0070c9",
2525
status: reviewCount.toString(),
2626
};
2727
});

api/appstore/rating/[country]/[id].ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
1-
import { makeBadge } from '../../../../lib/badge';
2-
import { html } from '../../../../lib/fetch';
1+
import { makeBadge } from "../../../../lib/badge";
2+
import { html } from "../../../../lib/fetch";
33

44
export default makeBadge(async ({ country, id }) => {
55
const url = `https://apps.apple.com/${country}/app/${id}`;
66
const dom = await html(url);
77
const schema = JSON.parse(
88
dom.window.document.querySelector(
9-
'script[name="schema:software-application"]',
10-
)?.textContent ?? '',
9+
'script[name="schema:software-application"]'
10+
)?.textContent ?? ""
1111
);
1212

1313
if (!schema.aggregateRating) {
1414
return {
15-
label: 'rating',
16-
color: 'gray',
17-
status: 'unavailable',
15+
label: "rating",
16+
color: "gray",
17+
status: "unavailable",
1818
};
1919
}
2020
const rating = parseInt(schema.aggregateRating.ratingValue);
2121
const stars = '★'.repeat(rating);
2222

2323
return {
24-
label: 'rating',
25-
color: '0070c9',
24+
label: "rating",
25+
color: "0070c9",
2626
status: stars,
2727
};
2828
});

api/hatena/b/[url].ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
import { makeBadge } from '../../../lib/badge';
2-
import { text } from '../../../lib/fetch';
1+
import { makeBadge } from "../../../lib/badge";
2+
import { text } from "../../../lib/fetch";
33

44
export default makeBadge(async ({ url }) => {
55
const status = await text(
66
`https://bookmark.hatenaapis.com/count/entry?url=https://${encodeURIComponent(
7-
url as string,
8-
)}`,
7+
url as string
8+
)}`
99
);
1010

1111
return {
12-
label: 'bookmarks',
13-
color: '04A4DE',
12+
label: "bookmarks",
13+
color: "04A4DE",
1414
status,
1515
};
1616
});

api/producthunt/upvotes/[slug].ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import { makeBadge } from '../../../lib/badge';
2-
import { graphql } from '../../../lib/fetch';
1+
import { makeBadge } from "../../../lib/badge";
2+
import { graphql } from "../../../lib/fetch";
33

44
export default makeBadge(async ({ slug }) => {
55
const status = await graphql(
6-
'https://api.producthunt.com/v2/api/graphql',
6+
"https://api.producthunt.com/v2/api/graphql",
77
`
88
{
99
post(slug: "${slug}") {
@@ -15,20 +15,20 @@ export default makeBadge(async ({ slug }) => {
1515
headers: {
1616
authorization: `Bearer ${process.env.PRODUCT_HUNT_TOKEN}`,
1717
},
18-
},
18+
}
1919
);
2020

2121
if (!status.post) {
2222
return {
23-
label: 'upvotes',
24-
color: 'gray',
25-
status: 'not found',
23+
label: "upvotes",
24+
color: "gray",
25+
status: "not found",
2626
};
2727
}
2828

2929
return {
30-
label: 'upvotes',
31-
color: 'cc4d29',
30+
label: "upvotes",
31+
color: "cc4d29",
3232
status: status.post.votesCount.toString(),
3333
};
3434
});

index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
<div id="app"></div>
1919
<script>
2020
window.$docsify = {
21-
name: 'badge.now.sh',
22-
repo: 'uetchy/badge',
21+
name: "badge.now.sh",
22+
repo: "uetchy/badge",
2323
};
2424
</script>
2525
<script src="//cdn.jsdelivr.net/npm/docsify/lib/docsify.min.js"></script>

lib/badge.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,42 @@
1-
import { NowRequest, NowResponse, NowRequestQuery } from '@vercel/node';
2-
import { badgen } from 'badgen';
1+
import { NowRequest, NowResponse, NowRequestQuery } from "@vercel/node";
2+
import { badgen } from "badgen";
33

44
export interface BadgenOptions {
55
status: string;
66
subject?: string;
77
color?: string;
88
label?: string;
99
labelColor?: string;
10-
style?: 'flat' | 'classic';
10+
style?: "flat" | "classic";
1111
icon?: string;
1212
iconWidth?: number;
1313
scale?: number;
1414
}
1515

1616
export function makeBadge(
17-
resolve: (query: NowRequestQuery) => Promise<BadgenOptions> | BadgenOptions,
17+
resolve: (query: NowRequestQuery) => Promise<BadgenOptions> | BadgenOptions
1818
) {
1919
return async (req: NowRequest, res: NowResponse) => {
2020
const isFlat = req.query.flat !== undefined;
2121
delete req.query.flat;
2222

23-
res.setHeader('Content-Type', 'image/svg+xml');
23+
res.setHeader("Content-Type", "image/svg+xml");
2424

2525
try {
2626
const badge = badgen({
2727
...(await Promise.resolve(resolve(req.query))),
28-
style: isFlat ? 'flat' : 'classic',
28+
style: isFlat ? "flat" : "classic",
2929
});
3030

31-
res.setHeader('Cache-Control', 's-maxage=86400');
31+
res.setHeader("Cache-Control", "s-maxage=86400");
3232
res.send(badge);
3333
} catch (err) {
3434
res.send(
3535
badgen({
36-
label: 'error',
37-
color: 'gray',
36+
label: "error",
37+
color: "gray",
3838
status: err.message,
39-
}),
39+
})
4040
);
4141
}
4242
};

lib/fetch.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import 'cross-fetch/polyfill';
2-
import { JSDOM } from 'jsdom';
3-
import { GraphQLClient } from 'graphql-request';
1+
import "cross-fetch/polyfill";
2+
import { JSDOM } from "jsdom";
3+
import { GraphQLClient } from "graphql-request";
44

55
export async function graphql(url: string, query: string, init?: RequestInit) {
66
const graphQLClient = new GraphQLClient(url, init);

0 commit comments

Comments
 (0)