mirror of
https://iceshrimp.dev/crimekillz/trashposs
synced 2024-11-23 17:29:05 +01:00
[backend/web-api] Add OpenAPI descriptions and fix controller naming
This commit is contained in:
parent
d1aa541a53
commit
ddfe8bb48e
16
.pnp.cjs
generated
16
.pnp.cjs
generated
@ -1898,10 +1898,10 @@ const RAW_RUNTIME_STATE =
|
|||||||
}]\
|
}]\
|
||||||
]],\
|
]],\
|
||||||
["@iceshrimp/koa-openapi", [\
|
["@iceshrimp/koa-openapi", [\
|
||||||
["npm:2.2.0::__archiveUrl=https%3A%2F%2Ficeshrimp.dev%2Fapi%2Fpackages%2Ficeshrimp%2Fnpm%2F%2540iceshrimp%252Fkoa-openapi%2F-%2F2.2.0%2Fkoa-openapi-2.2.0.tgz", {\
|
["npm:2.4.1::__archiveUrl=https%3A%2F%2Ficeshrimp.dev%2Fapi%2Fpackages%2Ficeshrimp%2Fnpm%2F%2540iceshrimp%252Fkoa-openapi%2F-%2F2.4.1%2Fkoa-openapi-2.4.1.tgz", {\
|
||||||
"packageLocation": "./.yarn/cache/@iceshrimp-koa-openapi-npm-2.2.0-b79af14354-a7ff2c0b1a.zip/node_modules/@iceshrimp/koa-openapi/",\
|
"packageLocation": "./.yarn/cache/@iceshrimp-koa-openapi-npm-2.4.1-8c7362549b-5270b64aa4.zip/node_modules/@iceshrimp/koa-openapi/",\
|
||||||
"packageDependencies": [\
|
"packageDependencies": [\
|
||||||
["@iceshrimp/koa-openapi", "npm:2.2.0::__archiveUrl=https%3A%2F%2Ficeshrimp.dev%2Fapi%2Fpackages%2Ficeshrimp%2Fnpm%2F%2540iceshrimp%252Fkoa-openapi%2F-%2F2.2.0%2Fkoa-openapi-2.2.0.tgz"],\
|
["@iceshrimp/koa-openapi", "npm:2.4.1::__archiveUrl=https%3A%2F%2Ficeshrimp.dev%2Fapi%2Fpackages%2Ficeshrimp%2Fnpm%2F%2540iceshrimp%252Fkoa-openapi%2F-%2F2.4.1%2Fkoa-openapi-2.4.1.tgz"],\
|
||||||
["@hapi/boom", "npm:10.0.1"],\
|
["@hapi/boom", "npm:10.0.1"],\
|
||||||
["@koa/cors", "npm:4.0.0"],\
|
["@koa/cors", "npm:4.0.0"],\
|
||||||
["@koa/router", "npm:12.0.1"],\
|
["@koa/router", "npm:12.0.1"],\
|
||||||
@ -1911,7 +1911,7 @@ const RAW_RUNTIME_STATE =
|
|||||||
["koa", "npm:2.14.2"],\
|
["koa", "npm:2.14.2"],\
|
||||||
["koa-body", "npm:6.0.1"],\
|
["koa-body", "npm:6.0.1"],\
|
||||||
["koa-helmet", "npm:7.0.2"],\
|
["koa-helmet", "npm:7.0.2"],\
|
||||||
["koa2-swagger-ui", "virtual:b79af143542f14e992898e20a1ab22405dbd6893d6a8c813e877de0a455aadcaf1a4faf2f8bc74ede210c0399435357919d77dcd4e83ecce226e0faf31581e3e#npm:5.10.0"],\
|
["koa2-swagger-ui", "virtual:8c7362549be2320b14415acd0a28c20c4a28a61f50998f521c19c171b924639d2efda4597f82a25044828aebf1f59af528473f27cfbb1764bf584786860b172c#npm:5.10.0"],\
|
||||||
["lodash", "npm:4.17.21"],\
|
["lodash", "npm:4.17.21"],\
|
||||||
["openapi-types", "npm:12.1.3"],\
|
["openapi-types", "npm:12.1.3"],\
|
||||||
["reflect-metadata", "npm:0.1.13"]\
|
["reflect-metadata", "npm:0.1.13"]\
|
||||||
@ -7217,7 +7217,7 @@ const RAW_RUNTIME_STATE =
|
|||||||
["@bull-board/ui", "npm:5.6.0"],\
|
["@bull-board/ui", "npm:5.6.0"],\
|
||||||
["@discordapp/twemoji", "npm:14.1.2"],\
|
["@discordapp/twemoji", "npm:14.1.2"],\
|
||||||
["@hapi/boom", "npm:10.0.1"],\
|
["@hapi/boom", "npm:10.0.1"],\
|
||||||
["@iceshrimp/koa-openapi", "npm:2.2.0::__archiveUrl=https%3A%2F%2Ficeshrimp.dev%2Fapi%2Fpackages%2Ficeshrimp%2Fnpm%2F%2540iceshrimp%252Fkoa-openapi%2F-%2F2.2.0%2Fkoa-openapi-2.2.0.tgz"],\
|
["@iceshrimp/koa-openapi", "npm:2.4.1::__archiveUrl=https%3A%2F%2Ficeshrimp.dev%2Fapi%2Fpackages%2Ficeshrimp%2Fnpm%2F%2540iceshrimp%252Fkoa-openapi%2F-%2F2.4.1%2Fkoa-openapi-2.4.1.tgz"],\
|
||||||
["@koa/cors", "npm:3.4.3"],\
|
["@koa/cors", "npm:3.4.3"],\
|
||||||
["@koa/multer", "virtual:aa59773ac87791c4813d53447077fcf8a847d6de5a301d34dc31286584b1dbb26d30d3adb5b4c41c1e8aea04371e926fda05c09c6253647c432e11d872a304ba#npm:3.0.2"],\
|
["@koa/multer", "virtual:aa59773ac87791c4813d53447077fcf8a847d6de5a301d34dc31286584b1dbb26d30d3adb5b4c41c1e8aea04371e926fda05c09c6253647c432e11d872a304ba#npm:3.0.2"],\
|
||||||
["@koa/router", "npm:9.0.1"],\
|
["@koa/router", "npm:9.0.1"],\
|
||||||
@ -17145,10 +17145,10 @@ const RAW_RUNTIME_STATE =
|
|||||||
],\
|
],\
|
||||||
"linkType": "SOFT"\
|
"linkType": "SOFT"\
|
||||||
}],\
|
}],\
|
||||||
["virtual:b79af143542f14e992898e20a1ab22405dbd6893d6a8c813e877de0a455aadcaf1a4faf2f8bc74ede210c0399435357919d77dcd4e83ecce226e0faf31581e3e#npm:5.10.0", {\
|
["virtual:8c7362549be2320b14415acd0a28c20c4a28a61f50998f521c19c171b924639d2efda4597f82a25044828aebf1f59af528473f27cfbb1764bf584786860b172c#npm:5.10.0", {\
|
||||||
"packageLocation": "./.yarn/__virtual__/koa2-swagger-ui-virtual-7468e59b3e/0/cache/koa2-swagger-ui-npm-5.10.0-54bce94261-40575d377d.zip/node_modules/koa2-swagger-ui/",\
|
"packageLocation": "./.yarn/__virtual__/koa2-swagger-ui-virtual-d32ac78ca4/0/cache/koa2-swagger-ui-npm-5.10.0-54bce94261-40575d377d.zip/node_modules/koa2-swagger-ui/",\
|
||||||
"packageDependencies": [\
|
"packageDependencies": [\
|
||||||
["koa2-swagger-ui", "virtual:b79af143542f14e992898e20a1ab22405dbd6893d6a8c813e877de0a455aadcaf1a4faf2f8bc74ede210c0399435357919d77dcd4e83ecce226e0faf31581e3e#npm:5.10.0"],\
|
["koa2-swagger-ui", "virtual:8c7362549be2320b14415acd0a28c20c4a28a61f50998f521c19c171b924639d2efda4597f82a25044828aebf1f59af528473f27cfbb1764bf584786860b172c#npm:5.10.0"],\
|
||||||
["@types/koa", null],\
|
["@types/koa", null],\
|
||||||
["handlebars", "npm:4.7.8"],\
|
["handlebars", "npm:4.7.8"],\
|
||||||
["lodash", "npm:4.17.21"],\
|
["lodash", "npm:4.17.21"],\
|
||||||
|
BIN
.yarn/cache/@iceshrimp-koa-openapi-npm-2.2.0-b79af14354-a7ff2c0b1a.zip
(Stored with Git LFS)
vendored
BIN
.yarn/cache/@iceshrimp-koa-openapi-npm-2.2.0-b79af14354-a7ff2c0b1a.zip
(Stored with Git LFS)
vendored
Binary file not shown.
BIN
.yarn/cache/@iceshrimp-koa-openapi-npm-2.4.1-8c7362549b-5270b64aa4.zip
(Stored with Git LFS)
vendored
Normal file
BIN
.yarn/cache/@iceshrimp-koa-openapi-npm-2.4.1-8c7362549b-5270b64aa4.zip
(Stored with Git LFS)
vendored
Normal file
Binary file not shown.
@ -76,6 +76,12 @@
|
|||||||
"dependenciesMeta": {
|
"dependenciesMeta": {
|
||||||
"@discordapp/twemoji@14.1.2": {
|
"@discordapp/twemoji@14.1.2": {
|
||||||
"unplugged": true
|
"unplugged": true
|
||||||
|
},
|
||||||
|
"@iceshrimp/koa-openapi@2.3.0": {
|
||||||
|
"unplugged": true
|
||||||
|
},
|
||||||
|
"@iceshrimp/koa-openapi@2.4.0": {
|
||||||
|
"unplugged": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
"@bull-board/ui": "5.6.0",
|
"@bull-board/ui": "5.6.0",
|
||||||
"@discordapp/twemoji": "14.1.2",
|
"@discordapp/twemoji": "14.1.2",
|
||||||
"@hapi/boom": "^10.0.1",
|
"@hapi/boom": "^10.0.1",
|
||||||
"@iceshrimp/koa-openapi": "^2.2.0",
|
"@iceshrimp/koa-openapi": "^2.4.1",
|
||||||
"@koa/cors": "3.4.3",
|
"@koa/cors": "3.4.3",
|
||||||
"@koa/multer": "3.0.2",
|
"@koa/multer": "3.0.2",
|
||||||
"@koa/router": "9.0.1",
|
"@koa/router": "9.0.1",
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { Controller, Get, Post, Body, CurrentUser, Flow } from "@iceshrimp/koa-openapi";
|
import { Controller, Get, Post, Body, CurrentUser, Flow, Description } from "@iceshrimp/koa-openapi";
|
||||||
import type { ILocalUser } from "@/models/entities/user.js";
|
import type { ILocalUser } from "@/models/entities/user.js";
|
||||||
import type { AuthRequest, AuthResponse } from "@/server/api/web/entities/auth.js";
|
import type { AuthRequest, AuthResponse } from "@/server/api/web/entities/auth.js";
|
||||||
import type { Session } from "@/models/entities/session.js";
|
import type { Session } from "@/models/entities/session.js";
|
||||||
@ -9,6 +9,7 @@ import { AuthHandler } from "@/server/api/web/handlers/auth.js";
|
|||||||
@Controller('/auth')
|
@Controller('/auth')
|
||||||
export class AuthController {
|
export class AuthController {
|
||||||
@Get('/')
|
@Get('/')
|
||||||
|
@Description("Get the authentication status")
|
||||||
async getAuthStatus(
|
async getAuthStatus(
|
||||||
@CurrentUser() me: ILocalUser | null,
|
@CurrentUser() me: ILocalUser | null,
|
||||||
@CurrentSession() session: Session | null,
|
@CurrentSession() session: Session | null,
|
||||||
@ -18,6 +19,7 @@ export class AuthController {
|
|||||||
|
|
||||||
@Post('/')
|
@Post('/')
|
||||||
@Flow([RatelimitRouteMiddleware("auth", 10, 60000, true)])
|
@Flow([RatelimitRouteMiddleware("auth", 10, 60000, true)])
|
||||||
|
@Description("Log in as a user and receive a auth token on success")
|
||||||
async login(@Body({ required: true }) request: AuthRequest): Promise<AuthResponse> {
|
async login(@Body({ required: true }) request: AuthRequest): Promise<AuthResponse> {
|
||||||
return AuthHandler.login(request);
|
return AuthHandler.login(request);
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { Controller, Get, CurrentUser, Params, } from "@iceshrimp/koa-openapi";
|
import { Controller, Get, CurrentUser, Params, Description, } from "@iceshrimp/koa-openapi";
|
||||||
import type { ILocalUser } from "@/models/entities/user.js";
|
import type { ILocalUser } from "@/models/entities/user.js";
|
||||||
import { NoteHandler } from "@/server/api/web/handlers/note.js";
|
import { NoteHandler } from "@/server/api/web/handlers/note.js";
|
||||||
import { NoteResponse } from "@/server/api/web/entities/note.js";
|
import { NoteResponse } from "@/server/api/web/entities/note.js";
|
||||||
@ -7,6 +7,7 @@ import { notFound } from "@hapi/boom";
|
|||||||
@Controller('/note')
|
@Controller('/note')
|
||||||
export class NoteController {
|
export class NoteController {
|
||||||
@Get('/:id')
|
@Get('/:id')
|
||||||
|
@Description("Get the specified note")
|
||||||
async getNote(
|
async getNote(
|
||||||
@CurrentUser() me: ILocalUser | null,
|
@CurrentUser() me: ILocalUser | null,
|
||||||
@Params('id') id: string,
|
@Params('id') id: string,
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { Controller, CurrentUser, Flow, Get, Params, Query } from "@iceshrimp/koa-openapi";
|
import { Controller, CurrentUser, Description, Flow, Get, Params, Query } from "@iceshrimp/koa-openapi";
|
||||||
import { UserResponse } from "@/server/api/web/entities/user.js";
|
import { UserResponse } from "@/server/api/web/entities/user.js";
|
||||||
import { TimelineResponse } from "@/server/api/web/entities/note.js";
|
import { TimelineResponse } from "@/server/api/web/entities/note.js";
|
||||||
import type { ILocalUser } from "@/models/entities/user.js";
|
import type { ILocalUser } from "@/models/entities/user.js";
|
||||||
@ -10,6 +10,7 @@ import { AuthorizationMiddleware } from "@/server/api/web/middleware/auth.js";
|
|||||||
export class TimelineController {
|
export class TimelineController {
|
||||||
@Get('/home')
|
@Get('/home')
|
||||||
@Flow([AuthorizationMiddleware()])
|
@Flow([AuthorizationMiddleware()])
|
||||||
|
@Description("Get the home timeline")
|
||||||
async getHomeTimeline(
|
async getHomeTimeline(
|
||||||
@CurrentUser() me: ILocalUser,
|
@CurrentUser() me: ILocalUser,
|
||||||
@Query('replies') replies: boolean = true,
|
@Query('replies') replies: boolean = true,
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { Controller, CurrentUser, Get, Params, Query } from "@iceshrimp/koa-openapi";
|
import { Controller, CurrentUser, Description, Get, Params, Query } from "@iceshrimp/koa-openapi";
|
||||||
import { UserResponse } from "@/server/api/web/entities/user.js";
|
import { UserResponse } from "@/server/api/web/entities/user.js";
|
||||||
import { TimelineResponse } from "@/server/api/web/entities/note.js";
|
import { TimelineResponse } from "@/server/api/web/entities/note.js";
|
||||||
import type { ILocalUser } from "@/models/entities/user.js";
|
import type { ILocalUser } from "@/models/entities/user.js";
|
||||||
@ -7,6 +7,7 @@ import { UserHandler } from "@/server/api/web/handlers/user.js";
|
|||||||
@Controller('/user')
|
@Controller('/user')
|
||||||
export class UserController {
|
export class UserController {
|
||||||
@Get('/:id')
|
@Get('/:id')
|
||||||
|
@Description("Get information on the specified user")
|
||||||
async getUser(
|
async getUser(
|
||||||
@CurrentUser() me: ILocalUser | null,
|
@CurrentUser() me: ILocalUser | null,
|
||||||
@Params('id') id: string,
|
@Params('id') id: string,
|
||||||
@ -16,6 +17,7 @@ export class UserController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Get('/:id/notes')
|
@Get('/:id/notes')
|
||||||
|
@Description("Get the specified user's notes")
|
||||||
async getUserNotes(
|
async getUserNotes(
|
||||||
@CurrentUser() me: ILocalUser | null,
|
@CurrentUser() me: ILocalUser | null,
|
||||||
@Params('id') id: string,
|
@Params('id') id: string,
|
||||||
|
14
yarn.lock
14
yarn.lock
@ -1204,9 +1204,9 @@ __metadata:
|
|||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
"@iceshrimp/koa-openapi@npm:^2.2.0":
|
"@iceshrimp/koa-openapi@npm:^2.4.1":
|
||||||
version: 2.2.0
|
version: 2.4.1
|
||||||
resolution: "@iceshrimp/koa-openapi@npm:2.2.0::__archiveUrl=https%3A%2F%2Ficeshrimp.dev%2Fapi%2Fpackages%2Ficeshrimp%2Fnpm%2F%2540iceshrimp%252Fkoa-openapi%2F-%2F2.2.0%2Fkoa-openapi-2.2.0.tgz"
|
resolution: "@iceshrimp/koa-openapi@npm:2.4.1::__archiveUrl=https%3A%2F%2Ficeshrimp.dev%2Fapi%2Fpackages%2Ficeshrimp%2Fnpm%2F%2540iceshrimp%252Fkoa-openapi%2F-%2F2.4.1%2Fkoa-openapi-2.4.1.tgz"
|
||||||
dependencies:
|
dependencies:
|
||||||
"@hapi/boom": "npm:^10.0.1"
|
"@hapi/boom": "npm:^10.0.1"
|
||||||
"@koa/cors": "npm:^4.0.0"
|
"@koa/cors": "npm:^4.0.0"
|
||||||
@ -1221,7 +1221,7 @@ __metadata:
|
|||||||
lodash: "npm:^4.17.21"
|
lodash: "npm:^4.17.21"
|
||||||
openapi-types: "npm:^12.1.3"
|
openapi-types: "npm:^12.1.3"
|
||||||
reflect-metadata: "npm:*"
|
reflect-metadata: "npm:*"
|
||||||
checksum: a7ff2c0b1a6fa54dacb9cc9a84d6a3008928f76396e47be42ddf93456f98c55bca42b027db378035b7f9d336ee703e44deb2a0e7d55167ddb081ff066c27f0a0
|
checksum: 5270b64aa4131de59f624b4c9afb669118fb611a57118cb984a9b2ded83a8d6097b2c84eb516c68ec7b0b27ebdead637ee8cfeccb07a46da0bc5dda59b2015a5
|
||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
@ -5414,7 +5414,7 @@ __metadata:
|
|||||||
"@bull-board/ui": "npm:5.6.0"
|
"@bull-board/ui": "npm:5.6.0"
|
||||||
"@discordapp/twemoji": "npm:14.1.2"
|
"@discordapp/twemoji": "npm:14.1.2"
|
||||||
"@hapi/boom": "npm:^10.0.1"
|
"@hapi/boom": "npm:^10.0.1"
|
||||||
"@iceshrimp/koa-openapi": "npm:^2.2.0"
|
"@iceshrimp/koa-openapi": "npm:^2.4.1"
|
||||||
"@koa/cors": "npm:3.4.3"
|
"@koa/cors": "npm:3.4.3"
|
||||||
"@koa/multer": "npm:3.0.2"
|
"@koa/multer": "npm:3.0.2"
|
||||||
"@koa/router": "npm:9.0.1"
|
"@koa/router": "npm:9.0.1"
|
||||||
@ -11560,6 +11560,10 @@ __metadata:
|
|||||||
dependenciesMeta:
|
dependenciesMeta:
|
||||||
"@discordapp/twemoji@14.1.2":
|
"@discordapp/twemoji@14.1.2":
|
||||||
unplugged: true
|
unplugged: true
|
||||||
|
"@iceshrimp/koa-openapi@2.3.0":
|
||||||
|
unplugged: true
|
||||||
|
"@iceshrimp/koa-openapi@2.4.0":
|
||||||
|
unplugged: true
|
||||||
languageName: unknown
|
languageName: unknown
|
||||||
linkType: soft
|
linkType: soft
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user