feat: Better styling on web pages, bad-words check now has less edge cases.

This commit is contained in:
2024-12-31 23:57:47 -05:00
parent 8dba393267
commit 26191a15c1
6 changed files with 160 additions and 91 deletions

View File

@@ -5,13 +5,18 @@ import Vapor
struct ApiController: RouteCollection {
func boot(routes: any RoutesBuilder) throws {
let users = routes.grouped("api", "users")
let api = routes.grouped("api")
let users = api.grouped("users")
let proCon = api.grouped("procons")
let utils = api.grouped("utils")
users.get(use: usersIndex(req:))
users.post(use: createUser(req:))
let proCon = routes.grouped("api", "procons")
proCon.get(use: prosAndConsIndex(req:))
proCon.post(use: createProCon(req:))
utils.post("check-words", use: checkWords(req:))
}
@Sendable
@@ -39,6 +44,17 @@ struct ApiController: RouteCollection {
return proCon
}
@Sendable
func checkWords(req: Request) async throws -> HTTPStatus {
let input = try req.content.decode(CheckWords.self)
try checkForBadWords(in: input.string)
return .ok
}
}
struct CheckWords: Content {
let string: String
}
struct ProConDTO: Content {