From c2d9971e14626269aa437d3b105f1c84653047d2 Mon Sep 17 00:00:00 2001 From: uurgothat Date: Wed, 29 Sep 2021 17:28:13 +0300 Subject: store improvements --- api/src/routes/store/applications.ts | 12 ---- api/src/routes/store/applications/#id/index.ts | 78 ++++++++++++++++++++++++++ api/src/routes/store/skus.ts | 12 ---- api/src/routes/store/skus/#id/index.ts | 78 ++++++++++++++++++++++++++ 4 files changed, 156 insertions(+), 24 deletions(-) delete mode 100644 api/src/routes/store/applications.ts create mode 100644 api/src/routes/store/applications/#id/index.ts delete mode 100644 api/src/routes/store/skus.ts create mode 100644 api/src/routes/store/skus/#id/index.ts (limited to 'api/src') diff --git a/api/src/routes/store/applications.ts b/api/src/routes/store/applications.ts deleted file mode 100644 index 352c1752..00000000 --- a/api/src/routes/store/applications.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { Request, Response, Router } from "express"; -import { route } from "@fosscord/api"; - -const router: Router = Router(); - -router.get("/applications/:id", route({}), async (req: Request, res: Response) => { - //TODO - const { id } = req.params; - res.json([]).status(200); -}); - -export default router; diff --git a/api/src/routes/store/applications/#id/index.ts b/api/src/routes/store/applications/#id/index.ts new file mode 100644 index 00000000..53b61c29 --- /dev/null +++ b/api/src/routes/store/applications/#id/index.ts @@ -0,0 +1,78 @@ +import { Request, Response, Router } from "express"; +import { route } from "@fosscord/api"; + +const router: Router = Router(); + +router.get("/", route({}), async (req: Request, res: Response) => { + //TODO + res.json({ + id: "", + summary: "", + sku: { + id: "", + type: 1, + dependent_sku_id: null, + application_id: "", + manifets_labels: [], + access_type: 2, + name: "", + features: [], + relase_date: "", + premium: false, + slug: "", + flags: 4, + genres: [], + legal_notice: "", + application: { + id: "", + name: "", + icon: "", + description: "", + summary: "", + cover_image: "", + primary_sku_id: "", + hook: true, + slug: "", + guild_id: "", + bot_public: "", + bot_require_code_grant: false, + verify_key: "", + publishers: [ + { + id: "", + name: "" + } + ], + developers: [ + { + id: "", + name: "" + } + ], + system_requirements: {}, + show_age_gate: false, + price: { + amount: 0, + currency: "EUR" + }, + locales: [] + }, + tagline: "", + description: "", + carousel_items: [ + { + asset_id: "" + } + ], + header_logo_dark_theme: {}, //{id: "", size: 4665, mime_type: "image/gif", width 160, height: 160} + header_logo_light_theme: {}, + box_art: {}, + thumbnail: {}, + header_background: {}, + hero_background: {}, + assets: [] + } + }).status(200); +}); + +export default router; diff --git a/api/src/routes/store/skus.ts b/api/src/routes/store/skus.ts deleted file mode 100644 index 7d0e12eb..00000000 --- a/api/src/routes/store/skus.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { Request, Response, Router } from "express"; -import { route } from "@fosscord/api"; - -const router: Router = Router(); - -router.get("/skus/:id", route({}), async (req: Request, res: Response) => { - //TODO - const { id } = req.params; - res.json([]).status(200); -}); - -export default router; diff --git a/api/src/routes/store/skus/#id/index.ts b/api/src/routes/store/skus/#id/index.ts new file mode 100644 index 00000000..53b61c29 --- /dev/null +++ b/api/src/routes/store/skus/#id/index.ts @@ -0,0 +1,78 @@ +import { Request, Response, Router } from "express"; +import { route } from "@fosscord/api"; + +const router: Router = Router(); + +router.get("/", route({}), async (req: Request, res: Response) => { + //TODO + res.json({ + id: "", + summary: "", + sku: { + id: "", + type: 1, + dependent_sku_id: null, + application_id: "", + manifets_labels: [], + access_type: 2, + name: "", + features: [], + relase_date: "", + premium: false, + slug: "", + flags: 4, + genres: [], + legal_notice: "", + application: { + id: "", + name: "", + icon: "", + description: "", + summary: "", + cover_image: "", + primary_sku_id: "", + hook: true, + slug: "", + guild_id: "", + bot_public: "", + bot_require_code_grant: false, + verify_key: "", + publishers: [ + { + id: "", + name: "" + } + ], + developers: [ + { + id: "", + name: "" + } + ], + system_requirements: {}, + show_age_gate: false, + price: { + amount: 0, + currency: "EUR" + }, + locales: [] + }, + tagline: "", + description: "", + carousel_items: [ + { + asset_id: "" + } + ], + header_logo_dark_theme: {}, //{id: "", size: 4665, mime_type: "image/gif", width 160, height: 160} + header_logo_light_theme: {}, + box_art: {}, + thumbnail: {}, + header_background: {}, + hero_background: {}, + assets: [] + } + }).status(200); +}); + +export default router; -- cgit 1.5.1 From 9e07c72a72e60ca8c3c3e6270867accd32b56ece Mon Sep 17 00:00:00 2001 From: uurgothat Date: Thu, 30 Sep 2021 17:57:51 +0300 Subject: Add misc routes --- api/src/routes/applications/#id/entitlements.ts | 12 ++++ .../#channel_id/messages/#message_id/crosspost.ts | 27 +++++++- api/src/routes/discovery.ts | 12 ++++ api/src/routes/stage-instances.ts | 11 +++ api/src/routes/store/applications/#id/index.ts | 78 ---------------------- .../store/published-listings/applications.ts | 78 ++++++++++++++++++++++ .../applications/#id/subscription-plans.ts | 24 +++++++ api/src/routes/store/published-listings/skus.ts | 78 ++++++++++++++++++++++ .../skus/#id/subscription-plans.ts | 24 +++++++ api/src/routes/store/skus/#id/index.ts | 78 ---------------------- .../@me/activities/statistics/applications.ts | 11 +++ .../routes/users/@me/billing/payment-sources.ts | 11 +++ api/src/routes/users/@me/email-settings.ts | 19 ++++++ api/src/routes/users/@me/entitlements.ts | 12 ++++ .../users/@me/guilds/premium/subscription-slots.ts | 11 +++ api/src/routes/users/@me/notes.ts | 11 +++ 16 files changed, 339 insertions(+), 158 deletions(-) create mode 100644 api/src/routes/applications/#id/entitlements.ts create mode 100644 api/src/routes/discovery.ts create mode 100644 api/src/routes/stage-instances.ts delete mode 100644 api/src/routes/store/applications/#id/index.ts create mode 100644 api/src/routes/store/published-listings/applications.ts create mode 100644 api/src/routes/store/published-listings/applications/#id/subscription-plans.ts create mode 100644 api/src/routes/store/published-listings/skus.ts create mode 100644 api/src/routes/store/published-listings/skus/#id/subscription-plans.ts delete mode 100644 api/src/routes/store/skus/#id/index.ts create mode 100644 api/src/routes/users/@me/activities/statistics/applications.ts create mode 100644 api/src/routes/users/@me/billing/payment-sources.ts create mode 100644 api/src/routes/users/@me/email-settings.ts create mode 100644 api/src/routes/users/@me/entitlements.ts create mode 100644 api/src/routes/users/@me/guilds/premium/subscription-slots.ts create mode 100644 api/src/routes/users/@me/notes.ts (limited to 'api/src') diff --git a/api/src/routes/applications/#id/entitlements.ts b/api/src/routes/applications/#id/entitlements.ts new file mode 100644 index 00000000..1152e500 --- /dev/null +++ b/api/src/routes/applications/#id/entitlements.ts @@ -0,0 +1,12 @@ +import { Router, Response, Request } from "express"; +import { route } from "@fosscord/api"; + +const router = Router(); + +router.get("/", route({}), (req: Request, res: Response) => { + // TODO: + //const { exclude_consumed } = req.query; + res.status(200).send([]); +}); + +export default router; diff --git a/api/src/routes/channels/#channel_id/messages/#message_id/crosspost.ts b/api/src/routes/channels/#channel_id/messages/#message_id/crosspost.ts index 6753e832..8174a61f 100644 --- a/api/src/routes/channels/#channel_id/messages/#message_id/crosspost.ts +++ b/api/src/routes/channels/#channel_id/messages/#message_id/crosspost.ts @@ -1,8 +1,31 @@ import { Router, Response, Request } from "express"; +import { route } from "@fosscord/api"; const router = Router(); -// TODO: -// router.post("/", (req: Request, res: Response) => {}); +router.post("/", route({ permission: "MANAGE_MESSAGES" }), (req: Request, res: Response) => { + // TODO: + //const { locale, primary_only } = req.query; + res.json({ + id: "", + type: 0, + content: "", + channel_id: "", + author: {id: "", + username: "", + avatar: "", + discriminator: "", public_flags: 64}, + attachments: [], + embeds: [], + mentions: [], + mention_roles: [], + pinned: false, + mention_everyone: false, + tts: false, + timestamp: "", + edited_timestamp: null, + flags: 1, components: []}).status(200); +}); export default router; + diff --git a/api/src/routes/discovery.ts b/api/src/routes/discovery.ts new file mode 100644 index 00000000..9e6e0164 --- /dev/null +++ b/api/src/routes/discovery.ts @@ -0,0 +1,12 @@ +import { Router, Response, Request } from "express"; +import { route } from "@fosscord/api"; + +const router = Router(); + +router.get("/categories", route({}), (req: Request, res: Response) => { + // TODO: + //const { locale, primary_only } = req.query; + res.json([]).status(200); +}); + +export default router; diff --git a/api/src/routes/stage-instances.ts b/api/src/routes/stage-instances.ts new file mode 100644 index 00000000..411e95bf --- /dev/null +++ b/api/src/routes/stage-instances.ts @@ -0,0 +1,11 @@ +import { Request, Response, Router } from "express"; +import { route } from "@fosscord/api"; + +const router: Router = Router(); + +router.get("/", route({}), async (req: Request, res: Response) => { + //TODO + res.json([]).status(200); +}); + +export default router; diff --git a/api/src/routes/store/applications/#id/index.ts b/api/src/routes/store/applications/#id/index.ts deleted file mode 100644 index 53b61c29..00000000 --- a/api/src/routes/store/applications/#id/index.ts +++ /dev/null @@ -1,78 +0,0 @@ -import { Request, Response, Router } from "express"; -import { route } from "@fosscord/api"; - -const router: Router = Router(); - -router.get("/", route({}), async (req: Request, res: Response) => { - //TODO - res.json({ - id: "", - summary: "", - sku: { - id: "", - type: 1, - dependent_sku_id: null, - application_id: "", - manifets_labels: [], - access_type: 2, - name: "", - features: [], - relase_date: "", - premium: false, - slug: "", - flags: 4, - genres: [], - legal_notice: "", - application: { - id: "", - name: "", - icon: "", - description: "", - summary: "", - cover_image: "", - primary_sku_id: "", - hook: true, - slug: "", - guild_id: "", - bot_public: "", - bot_require_code_grant: false, - verify_key: "", - publishers: [ - { - id: "", - name: "" - } - ], - developers: [ - { - id: "", - name: "" - } - ], - system_requirements: {}, - show_age_gate: false, - price: { - amount: 0, - currency: "EUR" - }, - locales: [] - }, - tagline: "", - description: "", - carousel_items: [ - { - asset_id: "" - } - ], - header_logo_dark_theme: {}, //{id: "", size: 4665, mime_type: "image/gif", width 160, height: 160} - header_logo_light_theme: {}, - box_art: {}, - thumbnail: {}, - header_background: {}, - hero_background: {}, - assets: [] - } - }).status(200); -}); - -export default router; diff --git a/api/src/routes/store/published-listings/applications.ts b/api/src/routes/store/published-listings/applications.ts new file mode 100644 index 00000000..53b61c29 --- /dev/null +++ b/api/src/routes/store/published-listings/applications.ts @@ -0,0 +1,78 @@ +import { Request, Response, Router } from "express"; +import { route } from "@fosscord/api"; + +const router: Router = Router(); + +router.get("/", route({}), async (req: Request, res: Response) => { + //TODO + res.json({ + id: "", + summary: "", + sku: { + id: "", + type: 1, + dependent_sku_id: null, + application_id: "", + manifets_labels: [], + access_type: 2, + name: "", + features: [], + relase_date: "", + premium: false, + slug: "", + flags: 4, + genres: [], + legal_notice: "", + application: { + id: "", + name: "", + icon: "", + description: "", + summary: "", + cover_image: "", + primary_sku_id: "", + hook: true, + slug: "", + guild_id: "", + bot_public: "", + bot_require_code_grant: false, + verify_key: "", + publishers: [ + { + id: "", + name: "" + } + ], + developers: [ + { + id: "", + name: "" + } + ], + system_requirements: {}, + show_age_gate: false, + price: { + amount: 0, + currency: "EUR" + }, + locales: [] + }, + tagline: "", + description: "", + carousel_items: [ + { + asset_id: "" + } + ], + header_logo_dark_theme: {}, //{id: "", size: 4665, mime_type: "image/gif", width 160, height: 160} + header_logo_light_theme: {}, + box_art: {}, + thumbnail: {}, + header_background: {}, + hero_background: {}, + assets: [] + } + }).status(200); +}); + +export default router; diff --git a/api/src/routes/store/published-listings/applications/#id/subscription-plans.ts b/api/src/routes/store/published-listings/applications/#id/subscription-plans.ts new file mode 100644 index 00000000..77f949d9 --- /dev/null +++ b/api/src/routes/store/published-listings/applications/#id/subscription-plans.ts @@ -0,0 +1,24 @@ +import { Request, Response, Router } from "express"; +import { route } from "@fosscord/api"; + +const router: Router = Router(); + +router.get("/", route({}), async (req: Request, res: Response) => { + //TODO + res.json([ + { + id: "", + name: "", + interval: 1, + interval_count: 1, + tax_inclusive: true, + sku_id: "", + fallback_price: 499, + fallback_currency: "eur", + currency: "eur", + price: 4199, + price_tier: null + }]).status(200); +}); + +export default router; diff --git a/api/src/routes/store/published-listings/skus.ts b/api/src/routes/store/published-listings/skus.ts new file mode 100644 index 00000000..53b61c29 --- /dev/null +++ b/api/src/routes/store/published-listings/skus.ts @@ -0,0 +1,78 @@ +import { Request, Response, Router } from "express"; +import { route } from "@fosscord/api"; + +const router: Router = Router(); + +router.get("/", route({}), async (req: Request, res: Response) => { + //TODO + res.json({ + id: "", + summary: "", + sku: { + id: "", + type: 1, + dependent_sku_id: null, + application_id: "", + manifets_labels: [], + access_type: 2, + name: "", + features: [], + relase_date: "", + premium: false, + slug: "", + flags: 4, + genres: [], + legal_notice: "", + application: { + id: "", + name: "", + icon: "", + description: "", + summary: "", + cover_image: "", + primary_sku_id: "", + hook: true, + slug: "", + guild_id: "", + bot_public: "", + bot_require_code_grant: false, + verify_key: "", + publishers: [ + { + id: "", + name: "" + } + ], + developers: [ + { + id: "", + name: "" + } + ], + system_requirements: {}, + show_age_gate: false, + price: { + amount: 0, + currency: "EUR" + }, + locales: [] + }, + tagline: "", + description: "", + carousel_items: [ + { + asset_id: "" + } + ], + header_logo_dark_theme: {}, //{id: "", size: 4665, mime_type: "image/gif", width 160, height: 160} + header_logo_light_theme: {}, + box_art: {}, + thumbnail: {}, + header_background: {}, + hero_background: {}, + assets: [] + } + }).status(200); +}); + +export default router; diff --git a/api/src/routes/store/published-listings/skus/#id/subscription-plans.ts b/api/src/routes/store/published-listings/skus/#id/subscription-plans.ts new file mode 100644 index 00000000..77f949d9 --- /dev/null +++ b/api/src/routes/store/published-listings/skus/#id/subscription-plans.ts @@ -0,0 +1,24 @@ +import { Request, Response, Router } from "express"; +import { route } from "@fosscord/api"; + +const router: Router = Router(); + +router.get("/", route({}), async (req: Request, res: Response) => { + //TODO + res.json([ + { + id: "", + name: "", + interval: 1, + interval_count: 1, + tax_inclusive: true, + sku_id: "", + fallback_price: 499, + fallback_currency: "eur", + currency: "eur", + price: 4199, + price_tier: null + }]).status(200); +}); + +export default router; diff --git a/api/src/routes/store/skus/#id/index.ts b/api/src/routes/store/skus/#id/index.ts deleted file mode 100644 index 53b61c29..00000000 --- a/api/src/routes/store/skus/#id/index.ts +++ /dev/null @@ -1,78 +0,0 @@ -import { Request, Response, Router } from "express"; -import { route } from "@fosscord/api"; - -const router: Router = Router(); - -router.get("/", route({}), async (req: Request, res: Response) => { - //TODO - res.json({ - id: "", - summary: "", - sku: { - id: "", - type: 1, - dependent_sku_id: null, - application_id: "", - manifets_labels: [], - access_type: 2, - name: "", - features: [], - relase_date: "", - premium: false, - slug: "", - flags: 4, - genres: [], - legal_notice: "", - application: { - id: "", - name: "", - icon: "", - description: "", - summary: "", - cover_image: "", - primary_sku_id: "", - hook: true, - slug: "", - guild_id: "", - bot_public: "", - bot_require_code_grant: false, - verify_key: "", - publishers: [ - { - id: "", - name: "" - } - ], - developers: [ - { - id: "", - name: "" - } - ], - system_requirements: {}, - show_age_gate: false, - price: { - amount: 0, - currency: "EUR" - }, - locales: [] - }, - tagline: "", - description: "", - carousel_items: [ - { - asset_id: "" - } - ], - header_logo_dark_theme: {}, //{id: "", size: 4665, mime_type: "image/gif", width 160, height: 160} - header_logo_light_theme: {}, - box_art: {}, - thumbnail: {}, - header_background: {}, - hero_background: {}, - assets: [] - } - }).status(200); -}); - -export default router; diff --git a/api/src/routes/users/@me/activities/statistics/applications.ts b/api/src/routes/users/@me/activities/statistics/applications.ts new file mode 100644 index 00000000..834be35c --- /dev/null +++ b/api/src/routes/users/@me/activities/statistics/applications.ts @@ -0,0 +1,11 @@ +import { Router, Response, Request } from "express"; +import { route } from "@fosscord/api"; + +const router = Router(); + +router.get("/", route({}), (req: Request, res: Response) => { + // TODO: + res.json([]).status(200) +}); + +export default router; diff --git a/api/src/routes/users/@me/billing/payment-sources.ts b/api/src/routes/users/@me/billing/payment-sources.ts new file mode 100644 index 00000000..834be35c --- /dev/null +++ b/api/src/routes/users/@me/billing/payment-sources.ts @@ -0,0 +1,11 @@ +import { Router, Response, Request } from "express"; +import { route } from "@fosscord/api"; + +const router = Router(); + +router.get("/", route({}), (req: Request, res: Response) => { + // TODO: + res.json([]).status(200) +}); + +export default router; diff --git a/api/src/routes/users/@me/email-settings.ts b/api/src/routes/users/@me/email-settings.ts new file mode 100644 index 00000000..2d961a0e --- /dev/null +++ b/api/src/routes/users/@me/email-settings.ts @@ -0,0 +1,19 @@ +import { Router, Response, Request } from "express"; +import { route } from "@fosscord/api"; + +const router = Router(); + +router.get("/", route({}), (req: Request, res: Response) => { + // TODO: + res.json({ + categories: { + social: true, + communication: true, + tips: false, + updates_and_announcements: false, + recommendations_and_events: false }, + initialized: false + }).status(200); +}); + +export default router; diff --git a/api/src/routes/users/@me/entitlements.ts b/api/src/routes/users/@me/entitlements.ts new file mode 100644 index 00000000..7be3634b --- /dev/null +++ b/api/src/routes/users/@me/entitlements.ts @@ -0,0 +1,12 @@ +import { Router, Response, Request } from "express"; +import { route } from "@fosscord/api"; + +const router = Router(); + +router.get("/gifts", route({}), (req: Request, res: Response) => { + // TODO: + //const { locale, primary_only } = req.query; + res.json([]).status(200); +}); + +export default router; diff --git a/api/src/routes/users/@me/guilds/premium/subscription-slots.ts b/api/src/routes/users/@me/guilds/premium/subscription-slots.ts new file mode 100644 index 00000000..b487a2ce --- /dev/null +++ b/api/src/routes/users/@me/guilds/premium/subscription-slots.ts @@ -0,0 +1,11 @@ +import { Router, Response, Request } from "express"; +import { route } from "@fosscord/api"; + +const router = Router(); + +router.get("/", route({}), (req: Request, res: Response) => { + // TODO: + res.json([]).status(200)); +}); + +export default router; diff --git a/api/src/routes/users/@me/notes.ts b/api/src/routes/users/@me/notes.ts new file mode 100644 index 00000000..235c2baf --- /dev/null +++ b/api/src/routes/users/@me/notes.ts @@ -0,0 +1,11 @@ +import { Request, Response, Router } from "express"; +import { route } from "@fosscord/api"; + +const router: Router = Router(); + +router.put("/", route({}), async (req: Request, res: Response) => { + //TODO + res.json({code: 0}).status(400); +}); + +export default router; -- cgit 1.5.1 From 7ae37c53719c782838c5cf77c3ad719ca20d72df Mon Sep 17 00:00:00 2001 From: uurgothat Date: Thu, 30 Sep 2021 18:57:53 +0300 Subject: hotfix for misc routes --- .../routes/channels/#channel_id/messages/#message_id/crosspost.ts | 1 - api/src/routes/store/published-listings/applications.ts | 3 ++- api/src/routes/store/published-listings/skus.ts | 3 ++- api/src/routes/users/@me/entitlements.ts | 1 - api/src/routes/users/@me/guilds/premium/subscription-slots.ts | 2 +- api/src/routes/users/@me/notes.ts | 7 +++++-- 6 files changed, 10 insertions(+), 7 deletions(-) (limited to 'api/src') diff --git a/api/src/routes/channels/#channel_id/messages/#message_id/crosspost.ts b/api/src/routes/channels/#channel_id/messages/#message_id/crosspost.ts index 8174a61f..de0c01f1 100644 --- a/api/src/routes/channels/#channel_id/messages/#message_id/crosspost.ts +++ b/api/src/routes/channels/#channel_id/messages/#message_id/crosspost.ts @@ -5,7 +5,6 @@ const router = Router(); router.post("/", route({ permission: "MANAGE_MESSAGES" }), (req: Request, res: Response) => { // TODO: - //const { locale, primary_only } = req.query; res.json({ id: "", type: 0, diff --git a/api/src/routes/store/published-listings/applications.ts b/api/src/routes/store/published-listings/applications.ts index 53b61c29..f06a01e4 100644 --- a/api/src/routes/store/published-listings/applications.ts +++ b/api/src/routes/store/published-listings/applications.ts @@ -3,8 +3,9 @@ import { route } from "@fosscord/api"; const router: Router = Router(); -router.get("/", route({}), async (req: Request, res: Response) => { +router.get("/:id", route({}), async (req: Request, res: Response) => { //TODO + const id = req.params.id; res.json({ id: "", summary: "", diff --git a/api/src/routes/store/published-listings/skus.ts b/api/src/routes/store/published-listings/skus.ts index 53b61c29..f06a01e4 100644 --- a/api/src/routes/store/published-listings/skus.ts +++ b/api/src/routes/store/published-listings/skus.ts @@ -3,8 +3,9 @@ import { route } from "@fosscord/api"; const router: Router = Router(); -router.get("/", route({}), async (req: Request, res: Response) => { +router.get("/:id", route({}), async (req: Request, res: Response) => { //TODO + const id = req.params.id; res.json({ id: "", summary: "", diff --git a/api/src/routes/users/@me/entitlements.ts b/api/src/routes/users/@me/entitlements.ts index 7be3634b..341e2b4c 100644 --- a/api/src/routes/users/@me/entitlements.ts +++ b/api/src/routes/users/@me/entitlements.ts @@ -5,7 +5,6 @@ const router = Router(); router.get("/gifts", route({}), (req: Request, res: Response) => { // TODO: - //const { locale, primary_only } = req.query; res.json([]).status(200); }); diff --git a/api/src/routes/users/@me/guilds/premium/subscription-slots.ts b/api/src/routes/users/@me/guilds/premium/subscription-slots.ts index b487a2ce..014df8af 100644 --- a/api/src/routes/users/@me/guilds/premium/subscription-slots.ts +++ b/api/src/routes/users/@me/guilds/premium/subscription-slots.ts @@ -5,7 +5,7 @@ const router = Router(); router.get("/", route({}), (req: Request, res: Response) => { // TODO: - res.json([]).status(200)); + res.json([]).status(200); }); export default router; diff --git a/api/src/routes/users/@me/notes.ts b/api/src/routes/users/@me/notes.ts index 235c2baf..2ef27bc0 100644 --- a/api/src/routes/users/@me/notes.ts +++ b/api/src/routes/users/@me/notes.ts @@ -3,9 +3,12 @@ import { route } from "@fosscord/api"; const router: Router = Router(); -router.put("/", route({}), async (req: Request, res: Response) => { +router.put("/:id", route({}), async (req: Request, res: Response) => { //TODO - res.json({code: 0}).status(400); + res.json({ + message: "400: Bad Request", + code: 0 + }).status(400); }); export default router; -- cgit 1.5.1 From 966fec29534143565d1298ada9260a82c1132440 Mon Sep 17 00:00:00 2001 From: Flam3rboy <34555296+Flam3rboy@users.noreply.github.com> Date: Fri, 1 Oct 2021 20:11:05 +0200 Subject: :sparkles: registration disabled notice --- api/src/routes/auth/register.ts | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'api/src') diff --git a/api/src/routes/auth/register.ts b/api/src/routes/auth/register.ts index 9c058399..75fa68c3 100644 --- a/api/src/routes/auth/register.ts +++ b/api/src/routes/auth/register.ts @@ -50,6 +50,15 @@ router.post("/", route({ body: "RegisterSchema" }), async (req: Request, res: Re const { register, security } = Config.get(); const ip = getIpAdress(req); + if (register.disabled) { + throw FieldErrors({ + email: { + code: "DISABLED", + message: "registration is disabled on this instance" + } + }); + } + if (register.blockProxies) { if (isProxy(await IPAnalysis(ip))) { console.log(`proxy ${ip} blocked from registration`); -- cgit 1.5.1 From f3dcab6b54f7576edfdf4bd5501a59b24af0b413 Mon Sep 17 00:00:00 2001 From: The Arcane Brony Date: Fri, 1 Oct 2021 22:11:56 +0200 Subject: Add setting to show all guilds in discovery, fix query for guild discovery --- api/src/routes/discoverable-guilds.ts | 7 +++++-- util/src/entities/Config.ts | 8 ++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) (limited to 'api/src') diff --git a/api/src/routes/discoverable-guilds.ts b/api/src/routes/discoverable-guilds.ts index f667eb2a..509abc9e 100644 --- a/api/src/routes/discoverable-guilds.ts +++ b/api/src/routes/discoverable-guilds.ts @@ -1,16 +1,19 @@ -import { Guild } from "@fosscord/util"; +import { Guild, Config } from "@fosscord/util"; + import { Router, Request, Response } from "express"; import { route } from "@fosscord/api"; + const router = Router(); router.get("/", route({}), async (req: Request, res: Response) => { const { limit } = req.params; + var showAllGuilds = Config.get().guild.showAllGuildsInDiscovery; // ! this only works using SQL querys // TODO: implement this with default typeorm query // const guilds = await Guild.find({ where: { features: "DISCOVERABLE" } }); //, take: Math.abs(Number(limit)) }); - const guilds = await Guild.find({ where: `"features" LIKE 'COMMUNITY'`, take: Math.abs(Number(limit)) }); + const guilds = showAllGuilds ? await Guild.find({take: Math.abs(Number(limit))}) : await Guild.find({ where: `"features" LIKE '%COMMUNITY%'`, take: Math.abs(Number(limit)) }); res.send({ guilds: guilds }); }); diff --git a/util/src/entities/Config.ts b/util/src/entities/Config.ts index 8efa853c..edce92a9 100644 --- a/util/src/entities/Config.ts +++ b/util/src/entities/Config.ts @@ -144,6 +144,10 @@ export interface ConfigValue { useDefaultAsOptimal: boolean; available: Region[]; }; + + guild: { + showAllGuildsInDiscovery: boolean; + }; rabbitmq: { host: string | null; }; @@ -295,6 +299,10 @@ export const DefaultConfigOptions: ConfigValue = { }, ], }, + + guild: { + showAllGuildsInDiscovery: false, + }, rabbitmq: { host: null, }, -- cgit 1.5.1 From c772816fd9037505baebc6f82fb4185ff4d2abf0 Mon Sep 17 00:00:00 2001 From: The Arcane Brony Date: Fri, 1 Oct 2021 22:43:58 +0200 Subject: Add default value to guild discovery" --- api/src/routes/discoverable-guilds.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'api/src') diff --git a/api/src/routes/discoverable-guilds.ts b/api/src/routes/discoverable-guilds.ts index 509abc9e..b626b084 100644 --- a/api/src/routes/discoverable-guilds.ts +++ b/api/src/routes/discoverable-guilds.ts @@ -9,11 +9,10 @@ const router = Router(); router.get("/", route({}), async (req: Request, res: Response) => { const { limit } = req.params; var showAllGuilds = Config.get().guild.showAllGuildsInDiscovery; - // ! this only works using SQL querys // TODO: implement this with default typeorm query // const guilds = await Guild.find({ where: { features: "DISCOVERABLE" } }); //, take: Math.abs(Number(limit)) }); - const guilds = showAllGuilds ? await Guild.find({take: Math.abs(Number(limit))}) : await Guild.find({ where: `"features" LIKE '%COMMUNITY%'`, take: Math.abs(Number(limit)) }); + const guilds = showAllGuilds ? await Guild.find({take: Math.abs(Number(limit || 20))}) : await Guild.find({ where: `"features" LIKE '%COMMUNITY%'`, take: Math.abs(Number(limit || 20)) }); res.send({ guilds: guilds }); }); -- cgit 1.5.1 From 5a45606411849fb8cbb39c3065f4ab5480ae2ef6 Mon Sep 17 00:00:00 2001 From: Flam3rboy <34555296+Flam3rboy@users.noreply.github.com> Date: Sun, 3 Oct 2021 01:55:57 +0200 Subject: :sparkles: add ``right`` option to route() --- api/src/middlewares/Authentication.ts | 4 +++- api/src/util/route.ts | 21 ++++++++++++++++++++- util/src/util/BitField.ts | 1 - util/src/util/Constants.ts | 4 +++- util/src/util/Token.ts | 5 ++++- util/src/util/index.ts | 1 + 6 files changed, 31 insertions(+), 5 deletions(-) (limited to 'api/src') diff --git a/api/src/middlewares/Authentication.ts b/api/src/middlewares/Authentication.ts index a300c786..571097bf 100644 --- a/api/src/middlewares/Authentication.ts +++ b/api/src/middlewares/Authentication.ts @@ -1,6 +1,6 @@ import { NextFunction, Request, Response } from "express"; import { HTTPError } from "lambert-server"; -import { checkToken, Config } from "@fosscord/util"; +import { checkToken, Config, Rights } from "@fosscord/util"; export const NO_AUTHORIZATION_ROUTES = [ "/auth/login", @@ -21,6 +21,7 @@ declare global { user_id: string; user_bot: boolean; token: string; + rights: Rights; } } } @@ -46,6 +47,7 @@ export async function Authentication(req: Request, res: Response, next: NextFunc req.token = decoded; req.user_id = decoded.id; req.user_bot = user.bot; + req.rights = new Rights(user.rights); return next(); } catch (error: any) { return next(new HTTPError(error?.toString(), 400)); diff --git a/api/src/util/route.ts b/api/src/util/route.ts index 45882d8a..3e967e2a 100644 --- a/api/src/util/route.ts +++ b/api/src/util/route.ts @@ -1,4 +1,15 @@ -import { DiscordApiErrors, EVENT, Event, EventData, getPermission, PermissionResolvable, Permissions } from "@fosscord/util"; +import { + DiscordApiErrors, + EVENT, + Event, + EventData, + FosscordApiErrors, + getPermission, + PermissionResolvable, + Permissions, + RightResolvable, + Rights +} from "@fosscord/util"; import { NextFunction, Request, Response } from "express"; import fs from "fs"; import path from "path"; @@ -33,6 +44,7 @@ export type RouteResponse = { status?: number; body?: `${string}Response`; heade export interface RouteOptions { permission?: PermissionResolvable; + right?: RightResolvable; body?: `${string}Schema`; // typescript interface name test?: { response?: RouteResponse; @@ -89,6 +101,13 @@ export function route(opts: RouteOptions) { } } + if (opts.right) { + const required = new Rights(opts.right); + if (!req.rights || !req.rights.has(required)) { + throw FosscordApiErrors.MISSING_RIGHTS.withParams(opts.right as string); + } + } + if (validate) { const valid = validate(normalizeBody(req.body)); if (!valid) { diff --git a/util/src/util/BitField.ts b/util/src/util/BitField.ts index 986077ba..fb887e05 100644 --- a/util/src/util/BitField.ts +++ b/util/src/util/BitField.ts @@ -143,6 +143,5 @@ export class BitField { } export function BitFlag(x: bigint | number) { - if (!x) throw new Error("You need to pass a bitflag"); return BigInt(1) << BigInt(x); } diff --git a/util/src/util/Constants.ts b/util/src/util/Constants.ts index d2cc5130..5fdf5bc0 100644 --- a/util/src/util/Constants.ts +++ b/util/src/util/Constants.ts @@ -726,7 +726,9 @@ export const DiscordApiErrors = { /** * An error encountered while performing an API request (Fosscord only). Here are the potential errors: */ -export const FosscordApiErrors = {}; +export const FosscordApiErrors = { + MISSING_RIGHTS: new ApiError("You lack rights to perform that action ({})", 50013, undefined, [""]), +}; /** * The value set for a guild's default message notifications, e.g. `ALL`. Here are the available types: diff --git a/util/src/util/Token.ts b/util/src/util/Token.ts index 111d59a2..7c4cc61d 100644 --- a/util/src/util/Token.ts +++ b/util/src/util/Token.ts @@ -10,7 +10,10 @@ export function checkToken(token: string, jwtSecret: string): Promise { jwt.verify(token, jwtSecret, JWTOptions, async (err, decoded: any) => { if (err || !decoded) return rej("Invalid Token"); - const user = await User.findOne({ id: decoded.id }, { select: ["data", "bot", "disabled", "deleted"] }); + const user = await User.findOne( + { id: decoded.id }, + { select: ["data", "bot", "disabled", "deleted", "rights"] } + ); if (!user) return rej("Invalid Token"); // we need to round it to seconds as it saved as seconds in jwt iat and valid_tokens_since is stored in milliseconds if (decoded.iat * 1000 < new Date(user.data.valid_tokens_since).setSeconds(0, 0)) diff --git a/util/src/util/index.ts b/util/src/util/index.ts index d73bf4ca..9c51d3b8 100644 --- a/util/src/util/index.ts +++ b/util/src/util/index.ts @@ -12,6 +12,7 @@ export * from "./MessageFlags"; export * from "./Permissions"; export * from "./RabbitMQ"; export * from "./Regex"; +export * from "./Rights"; export * from "./Snowflake"; export * from "./String"; export * from "./Array"; -- cgit 1.5.1 From 45b9800b5d0c8b0a2a75309502ea52ab6b0e83dc Mon Sep 17 00:00:00 2001 From: Flam3rboy <34555296+Flam3rboy@users.noreply.github.com> Date: Sun, 3 Oct 2021 01:59:38 +0200 Subject: :bug: fix registration --- api/src/routes/auth/register.ts | 1 + 1 file changed, 1 insertion(+) (limited to 'api/src') diff --git a/api/src/routes/auth/register.ts b/api/src/routes/auth/register.ts index 75fa68c3..1344c994 100644 --- a/api/src/routes/auth/register.ts +++ b/api/src/routes/auth/register.ts @@ -211,6 +211,7 @@ router.post("/", route({ body: "RegisterSchema" }), async (req: Request, res: Re disabled: false, deleted: false, email: email, + rights: "0", nsfw_allowed: true, // TODO: depending on age public_flags: "0", flags: "0", // TODO: generate -- cgit 1.5.1 From c745c765e0733751d62bd65c896860a83f26ccf3 Mon Sep 17 00:00:00 2001 From: afeuerstein <32029275+afeuerstein@users.noreply.github.com> Date: Sun, 3 Oct 2021 20:06:03 +0200 Subject: fix request failiure with error code 400 --- api/src/middlewares/Authentication.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'api/src') diff --git a/api/src/middlewares/Authentication.ts b/api/src/middlewares/Authentication.ts index 571097bf..5a082751 100644 --- a/api/src/middlewares/Authentication.ts +++ b/api/src/middlewares/Authentication.ts @@ -47,7 +47,7 @@ export async function Authentication(req: Request, res: Response, next: NextFunc req.token = decoded; req.user_id = decoded.id; req.user_bot = user.bot; - req.rights = new Rights(user.rights); + req.rights = new Rights(Number(user.rights)); return next(); } catch (error: any) { return next(new HTTPError(error?.toString(), 400)); -- cgit 1.5.1 From 48c1a155680d5471190ea116e29e9816e86ad8a9 Mon Sep 17 00:00:00 2001 From: Flam3rboy <34555296+Flam3rboy@users.noreply.github.com> Date: Sun, 3 Oct 2021 22:53:01 +0200 Subject: :bug: fix message reactions --- .../routes/channels/#channel_id/messages/#message_id/reactions.ts | 4 ++-- util/src/entities/Message.ts | 6 ++---- 2 files changed, 4 insertions(+), 6 deletions(-) (limited to 'api/src') diff --git a/api/src/routes/channels/#channel_id/messages/#message_id/reactions.ts b/api/src/routes/channels/#channel_id/messages/#message_id/reactions.ts index f2b83d40..6b6a66b2 100644 --- a/api/src/routes/channels/#channel_id/messages/#message_id/reactions.ts +++ b/api/src/routes/channels/#channel_id/messages/#message_id/reactions.ts @@ -124,7 +124,7 @@ router.put("/:emoji/:user_id", route({ permission: "READ_MESSAGE_HISTORY" }), as already_added.count++; } else message.reactions.push({ count: 1, emoji, user_ids: [req.user_id] }); - await Message.update({ id: message_id, channel_id }, message); + await message.save(); const member = channel.guild_id && (await Member.findOneOrFail({ id: req.user_id })); @@ -165,7 +165,7 @@ router.delete("/:emoji/:user_id", route({}), async (req: Request, res: Response) if (already_added.count <= 0) message.reactions.remove(already_added); - await Message.update({ id: message_id, channel_id }, message); + await message.save(); await emitEvent({ event: "MESSAGE_REACTION_REMOVE", diff --git a/util/src/entities/Message.ts b/util/src/entities/Message.ts index c4901693..04c3c7aa 100644 --- a/util/src/entities/Message.ts +++ b/util/src/entities/Message.ts @@ -74,9 +74,7 @@ export class Message extends BaseClass { author_id: string; @JoinColumn({ name: "author_id", referencedColumnName: "id" }) - @ManyToOne(() => User, { - onDelete: "CASCADE", - }) + @ManyToOne(() => User) author?: User; @Column({ nullable: true }) @@ -120,7 +118,7 @@ export class Message extends BaseClass { mention_everyone?: boolean; @JoinTable({ name: "message_user_mentions" }) - @ManyToMany(() => User, { orphanedRowAction: "delete", onDelete: "CASCADE", cascade: true }) + @ManyToMany(() => User) mentions: User[]; @JoinTable({ name: "message_role_mentions" }) -- cgit 1.5.1 From 5116dcf2e801571fb747a1d4288e0d8ee3873d39 Mon Sep 17 00:00:00 2001 From: The Arcane Brony Date: Sun, 3 Oct 2021 23:17:34 +0200 Subject: Add subscription plans so the client doesn't crash --- .../skus/#id/subscription-plans.ts | 45 +++++++++++++++------- 1 file changed, 31 insertions(+), 14 deletions(-) (limited to 'api/src') diff --git a/api/src/routes/store/published-listings/skus/#id/subscription-plans.ts b/api/src/routes/store/published-listings/skus/#id/subscription-plans.ts index 77f949d9..49bb0aa3 100644 --- a/api/src/routes/store/published-listings/skus/#id/subscription-plans.ts +++ b/api/src/routes/store/published-listings/skus/#id/subscription-plans.ts @@ -3,22 +3,39 @@ import { route } from "@fosscord/api"; const router: Router = Router(); +const skus = new Map([ + ["521842865731534868", [{"id": "511651856145973248", "name": "Premium Monthly (Legacy)", "interval": 1, "interval_count": 1, "tax_inclusive": true, "sku_id": "521842865731534868", "currency": "usd", "price": 0, "price_tier": null}, {"id": "511651860671627264", "name": "Premium Yearly (Legacy)", "interval": 2, "interval_count": 1, "tax_inclusive": true, "sku_id": "521842865731534868", "currency": "usd", "price": 0, "price_tier": null}]], + ["521846918637420545", [{"id": "511651871736201216", "name": "Premium Classic Monthly", "interval": 1, "interval_count": 1, "tax_inclusive": true, "sku_id": "521846918637420545", "currency": "usd", "price": 0, "price_tier": null}, {"id": "511651876987469824", "name": "Premium Classic Yearly", "interval": 2, "interval_count": 1, "tax_inclusive": true, "sku_id": "521846918637420545", "currency": "usd", "price": 0, "price_tier": null}]], + ["521847234246082599", [{"id": "642251038925127690", "name": "Premium Quarterly", "interval": 1, "interval_count": 3, "tax_inclusive": true, "sku_id": "521847234246082599", "currency": "usd", "price": 0, "price_tier": null}, {"id": "511651880837840896", "name": "Premium Monthly", "interval": 1, "interval_count": 1, "tax_inclusive": true, "sku_id": "521847234246082599", "currency": "usd", "price": 0, "price_tier": null}, {"id": "511651885459963904", "name": "Premium Yearly", "interval": 2, "interval_count": 1, "tax_inclusive": true, "sku_id": "521847234246082599", "currency": "usd", "price": 0, "price_tier": null}]], + ["590663762298667008", [{"id": "590665532894740483", "name": "Server Boost Monthly", "interval": 1, "interval_count": 1, "tax_inclusive": true, "sku_id": "590663762298667008", "discount_price": 0, "currency": "usd", "price": 0, "price_tier": null}, {"id": "590665538238152709", "name": "Server Boost Yearly", "interval": 2, "interval_count": 1, "tax_inclusive": true, "sku_id": "590663762298667008", "discount_price": 0, "currency": "usd", "price": 0, "price_tier": null}]], +]); + router.get("/", route({}), async (req: Request, res: Response) => { //TODO - res.json([ - { - id: "", - name: "", - interval: 1, - interval_count: 1, - tax_inclusive: true, - sku_id: "", - fallback_price: 499, - fallback_currency: "eur", - currency: "eur", - price: 4199, - price_tier: null - }]).status(200); + const { id } = req.params; + + if(!skus.has(id.toString())) { + console.log(`Request for invalid SKU ${id}! Please report this!`); + res.sendStatus(404); + } + else { + + res.json(skus.get(id.toString())).status(200); + } + // res.json([ + // { + // id: "", + // name: "", + // interval: 1, + // interval_count: 1, + // tax_inclusive: true, + // sku_id: "", + // fallback_price: 499, + // fallback_currency: "eur", + // currency: "eur", + // price: 4199, + // price_tier: null + // }]).status(200); }); export default router; -- cgit 1.5.1 From 844911b9eef2379583321fe0c1bebaec61a7a19f Mon Sep 17 00:00:00 2001 From: Flam3rboy <34555296+Flam3rboy@users.noreply.github.com> Date: Sun, 3 Oct 2021 23:32:10 +0200 Subject: :truck: rename id -> sku_id --- .../skus/#id/subscription-plans.ts | 41 ---------------------- .../skus/#sku_id/subscription-plans.ts | 25 +++++++++++++ 2 files changed, 25 insertions(+), 41 deletions(-) delete mode 100644 api/src/routes/store/published-listings/skus/#id/subscription-plans.ts create mode 100644 api/src/routes/store/published-listings/skus/#sku_id/subscription-plans.ts (limited to 'api/src') diff --git a/api/src/routes/store/published-listings/skus/#id/subscription-plans.ts b/api/src/routes/store/published-listings/skus/#id/subscription-plans.ts deleted file mode 100644 index 49bb0aa3..00000000 --- a/api/src/routes/store/published-listings/skus/#id/subscription-plans.ts +++ /dev/null @@ -1,41 +0,0 @@ -import { Request, Response, Router } from "express"; -import { route } from "@fosscord/api"; - -const router: Router = Router(); - -const skus = new Map([ - ["521842865731534868", [{"id": "511651856145973248", "name": "Premium Monthly (Legacy)", "interval": 1, "interval_count": 1, "tax_inclusive": true, "sku_id": "521842865731534868", "currency": "usd", "price": 0, "price_tier": null}, {"id": "511651860671627264", "name": "Premium Yearly (Legacy)", "interval": 2, "interval_count": 1, "tax_inclusive": true, "sku_id": "521842865731534868", "currency": "usd", "price": 0, "price_tier": null}]], - ["521846918637420545", [{"id": "511651871736201216", "name": "Premium Classic Monthly", "interval": 1, "interval_count": 1, "tax_inclusive": true, "sku_id": "521846918637420545", "currency": "usd", "price": 0, "price_tier": null}, {"id": "511651876987469824", "name": "Premium Classic Yearly", "interval": 2, "interval_count": 1, "tax_inclusive": true, "sku_id": "521846918637420545", "currency": "usd", "price": 0, "price_tier": null}]], - ["521847234246082599", [{"id": "642251038925127690", "name": "Premium Quarterly", "interval": 1, "interval_count": 3, "tax_inclusive": true, "sku_id": "521847234246082599", "currency": "usd", "price": 0, "price_tier": null}, {"id": "511651880837840896", "name": "Premium Monthly", "interval": 1, "interval_count": 1, "tax_inclusive": true, "sku_id": "521847234246082599", "currency": "usd", "price": 0, "price_tier": null}, {"id": "511651885459963904", "name": "Premium Yearly", "interval": 2, "interval_count": 1, "tax_inclusive": true, "sku_id": "521847234246082599", "currency": "usd", "price": 0, "price_tier": null}]], - ["590663762298667008", [{"id": "590665532894740483", "name": "Server Boost Monthly", "interval": 1, "interval_count": 1, "tax_inclusive": true, "sku_id": "590663762298667008", "discount_price": 0, "currency": "usd", "price": 0, "price_tier": null}, {"id": "590665538238152709", "name": "Server Boost Yearly", "interval": 2, "interval_count": 1, "tax_inclusive": true, "sku_id": "590663762298667008", "discount_price": 0, "currency": "usd", "price": 0, "price_tier": null}]], -]); - -router.get("/", route({}), async (req: Request, res: Response) => { - //TODO - const { id } = req.params; - - if(!skus.has(id.toString())) { - console.log(`Request for invalid SKU ${id}! Please report this!`); - res.sendStatus(404); - } - else { - - res.json(skus.get(id.toString())).status(200); - } - // res.json([ - // { - // id: "", - // name: "", - // interval: 1, - // interval_count: 1, - // tax_inclusive: true, - // sku_id: "", - // fallback_price: 499, - // fallback_currency: "eur", - // currency: "eur", - // price: 4199, - // price_tier: null - // }]).status(200); -}); - -export default router; diff --git a/api/src/routes/store/published-listings/skus/#sku_id/subscription-plans.ts b/api/src/routes/store/published-listings/skus/#sku_id/subscription-plans.ts new file mode 100644 index 00000000..54c01607 --- /dev/null +++ b/api/src/routes/store/published-listings/skus/#sku_id/subscription-plans.ts @@ -0,0 +1,25 @@ +import { Request, Response, Router } from "express"; +import { route } from "@fosscord/api"; + +const router: Router = Router(); + +const skus = new Map([ + ["521842865731534868", [{"id": "511651856145973248", "name": "Premium Monthly (Legacy)", "interval": 1, "interval_count": 1, "tax_inclusive": true, "sku_id": "521842865731534868", "currency": "usd", "price": 0, "price_tier": null}, {"id": "511651860671627264", "name": "Premium Yearly (Legacy)", "interval": 2, "interval_count": 1, "tax_inclusive": true, "sku_id": "521842865731534868", "currency": "usd", "price": 0, "price_tier": null}]], + ["521846918637420545", [{"id": "511651871736201216", "name": "Premium Classic Monthly", "interval": 1, "interval_count": 1, "tax_inclusive": true, "sku_id": "521846918637420545", "currency": "usd", "price": 0, "price_tier": null}, {"id": "511651876987469824", "name": "Premium Classic Yearly", "interval": 2, "interval_count": 1, "tax_inclusive": true, "sku_id": "521846918637420545", "currency": "usd", "price": 0, "price_tier": null}]], + ["521847234246082599", [{"id": "642251038925127690", "name": "Premium Quarterly", "interval": 1, "interval_count": 3, "tax_inclusive": true, "sku_id": "521847234246082599", "currency": "usd", "price": 0, "price_tier": null}, {"id": "511651880837840896", "name": "Premium Monthly", "interval": 1, "interval_count": 1, "tax_inclusive": true, "sku_id": "521847234246082599", "currency": "usd", "price": 0, "price_tier": null}, {"id": "511651885459963904", "name": "Premium Yearly", "interval": 2, "interval_count": 1, "tax_inclusive": true, "sku_id": "521847234246082599", "currency": "usd", "price": 0, "price_tier": null}]], + ["590663762298667008", [{"id": "590665532894740483", "name": "Server Boost Monthly", "interval": 1, "interval_count": 1, "tax_inclusive": true, "sku_id": "590663762298667008", "discount_price": 0, "currency": "usd", "price": 0, "price_tier": null}, {"id": "590665538238152709", "name": "Server Boost Yearly", "interval": 2, "interval_count": 1, "tax_inclusive": true, "sku_id": "590663762298667008", "discount_price": 0, "currency": "usd", "price": 0, "price_tier": null}]], +]); + +router.get("/", route({}), async (req: Request, res: Response) => { + // TODO: add the ability to add custom + const { sku_id } = req.params; + + if(!skus.has(sku_id)) { + console.log(`Request for invalid SKU ${sku_id}! Please report this!`); + res.sendStatus(404); + } else { + res.json(skus.get(sku_id)).status(200); + } +}); + +export default router; -- cgit 1.5.1