Skip to content

Commit 782b82f

Browse files
committed
refactor: rely on typescript and tsx
1 parent 9249f53 commit 782b82f

18 files changed

+346
-73
lines changed

.github/workflows/audits.yml

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,10 @@ jobs:
3838
cache: yarn
3939
- name: Install
4040
run: yarn install --immutable
41-
- name: Build
42-
run: yarn build:esm
4341
- name: Start
4442
run: yarn workspace ${{ matrix.workspace }} start &
4543
- name: Audit
46-
run: node scripts/audit-implementation.mjs implementations/${{ matrix.workspace }}
44+
run: yarn tsx scripts/audit-implementation.ts implementations/${{ matrix.workspace }}
4745
- name: Summary
4846
run: cat implementations/${{ matrix.workspace }}/README.md >> $GITHUB_STEP_SUMMARY
4947
- name: Upload audit report
@@ -88,8 +86,6 @@ jobs:
8886
cache: yarn
8987
- name: Install
9088
run: yarn install --immutable
91-
- name: Build
92-
run: yarn build:esm
9389
- name: Bake
9490
uses: docker/bake-action@v2
9591
with:
@@ -101,7 +97,7 @@ jobs:
10197
- name: Start
10298
run: yarn workspace ${{ matrix.workspace }} start --detach --wait
10399
- name: Audit
104-
run: node scripts/audit-implementation.mjs implementations/${{ matrix.workspace }}
100+
run: yarn tsx scripts/audit-implementation.ts implementations/${{ matrix.workspace }}
105101
- name: Summary
106102
run: cat implementations/${{ matrix.workspace }}/README.md >> $GITHUB_STEP_SUMMARY
107103
- name: Upload audit report
@@ -141,10 +137,8 @@ jobs:
141137
cache: yarn
142138
- name: Install
143139
run: yarn install --immutable
144-
- name: Build
145-
run: yarn build:esm
146140
- name: Audit
147-
run: node scripts/audit-implementation.mjs implementations/${{ matrix.workspace.name }}
141+
run: yarn tsx scripts/audit-implementation.ts implementations/${{ matrix.workspace.name }}
148142
- name: Summary
149143
run: cat implementations/${{ matrix.workspace.name }}/README.md >> $GITHUB_STEP_SUMMARY
150144
- name: Upload audit report
@@ -176,7 +170,7 @@ jobs:
176170
with:
177171
name: audit-reports
178172
- name: Render servers table
179-
run: node scripts/render-servers-table.mjs
173+
run: yarn tsx scripts/render-servers-table.mjs
180174
- name: Diff
181175
run: git diff --minimal
182176
- name: Commit

.github/workflows/benchmark.yml

Lines changed: 13 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,10 @@ jobs:
3030
- name: Download k6
3131
run: |
3232
curl https://github.com/grafana/k6/releases/download/${{ env.K6_VERSION }}/k6-${{ env.K6_VERSION }}-linux-amd64.tar.gz -L | tar xvz --strip-components 1
33-
- name: Build
34-
run: yarn run build:esm
3533
- name: Run
36-
run: node benchmark/servers/http.mjs &
34+
run: yarn tsx benchmark/servers/http.ts &
3735
- name: Benchmark
38-
run: ./k6 run benchmark/k6.mjs --summary-export summary.json
36+
run: ./k6 run benchmark/k6.ts --summary-export summary.json
3937
- name: Summary
4038
run: |
4139
echo '```json' >> $GITHUB_STEP_SUMMARY
@@ -58,12 +56,10 @@ jobs:
5856
- name: Download k6
5957
run: |
6058
curl https://github.com/grafana/k6/releases/download/${{ env.K6_VERSION }}/k6-${{ env.K6_VERSION }}-linux-amd64.tar.gz -L | tar xvz --strip-components 1
61-
- name: Build
62-
run: yarn run build:esm
6359
- name: Run
64-
run: node benchmark/servers/express.mjs &
60+
run: yarn tsx benchmark/servers/express.ts &
6561
- name: Benchmark
66-
run: ./k6 run benchmark/k6.mjs --summary-export summary.json
62+
run: ./k6 run benchmark/k6.ts --summary-export summary.json
6763
- name: Summary
6864
run: |
6965
echo '```json' >> $GITHUB_STEP_SUMMARY
@@ -86,12 +82,10 @@ jobs:
8682
- name: Download k6
8783
run: |
8884
curl https://github.com/grafana/k6/releases/download/${{ env.K6_VERSION }}/k6-${{ env.K6_VERSION }}-linux-amd64.tar.gz -L | tar xvz --strip-components 1
89-
- name: Build
90-
run: yarn run build:esm
9185
- name: Run
92-
run: node benchmark/servers/fastify.mjs &
86+
run: yarn tsx benchmark/servers/fastify.ts &
9387
- name: Benchmark
94-
run: ./k6 run benchmark/k6.mjs --summary-export summary.json
88+
run: ./k6 run benchmark/k6.ts --summary-export summary.json
9589
- name: Summary
9690
run: |
9791
echo '```json' >> $GITHUB_STEP_SUMMARY
@@ -114,12 +108,10 @@ jobs:
114108
- name: Download k6
115109
run: |
116110
curl https://github.com/grafana/k6/releases/download/${{ env.K6_VERSION }}/k6-${{ env.K6_VERSION }}-linux-amd64.tar.gz -L | tar xvz --strip-components 1
117-
- name: Build
118-
run: yarn run build:esm
119111
- name: Run
120-
run: node benchmark/servers/koa.mjs &
112+
run: yarn tsx benchmark/servers/koa.ts &
121113
- name: Benchmark
122-
run: ./k6 run benchmark/k6.mjs --summary-export summary.json
114+
run: ./k6 run benchmark/k6.ts --summary-export summary.json
123115
- name: Summary
124116
run: |
125117
echo '```json' >> $GITHUB_STEP_SUMMARY
@@ -142,12 +134,10 @@ jobs:
142134
- name: Download k6
143135
run: |
144136
curl https://github.com/grafana/k6/releases/download/${{ env.K6_VERSION }}/k6-${{ env.K6_VERSION }}-linux-amd64.tar.gz -L | tar xvz --strip-components 1
145-
- name: Build
146-
run: yarn run build:esm
147137
- name: Run
148-
run: node benchmark/servers/uWebSockets.mjs &
138+
run: yarn tsx benchmark/servers/uWebSockets.ts &
149139
- name: Benchmark
150-
run: ./k6 run benchmark/k6.mjs --summary-export summary.json
140+
run: ./k6 run benchmark/k6.ts --summary-export summary.json
151141
- name: Summary
152142
run: |
153143
echo '```json' >> $GITHUB_STEP_SUMMARY
@@ -181,7 +171,7 @@ jobs:
181171
- name: Run
182172
run: deno run -A benchmark/servers/deno.ts &
183173
- name: Benchmark
184-
run: ./k6 run benchmark/k6.mjs --summary-export summary.json
174+
run: ./k6 run benchmark/k6.ts --summary-export summary.json
185175
- name: Summary
186176
run: |
187177
echo '```json' >> $GITHUB_STEP_SUMMARY
@@ -208,12 +198,10 @@ jobs:
208198
- name: Download k6
209199
run: |
210200
curl https://github.com/grafana/k6/releases/download/${{ env.K6_VERSION }}/k6-${{ env.K6_VERSION }}-linux-amd64.tar.gz -L | tar xvz --strip-components 1
211-
- name: Build
212-
run: yarn run build:esm
213201
- name: Run
214-
run: bun run benchmark/servers/bun.mjs &
202+
run: bun run benchmark/servers/bun.ts &
215203
- name: Benchmark
216-
run: ./k6 run benchmark/k6.mjs --summary-export summary.json
204+
run: ./k6 run benchmark/k6.ts --summary-export summary.json
217205
- name: Summary
218206
run: |
219207
echo '```json' >> $GITHUB_STEP_SUMMARY

.github/workflows/website.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
- name: Build
2424
run: yarn build:umd
2525
- name: Inject
26-
run: node scripts/inject-audits-website.mjs
26+
run: yarn tsx scripts/inject-audits-website.ts
2727
- name: Upload website
2828
uses: actions/upload-pages-artifact@v1
2929
with:

benchmark/k6.mjs renamed to benchmark/k6.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import { check, fail } from 'k6';
2+
import { Options } from 'k6/options';
23
import { Counter, Trend } from 'k6/metrics';
3-
import http from 'k6/http';
4+
import http, { RefinedResponse } from 'k6/http';
45

56
const port = parseInt(__ENV.PORT || '');
67
if (isNaN(port)) {
78
throw new Error('Missing PORT environment variable!');
89
}
910

10-
/** @type {import("k6/options").Options} */
11-
export const options = {
11+
export const options: Options = {
1212
scenarios: {
1313
get: {
1414
executor: 'constant-vus',
@@ -27,8 +27,10 @@ export const options = {
2727
},
2828
};
2929

30-
/** @type {Record<string, { runs: Counter, oks: Counter, duration: Trend }>} */
31-
const scenarioMetrics = {};
30+
const scenarioMetrics: Record<
31+
string,
32+
{ runs: Counter; oks: Counter; duration: Trend }
33+
> = {};
3234
for (const scenario of Object.keys(options.scenarios || {})) {
3335
scenarioMetrics[scenario] = {
3436
runs: new Counter(`query_runs(${scenario})`),
@@ -47,8 +49,7 @@ export default function () {
4749
const begin = Date.now();
4850
metrics.runs.add(1);
4951

50-
/** @type {import("k6/http").RefinedResponse<'text'>} */
51-
let res;
52+
let res: RefinedResponse<'text'>;
5253
switch (scenario) {
5354
case 'get':
5455
res = http.get(`http://localhost:${port}/graphql?query={hello}`);
File renamed without changes.

benchmark/servers/bun.mjs renamed to benchmark/servers/bun.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { createHandler } from '../../lib/use/fetch.mjs';
2-
import { schema } from '../schema.mjs';
1+
import { createHandler } from '../../src/use/fetch';
2+
import { schema } from '../schema';
33

44
const port = parseInt(process.env.PORT || '');
55
if (isNaN(port)) {
@@ -10,8 +10,7 @@ const handler = createHandler({ schema });
1010

1111
export default {
1212
port,
13-
/** @param {Request} req */
14-
fetch(req) {
13+
fetch(req: Request) {
1514
const [path, _search] = req.url.split('?');
1615
if (path.endsWith('/graphql')) {
1716
return handler(req);

benchmark/servers/deno.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
// @ts-expect-error this is deno
22
import { serve } from 'https://deno.land/[email protected]/http/server.ts';
3+
// @ts-expect-error this is deno
34
import { createHandler } from '../../lib/use/fetch.mjs';
4-
import { schema } from '../schema.mjs';
5+
// @ts-expect-error this is deno
6+
import { schema } from '../schema.ts';
57

68
const port = parseInt(
79
// @ts-expect-error this is deno

benchmark/servers/express.mjs renamed to benchmark/servers/express.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import express from 'express';
2-
import { createHandler } from '../../lib/use/express.mjs';
3-
import { schema } from '../schema.mjs';
2+
import { createHandler } from '../../src/use/express';
3+
import { schema } from '../schema';
44

55
const port = parseInt(process.env.PORT || '');
66
if (isNaN(port)) {

benchmark/servers/fastify.mjs renamed to benchmark/servers/fastify.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Fastify from 'fastify';
2-
import { createHandler } from '../../lib/use/fastify.mjs';
3-
import { schema } from '../schema.mjs';
2+
import { createHandler } from '../../src/use/fastify';
3+
import { schema } from '../schema';
44

55
const port = parseInt(process.env.PORT || '');
66
if (isNaN(port)) {

benchmark/servers/http.mjs renamed to benchmark/servers/http.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import http from 'http';
2-
import { schema } from '../schema.mjs';
3-
import { createHandler } from '../../lib/use/http.mjs';
2+
import { schema } from '../schema';
3+
import { createHandler } from '../../src/use/http';
44

55
const port = parseInt(process.env.PORT || '');
66
if (isNaN(port)) {

0 commit comments

Comments
 (0)