diff --git a/src/eventRoute.ts b/src/eventRoute.ts deleted file mode 100644 index 61bec8f..0000000 --- a/src/eventRoute.ts +++ /dev/null @@ -1,11 +0,0 @@ -import getEvent from "./getEvent.js"; -import type { FastifyInstance } from "fastify"; - -/* eslint-disable @typescript-eslint/no-explicit-any */ -/* eslint-disable @typescript-eslint/no-unsafe-call */ -function eventRouter(fastify: FastifyInstance, options: any, done: any) { - fastify.get("/event", getEvent); - done(); -} - -export default eventRouter; diff --git a/src/getStatus.ts b/src/getStatus.ts deleted file mode 100644 index 02a3956..0000000 --- a/src/getStatus.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { VERSION_PRETTY } from "./constants/version.js"; - -function getStatus() { - try { - return { - success: true, - data: { - serverTime: Date.now(), - version: VERSION_PRETTY, - }, - }; - } catch (err) { - return { - success: false, - error: err, - }; - } -} - -export default getStatus; diff --git a/src/index.ts b/src/index.ts index 08cbcd1..5c812f8 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,5 +1,5 @@ -import eventRouter from "./eventRoute.js"; -import statusRouter from "./statusRoute.js"; +import eventRouter from "./routes/eventRoute.js"; +import statusRouter from "./routes/statusRoute.js"; import cors from "@fastify/cors"; import * as dotenv from "dotenv"; import fastify from "fastify"; diff --git a/src/getEvent.ts b/src/routes/eventRoute.ts similarity index 86% rename from src/getEvent.ts rename to src/routes/eventRoute.ts index eaec51d..ae11bcd 100644 --- a/src/getEvent.ts +++ b/src/routes/eventRoute.ts @@ -1,5 +1,13 @@ import { JSDOM } from "jsdom"; import fetch from "node-fetch"; +import type { FastifyInstance } from "fastify"; + +/* eslint-disable @typescript-eslint/no-explicit-any */ +/* eslint-disable @typescript-eslint/no-unsafe-call */ +function eventRouter(fastify: FastifyInstance, options: any, done: any) { + fastify.get("/event", getEvent); + done(); +} const BASE_URL = "https://gamepress.gg/arknights/"; @@ -73,4 +81,4 @@ async function getEvent() { } } -export default getEvent; +export default eventRouter; diff --git a/src/statusRoute.ts b/src/routes/statusRoute.ts similarity index 53% rename from src/statusRoute.ts rename to src/routes/statusRoute.ts index 1ba02f9..acb8ac7 100644 --- a/src/statusRoute.ts +++ b/src/routes/statusRoute.ts @@ -1,4 +1,4 @@ -import getStatus from "./getStatus.js"; +import { VERSION_PRETTY } from "../constants/version.js"; import type { FastifyInstance } from "fastify"; /* eslint-disable @typescript-eslint/no-explicit-any */ @@ -9,3 +9,20 @@ function statusRouter(fastify: FastifyInstance, options: any, done: any) { } export default statusRouter; + +function getStatus() { + try { + return { + success: true, + data: { + serverTime: Date.now(), + version: VERSION_PRETTY, + }, + }; + } catch (err) { + return { + success: false, + error: err, + }; + } +}