Skip to content

Commit 2a1756f

Browse files
authored
Replace Fastify with Hono (#790)
1 parent a2b828a commit 2a1756f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+6786
-4972
lines changed

.eslintrc.js

-11
This file was deleted.

.husky/pre-commit

-4
This file was deleted.

bin/update.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
import { updateRelations } from "../src/update"
1+
import { updateRelations } from "../src/update.js"
22

3-
void updateRelations()
3+
await updateRelations()

dprint.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
"typescript": {
77
"semiColons": "asi",
88
"quoteProps": "asNeeded",
9-
"arrowFunction.useParentheses": "force"
9+
"arrowFunction.useParentheses": "force",
10+
"module.sortImportDeclarations": "maintain",
11+
"importDeclaration.sortNamedImports": "maintain"
1012
},
1113
"excludes": [
1214
"**/node_modules",

eslint.config.js

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import antfu from "@antfu/eslint-config"
2+
3+
export default antfu({
4+
stylistic: false,
5+
typescript: {
6+
tsconfigPath: "tsconfig.json",
7+
overrides: {
8+
"no-console": "off",
9+
"ts/no-use-before-define": "off",
10+
"ts/consistent-type-definitions": "off",
11+
"ts/no-unsafe-argument": "off",
12+
"ts/no-unsafe-assignment": "off",
13+
"@typescript-eslint/consistent-type-imports": ["error", { fixStyle: "inline-type-imports" }],
14+
},
15+
},
16+
})

knexfile.ts knexfile.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/** @type5 {import("knex").Knex.Config} */
12
export default {
23
client: "better-sqlite3",
34
migrations: {
@@ -8,4 +9,4 @@ export default {
89
connection: {
910
filename: `./sqlite/${process.env.NODE_ENV ?? "development"}.sqlite3`,
1011
},
11-
} satisfies import("knex").Knex.Config
12+
}

migrations/20190611171759_create_tables.ts migrations/20190611171759_create_tables.js

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
import type { Knex } from "knex"
2-
3-
export async function up(knex: Knex): Promise<void> {
1+
export async function up(knex) {
42
if (await knex.schema.hasTable("relations")) return
53

6-
const promises: Promise<void>[] = []
4+
const promises = []
75

86
promises.push(
97
knex.schema.createTable("relations", (table) => {
@@ -17,6 +15,6 @@ export async function up(knex: Knex): Promise<void> {
1715
await Promise.all(promises)
1816
}
1917

20-
export async function down(knex: Knex): Promise<void> {
18+
export async function down(knex) {
2119
await knex.schema.dropTableIfExists("relations")
2220
}

migrations/20221230042725_anime-lists.ts migrations/20221230042725_anime-lists.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
import type { Knex } from "knex"
2-
3-
export async function up(knex: Knex): Promise<void> {
1+
export async function up(knex) {
42
await knex.schema.alterTable("relations", (table) => {
53
table.text("anime-planet").unique()
64
table.integer("anisearch").unique()
@@ -12,7 +10,7 @@ export async function up(knex: Knex): Promise<void> {
1210
})
1311
}
1412

15-
export async function down(knex: Knex): Promise<void> {
13+
export async function down(knex) {
1614
await knex.schema.alterTable("relations", (table) => {
1715
table.dropColumns(
1816
"anime-planet",

package.json

+36-44
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
{
22
"name": "arm-server",
3+
"type": "module",
34
"author": "BeeeQueue <adam@haglund.dev>",
45
"version": "1.0.0",
56
"private": true,
67
"license": "AGPL-3.0-only",
78
"homepage": "https://arm.haglund.dev/docs",
8-
"packageManager": "pnpm@8.11.0",
9+
"packageManager": "pnpm@9.3.0",
910
"engines": {
1011
"node": ">=20"
1112
},
13+
"simple-git-hooks": {
14+
"pre-commit": "pnpm --silent lint-staged"
15+
},
1216
"lint-staged": {
1317
"*.{js,ts,json}": [
1418
"dprint fmt"
@@ -26,67 +30,55 @@
2630
"docker:run": "docker run -it --rm --name arm -p 3000:3000 arm-server",
2731
"fetch-data": "tsx bin/update.ts --exit",
2832
"lint": "eslint src",
29-
"migrate": "knex migrate:latest --knexfile knexfile.ts",
30-
"migrate:create": "knex migrate:make --knexfile knexfile.ts -x ts",
33+
"migrate": "knex migrate:latest --knexfile knexfile.js",
34+
"migrate:create": "knex migrate:make --knexfile knexfile.js -x ts",
3135
"start": "pnpm --silent run migrate && tsx src/index.ts",
3236
"test": "NODE_ENV=test pnpm --silent run migrate && vitest",
3337
"typecheck": "tsc --noEmit",
34-
"prepare": "is-ci || husky install"
38+
"prepare": "is-ci || simple-git-hooks"
3539
},
3640
"dependencies": {
37-
"@fastify/cors": "8.4.1",
38-
"@fastify/helmet": "11.1.1",
39-
"@sentry/node": "7.81.1",
40-
"@tsconfig/node20": "20.1.2",
41-
"@tsconfig/strictest": "2.0.3",
42-
"better-sqlite3": "9.4.1",
43-
"fastify": "4.24.3",
41+
"@hono/node-server": "1.11.2",
42+
"@hono/sentry": "1.1.0",
43+
"@hono/zod-validator": "0.2.2",
44+
"@sentry/node": "8.9.2",
45+
"@tsconfig/node20": "20.1.4",
46+
"@tsconfig/strictest": "2.0.5",
47+
"better-sqlite3": "11.0.0",
48+
"hono": "4.4.5",
4449
"is-ci": "3.0.1",
4550
"knex": "3.0.1",
46-
"nanoid": "5.0.3",
47-
"ofetch": "1.3.3",
48-
"pino": "8.16.2",
49-
"pino-pretty": "10.2.3",
50-
"remeda": "1.29.0",
51-
"sucrase": "3.34.0",
52-
"tsx": "4.7.0",
53-
"type-fest": "4.8.2",
54-
"typescript": "5.3.2",
55-
"zod": "3.22.4"
51+
"ofetch": "1.3.4",
52+
"pino": "9.2.0",
53+
"pino-pretty": "11.2.1",
54+
"rambda": "9.2.0",
55+
"sucrase": "3.35.0",
56+
"tsx": "4.15.4",
57+
"type-fest": "4.20.0",
58+
"typescript": "5.4.5",
59+
"zod": "3.23.8"
5660
},
5761
"devDependencies": {
58-
"@beequeue/eslint-plugin": "4.0.0",
62+
"@antfu/eslint-config": "2.21.1",
5963
"@types/json-schema": "7.0.15",
60-
"@types/node": "20.11.24",
61-
"@vitest/coverage-v8": "0.34.6",
64+
"@types/node": "20.14.2",
65+
"@vitest/coverage-v8": "1.6.0",
6266
"ajv": "8.12.0",
63-
"dotenv": "16.3.1",
67+
"dotenv": "16.4.5",
6468
"eslint": "8.57.0",
65-
"husky": "8.0.3",
66-
"lint-staged": "15.2.2",
69+
"lint-staged": "15.2.7",
6770
"onchange": "7.1.0",
6871
"redoc-cli": "0.13.21",
72+
"simple-git-hooks": "2.11.1",
6973
"tsconfig-paths": "4.2.0",
70-
"vitest": "0.34.6"
74+
"vitest": "1.6.0"
7175
},
7276
"pnpm": {
7377
"overrides": {
74-
"@types/node": "20.5.9",
75-
"esbuild": "0.19.2",
76-
"node-fetch": "npm:node-fetch-native@1.4.0",
77-
"array-includes": "npm:@nolyfill/array-includes@latest",
78-
"array.prototype.flat": "npm:@nolyfill/array.prototype.flat@latest",
79-
"array.prototype.flatmap": "npm:@nolyfill/array.prototype.flatmap@latest",
80-
"array.prototype.tosorted": "npm:@nolyfill/array.prototype.tosorted@latest",
81-
"has": "npm:@nolyfill/has@latest",
82-
"object.assign": "npm:@nolyfill/object.assign@latest",
83-
"object.entries": "npm:@nolyfill/object.entries@latest",
84-
"object.fromentries": "npm:@nolyfill/object.fromentries@latest",
85-
"object.hasown": "npm:@nolyfill/object.hasown@latest",
86-
"object.values": "npm:@nolyfill/object.values@latest",
87-
"string.prototype.matchall": "npm:@nolyfill/string.prototype.matchall@latest",
88-
"side-channel": "npm:@nolyfill/side-channel@latest",
89-
"es-iterator-helpers": "npm:@nolyfill/es-iterator-helpers@latest"
78+
"assert": "npm:@nolyfill/assert@latest",
79+
"hasown": "npm:@nolyfill/hasown@latest",
80+
"isarray": "npm:@nolyfill/isarray@latest",
81+
"side-channel": "npm:@nolyfill/side-channel@latest"
9082
}
9183
}
9284
}

0 commit comments

Comments
 (0)