From 0b1d12d968e8d65d94acf0f9c5edfd10fb8aadda Mon Sep 17 00:00:00 2001 From: Rory& Date: Sat, 14 Mar 2026 06:13:32 +0100 Subject: Some minor work --- src/api/global.d.ts | 26 ----------------------- src/api/routes/users/@me/billing/country-code.ts | 7 +++--- src/api/routes/users/@me/billing/location-info.ts | 7 +++--- 3 files changed, 8 insertions(+), 32 deletions(-) delete mode 100644 src/api/global.d.ts (limited to 'src/api') diff --git a/src/api/global.d.ts b/src/api/global.d.ts deleted file mode 100644 index 9423b781a..000000000 --- a/src/api/global.d.ts +++ /dev/null @@ -1,26 +0,0 @@ -/* - Spacebar: A FOSS re-implementation and extension of the Discord.com backend. - Copyright (C) 2023 Spacebar and Spacebar Contributors - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . -*/ - -// declare global { -// namespace Express { -// interface Request { -// user_id: any; -// token: any; -// } -// } -// } diff --git a/src/api/routes/users/@me/billing/country-code.ts b/src/api/routes/users/@me/billing/country-code.ts index dd2be6d43..7b90f121c 100644 --- a/src/api/routes/users/@me/billing/country-code.ts +++ b/src/api/routes/users/@me/billing/country-code.ts @@ -18,12 +18,13 @@ import { Request, Response, Router } from "express"; import { route } from "@spacebar/api"; +import { IpDataClient } from "@spacebar/util*"; const router: Router = Router({ mergeParams: true }); -router.get("/", route({}), (req: Request, res: Response) => { - //TODO - res.json({ country_code: "US" }).status(200); +router.get("/", route({}), async (req: Request, res: Response) => { + const country_code = (await IpDataClient.getIpInfo(req.ip!))?.country_code; + res.json({ country_code: country_code }).status(200); }); export default router; diff --git a/src/api/routes/users/@me/billing/location-info.ts b/src/api/routes/users/@me/billing/location-info.ts index 5a57c0ea6..21dfda972 100644 --- a/src/api/routes/users/@me/billing/location-info.ts +++ b/src/api/routes/users/@me/billing/location-info.ts @@ -18,13 +18,14 @@ import { Request, Response, Router } from "express"; import { route } from "@spacebar/api"; +import { IpDataClient } from "@spacebar/util*"; const router: Router = Router({ mergeParams: true }); -router.get("/", route({}), (req: Request, res: Response) => { - //TODO +router.get("/", route({}), async (req: Request, res: Response) => { // TODO: subdivision_code (optional) - res.json({ country_code: "US" }).status(200); + const country_code = (await IpDataClient.getIpInfo(req.ip!))?.country_code; + res.json({ country_code: country_code }).status(200); }); export default router; -- cgit 1.5.1