Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,8 @@ jobs:
- name: Install dependencies
run: npm install

- name: Type check
run: npm run typecheck

- name: Run tests
run: npm test
run: npm test
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@

coverage/
node_modules/
dist/

.vercel
.vercel
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ To get 10 languages, a dark theme, and a custom title:

### Prerequisites
- Node.js 18+
- TypeScript 5.0+
- (Optional) Vercel or other Node.js hosting

### Installation
Expand Down
12 changes: 8 additions & 4 deletions api/languages/index.js → api/languages/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import { parseQueryParams } from "../../src/utils/params.js";
import { parseQueryParams, type QueryParams } from "../../src/utils/params.js";
import { fetchLanguageData, processLanguageData } from "../../src/api/github.js";
import { generateChartData } from "../../src/render/chart.js";
import { renderSvg } from "../../src/render/svg.js";
import { renderError } from "../../src/render/error.js";
import type { VercelRequest, VercelResponse } from "@vercel/node";

export default async function handler(req, res) {
const params = parseQueryParams(req.query);
export default async function handler(
req: VercelRequest,
res: VercelResponse
): Promise<void> {
const params = parseQueryParams(req.query as QueryParams);
const { chartType, chartTitle, width, height, count, selectedTheme, stroke, useTestData } = params;

try {
Expand All @@ -19,7 +23,7 @@ export default async function handler(req, res) {
res.setHeader("Cache-Control", "public, max-age=3600, s-maxage=3600, stale-while-revalidate=60");
res.status(200).send(svg);
} catch (error) {
const errorSvg = renderError(error.message, width, height, selectedTheme);
const errorSvg = renderError((error as Error).message, width, height, selectedTheme);
res.setHeader("Content-Type", "image/svg+xml");
res.status(500).send(errorSvg);
}
Expand Down
Loading