Add api docs
This commit is contained in:
3 files changed
+111
-17
No files matched your search
+83
-17
@@ -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('*', () =>
|
||||
jsonResponse(
|
||||
{
|
||||
success: false,
|
||||
message: 'Endpoint not found (are you using the correct request method?)'
|
||||
},
|
||||
404
|
||||
)
|
||||
app.all(
|
||||
'*',
|
||||
() =>
|
||||
jsonResponse(
|
||||
{
|
||||
success: false,
|
||||
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