chore: update all dependencies, update routes for latest fastify

This commit is contained in:
Vjacheslav Trushkin 2025-11-27 17:31:14 +02:00
parent f79638ef5f
commit 8e35844326
3 changed files with 1063 additions and 2106 deletions

3137
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -11,7 +11,7 @@
"type": "git", "type": "git",
"url": "https://github.com/iconify/api.git" "url": "https://github.com/iconify/api.git"
}, },
"packageManager": "npm@11.6.2", "packageManager": "npm@11.6.4",
"engines": { "engines": {
"node": ">=22.20.0" "node": ">=22.20.0"
}, },
@ -26,17 +26,17 @@
"docker:publish": "docker push iconify/api" "docker:publish": "docker push iconify/api"
}, },
"dependencies": { "dependencies": {
"@fastify/formbody": "^7.4.0", "@fastify/formbody": "^8.0.2",
"@iconify/tools": "^4.1.4", "@iconify/tools": "^5.0.0-beta.5",
"@iconify/types": "^2.0.0", "@iconify/types": "^2.0.0",
"@iconify/utils": "^2.3.0", "@iconify/utils": "^3.1.0",
"dotenv": "^17.2.3", "dotenv": "^17.2.3",
"fastify": "^4.29.1" "fastify": "^5.6.2"
}, },
"devDependencies": { "devDependencies": {
"@types/jest": "^30.0.0", "@types/jest": "^30.0.0",
"@types/node": "^24.10.1", "@types/node": "^24.10.1",
"typescript": "^5.9.3", "typescript": "^5.9.3",
"vitest": "^4.0.10" "vitest": "^4.0.14"
} }
} }

View File

@ -23,7 +23,9 @@ import { errorText } from './helpers/errors.js';
export async function startHTTPServer() { export async function startHTTPServer() {
// Create HTP server // Create HTP server
const server = fastify({ const server = fastify({
routerOptions: {
caseSensitive: true, caseSensitive: true,
},
}); });
// Support `application/x-www-form-urlencoded` // Support `application/x-www-form-urlencoded`
@ -199,21 +201,21 @@ export async function startHTTPServer() {
// Redirect // Redirect
server.get('/', (req, res) => { server.get('/', (req, res) => {
res.redirect(301, appConfig.redirectIndex); res.redirect(appConfig.redirectIndex, 301);
}); });
// Error handling // Error handling
server.setDefaultRoute((req, res) => { server.setNotFoundHandler((req, res) => {
res.statusCode = 404; res.statusCode = 404;
console.log('404:', req.url); console.log('404:', req.url);
// Need to set custom headers because hooks don't work here // Need to set custom headers because hooks don't work here
for (let i = 0; i < headers.length; i++) { for (let i = 0; i < headers.length; i++) {
const header = headers[i]; const header = headers[i];
res.setHeader(header.key, header.value); res.header(header.key, header.value);
} }
res.end(); res.send();
}); });
// Start it // Start it