Add api docs
This commit is contained in:
3 files changed
+106
-12
No files matched your search
@@ -5,6 +5,7 @@
|
||||
"": {
|
||||
"name": "gd-api",
|
||||
"dependencies": {
|
||||
"@elysiajs/swagger": "^1.3.1",
|
||||
"axios": "^1.13.5",
|
||||
"dotenv": "^17.3.1",
|
||||
"elysia": "1.4.25",
|
||||
@@ -17,6 +18,14 @@
|
||||
"packages": {
|
||||
"@borewit/text-codec": ["@borewit/text-codec@0.2.1", "", {}, "sha512-k7vvKPbf7J2fZ5klGRD9AeKfUvojuZIQ3BT5u7Jfv+puwXkUBUT5PVyMDfJZpy30CBDXGMgw7fguK/lpOMBvgw=="],
|
||||
|
||||
"@elysiajs/swagger": ["@elysiajs/swagger@1.3.1", "", { "dependencies": { "@scalar/themes": "^0.9.52", "@scalar/types": "^0.0.12", "openapi-types": "^12.1.3", "pathe": "^1.1.2" }, "peerDependencies": { "elysia": ">= 1.3.0" } }, "sha512-LcbLHa0zE6FJKWPWKsIC/f+62wbDv3aXydqcNPVPyqNcaUgwvCajIi+5kHEU6GO3oXUCpzKaMsb3gsjt8sLzFQ=="],
|
||||
|
||||
"@scalar/openapi-types": ["@scalar/openapi-types@0.1.1", "", {}, "sha512-NMy3QNk6ytcCoPUGJH0t4NNr36OWXgZhA3ormr3TvhX1NDgoF95wFyodGVH8xiHeUyn2/FxtETm8UBLbB5xEmg=="],
|
||||
|
||||
"@scalar/themes": ["@scalar/themes@0.9.86", "", { "dependencies": { "@scalar/types": "0.1.7" } }, "sha512-QUHo9g5oSWi+0Lm1vJY9TaMZRau8LHg+vte7q5BVTBnu6NuQfigCaN+ouQ73FqIVd96TwMO6Db+dilK1B+9row=="],
|
||||
|
||||
"@scalar/types": ["@scalar/types@0.0.12", "", { "dependencies": { "@scalar/openapi-types": "0.1.1", "@unhead/schema": "^1.9.5" } }, "sha512-XYZ36lSEx87i4gDqopQlGCOkdIITHHEvgkuJFrXFATQs9zHARop0PN0g4RZYWj+ZpCUclOcaOjbCt8JGe22mnQ=="],
|
||||
|
||||
"@sinclair/typebox": ["@sinclair/typebox@0.34.48", "", {}, "sha512-kKJTNuK3AQOrgjjotVxMrCn1sUJwM76wMszfq1kdU4uYVJjvEWuFQ6HgvLt4Xz3fSmZlTOxJ/Ie13KnIcWQXFA=="],
|
||||
|
||||
"@tokenizer/inflate": ["@tokenizer/inflate@0.4.1", "", { "dependencies": { "debug": "^4.4.3", "token-types": "^6.1.1" } }, "sha512-2mAv+8pkG6GIZiF1kNg1jAjh27IDxEPKwdGul3snfztFerfPGI1LjDezZp3i7BElXompqEtPmoPx6c2wgtWsOA=="],
|
||||
@@ -25,6 +34,8 @@
|
||||
|
||||
"@types/node": ["@types/node@25.3.0", "", { "dependencies": { "undici-types": "~7.18.0" } }, "sha512-4K3bqJpXpqfg2XKGK9bpDTc6xO/xoUP/RBWS7AtRMug6zZFaRekiLzjVtAoZMquxoAbzBvy5nxQ7veS5eYzf8A=="],
|
||||
|
||||
"@unhead/schema": ["@unhead/schema@1.11.20", "", { "dependencies": { "hookable": "^5.5.3", "zhead": "^2.2.4" } }, "sha512-0zWykKAaJdm+/Y7yi/Yds20PrUK7XabLe9c3IRcjnwYmSWY6z0Cr19VIs3ozCj8P+GhR+/TI2mwtGlueCEYouA=="],
|
||||
|
||||
"asynckit": ["asynckit@0.4.0", "", {}, "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q=="],
|
||||
|
||||
"axios": ["axios@1.13.5", "", { "dependencies": { "follow-redirects": "^1.15.11", "form-data": "^4.0.5", "proxy-from-env": "^1.1.0" } }, "sha512-cz4ur7Vb0xS4/KUN0tPWe44eqxrIu31me+fbang3ijiNscE129POzipJJA6zniq2C/Z6sJCjMimjS8Lc/GAs8Q=="],
|
||||
@@ -79,6 +90,8 @@
|
||||
|
||||
"hasown": ["hasown@2.0.2", "", { "dependencies": { "function-bind": "^1.1.2" } }, "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ=="],
|
||||
|
||||
"hookable": ["hookable@5.5.3", "", {}, "sha512-Yc+BQe8SvoXH1643Qez1zqLRmbA5rCL+sSmk6TVos0LWVfNIB7PGncdlId77WzLGSIB5KaWgTaNTs2lNVEI6VQ=="],
|
||||
|
||||
"ieee754": ["ieee754@1.2.1", "", {}, "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA=="],
|
||||
|
||||
"math-intrinsics": ["math-intrinsics@1.1.0", "", {}, "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g=="],
|
||||
@@ -91,16 +104,30 @@
|
||||
|
||||
"ms": ["ms@2.1.3", "", {}, "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA=="],
|
||||
|
||||
"nanoid": ["nanoid@5.1.6", "", { "bin": { "nanoid": "bin/nanoid.js" } }, "sha512-c7+7RQ+dMB5dPwwCp4ee1/iV/q2P6aK1mTZcfr1BTuVlyW9hJYiMPybJCcnBlQtuSmTIWNeazm/zqNoZSSElBg=="],
|
||||
|
||||
"openapi-types": ["openapi-types@12.1.3", "", {}, "sha512-N4YtSYJqghVu4iek2ZUvcN/0aqH1kRDuNqzcycDxhOUpg7GdvLa2F3DgS6yBNhInhv2r/6I0Flkn7CqL8+nIcw=="],
|
||||
|
||||
"pathe": ["pathe@1.1.2", "", {}, "sha512-whLdWMYL2TwI08hn8/ZqAbrVemu0LNaNNJZX73O6qaIdCTfXutsLhMkjdENX0qhsQ9uIimo4/aQOmXkoon2nDQ=="],
|
||||
|
||||
"proxy-from-env": ["proxy-from-env@1.1.0", "", {}, "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg=="],
|
||||
|
||||
"strtok3": ["strtok3@10.3.4", "", { "dependencies": { "@tokenizer/token": "^0.3.0" } }, "sha512-KIy5nylvC5le1OdaaoCJ07L+8iQzJHGH6pWDuzS+d07Cu7n1MZ2x26P8ZKIWfbK02+XIL8Mp4RkWeqdUCrDMfg=="],
|
||||
|
||||
"token-types": ["token-types@6.1.2", "", { "dependencies": { "@borewit/text-codec": "^0.2.1", "@tokenizer/token": "^0.3.0", "ieee754": "^1.2.1" } }, "sha512-dRXchy+C0IgK8WPC6xvCHFRIWYUbqqdEIKPaKo/AcTUNzwLTK6AH7RjdLWsEZcAN/TBdtfUw3PYEgPr5VPr6ww=="],
|
||||
|
||||
"type-fest": ["type-fest@4.41.0", "", {}, "sha512-TeTSQ6H5YHvpqVwBRcnLDCBnDOHWYu7IvGbHT6N8AOymcr9PJGjc1GTtiWZTYg0NCgYwvnYWEkVChQAr9bjfwA=="],
|
||||
|
||||
"uint8array-extras": ["uint8array-extras@1.5.0", "", {}, "sha512-rvKSBiC5zqCCiDZ9kAOszZcDvdAHwwIKJG33Ykj43OKcWsnmcBRL09YTU4nOeHZ8Y2a7l1MgTd08SBe9A8Qj6A=="],
|
||||
|
||||
"undici-types": ["undici-types@7.18.2", "", {}, "sha512-AsuCzffGHJybSaRrmr5eHr81mwJU3kjw6M+uprWvCXiNeN9SOGwQ3Jn8jb8m3Z6izVgknn1R0FTCEAP2QrLY/w=="],
|
||||
|
||||
"zhead": ["zhead@2.2.4", "", {}, "sha512-8F0OI5dpWIA5IGG5NHUg9staDwz/ZPxZtvGVf01j7vHqSyZ0raHY+78atOVxRqb73AotX22uV1pXt3gYSstGag=="],
|
||||
|
||||
"zod": ["zod@3.25.76", "", {}, "sha512-gzUt/qt81nXsFGKIFcC3YnfEAx5NkunCfnDlvuBSSFS02bcXu4Lmea0AFIUwbLWxWPx3d9p8S5QoaujKcNQxcQ=="],
|
||||
|
||||
"@scalar/themes/@scalar/types": ["@scalar/types@0.1.7", "", { "dependencies": { "@scalar/openapi-types": "0.2.0", "@unhead/schema": "^1.11.11", "nanoid": "^5.1.5", "type-fest": "^4.20.0", "zod": "^3.23.8" } }, "sha512-irIDYzTQG2KLvFbuTI8k2Pz/R4JR+zUUSykVTbEMatkzMmVFnn1VzNSMlODbadycwZunbnL2tA27AXed9URVjw=="],
|
||||
|
||||
"@scalar/themes/@scalar/types/@scalar/openapi-types": ["@scalar/openapi-types@0.2.0", "", { "dependencies": { "zod": "^3.23.8" } }, "sha512-waiKk12cRCqyUCWTOX0K1WEVX46+hVUK+zRPzAahDJ7G0TApvbNkuy5wx7aoUyEk++HHde0XuQnshXnt8jsddA=="],
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,7 @@
|
||||
"build": "rm -rf dist; bun build src/index.ts --target=bun --outdir=dist"
|
||||
},
|
||||
"dependencies": {
|
||||
"@elysiajs/swagger": "^1.3.1",
|
||||
"axios": "^1.13.5",
|
||||
"dotenv": "^17.3.1",
|
||||
"elysia": "1.4.25"
|
||||
|
||||
+78
-12
@@ -1,6 +1,7 @@
|
||||
import { Elysia, t } from 'elysia'
|
||||
import { jsonResponse } from './lib/util'
|
||||
import dotenv from 'dotenv'
|
||||
import swagger from '@elysiajs/swagger'
|
||||
|
||||
import { handler as gauntletsGetHandler } from './routes/gauntlets/get'
|
||||
|
||||
@@ -11,18 +12,53 @@ import { handler as mapPacksGetHandler } from './routes/map-packs/get'
|
||||
|
||||
dotenv.config()
|
||||
|
||||
const app = new Elysia()
|
||||
const app = new Elysia().use(
|
||||
swagger({
|
||||
path: '/docs',
|
||||
documentation: {
|
||||
info: {
|
||||
title: 'Lncvrt Games API',
|
||||
description:
|
||||
'This is the official documentation for the Lncvrt Games API!',
|
||||
version: '1.0.0'
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
app.listen(3692)
|
||||
|
||||
app.get('/gauntlets', gauntletsGetHandler)
|
||||
app.get('/map-packs', mapPacksGetHandler)
|
||||
app.get('/leaderboards/top', () => leaderboardsGetHandler('top'))
|
||||
app.get('/leaderboards/creators', () => leaderboardsGetHandler('creators'))
|
||||
app.get('/gauntlets', gauntletsGetHandler, {
|
||||
detail: {
|
||||
description: 'The endpoint for getting all gauntlets',
|
||||
tags: ['Levels']
|
||||
}
|
||||
})
|
||||
app.get('/map-packs', mapPacksGetHandler, {
|
||||
detail: {
|
||||
description: 'The endpoint for getting all map packs',
|
||||
tags: ['Levels']
|
||||
}
|
||||
})
|
||||
app.get('/leaderboards/top', () => leaderboardsGetHandler('top'), {
|
||||
detail: {
|
||||
description: 'The endpoint for getting the top players leaderboard',
|
||||
tags: ['Leaderboards']
|
||||
}
|
||||
})
|
||||
app.get('/leaderboards/creators', () => leaderboardsGetHandler('creators'), {
|
||||
detail: {
|
||||
description: 'The endpoint for getting the top creators leaderboard',
|
||||
tags: ['Leaderboards']
|
||||
}
|
||||
})
|
||||
app.get(
|
||||
'/leaderboards/level/classic/top',
|
||||
handler => leaderboardsLevelGetHandler(handler, '1', true),
|
||||
{
|
||||
detail: {
|
||||
description:
|
||||
'The endpoint for getting the classic level top players leaderboard',
|
||||
tags: ['Leaderboards', 'Levels']
|
||||
},
|
||||
query: t.Object({
|
||||
id: t.String()
|
||||
})
|
||||
@@ -32,6 +68,11 @@ app.get(
|
||||
'/leaderboards/level/platformer/top',
|
||||
handler => leaderboardsLevelGetHandler(handler, '2', false),
|
||||
{
|
||||
detail: {
|
||||
description:
|
||||
'The endpoint for getting the platformer level top players leaderboard',
|
||||
tags: ['Leaderboards', 'Levels']
|
||||
},
|
||||
query: t.Object({
|
||||
id: t.String()
|
||||
})
|
||||
@@ -41,6 +82,11 @@ app.get(
|
||||
'/leaderboards/level/classic/week',
|
||||
handler => leaderboardsLevelGetHandler(handler, '2', true),
|
||||
{
|
||||
detail: {
|
||||
description:
|
||||
'The endpoint for getting the classic level week players leaderboard',
|
||||
tags: ['Leaderboards', 'Levels']
|
||||
},
|
||||
query: t.Object({
|
||||
id: t.String()
|
||||
})
|
||||
@@ -50,6 +96,11 @@ app.get(
|
||||
'/leaderboards/level/platformer/week',
|
||||
handler => leaderboardsLevelGetHandler(handler, '1', false),
|
||||
{
|
||||
detail: {
|
||||
description:
|
||||
'The endpoint for getting the classic level week players leaderboard',
|
||||
tags: ['Leaderboards', 'Levels']
|
||||
},
|
||||
query: t.Object({
|
||||
id: t.String()
|
||||
})
|
||||
@@ -60,19 +111,34 @@ app.get(
|
||||
() =>
|
||||
new Response(null, {
|
||||
status: 301,
|
||||
headers: { Location: 'https://git.lncvrt.xyz/Geometry-Dash-RE/gd-api' }
|
||||
})
|
||||
headers: { Location: '/docs' }
|
||||
}),
|
||||
{
|
||||
detail: {
|
||||
hide: true
|
||||
}
|
||||
}
|
||||
)
|
||||
app.all('*', () =>
|
||||
app.all(
|
||||
'*',
|
||||
() =>
|
||||
jsonResponse(
|
||||
{
|
||||
success: false,
|
||||
message: 'Endpoint not found (are you using the correct request method?)'
|
||||
message:
|
||||
'Endpoint not found (are you using the correct request method?)'
|
||||
},
|
||||
404
|
||||
)
|
||||
),
|
||||
{
|
||||
detail: {
|
||||
hide: true
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
app.listen(3692)
|
||||
|
||||
console.log(
|
||||
`Geometry Dash API Server started on http://${app.server?.hostname}:${app.server?.port}/`
|
||||
)
|
||||
Reference in new issue
Block a user