feat(WEB-132): add middlewares, support for seamless login and improve lang based routes
This commit is contained in:
13
server/errors/next.ts
Normal file
13
server/errors/next.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import { NextResponse } from "next/server"
|
||||
|
||||
export function badRequest() {
|
||||
return new NextResponse("Bad request", {
|
||||
status: 400,
|
||||
})
|
||||
}
|
||||
|
||||
export function internalServerError() {
|
||||
return new NextResponse("Internal Server Error", {
|
||||
status: 500,
|
||||
})
|
||||
}
|
||||
28
server/errors/trpc.ts
Normal file
28
server/errors/trpc.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import { TRPCError } from "@trpc/server"
|
||||
import {
|
||||
TRPC_ERROR_CODES_BY_NUMBER,
|
||||
TRPC_ERROR_CODES_BY_KEY,
|
||||
} from "@trpc/server/rpc"
|
||||
|
||||
export function unauthorizedError() {
|
||||
return new TRPCError({
|
||||
code: TRPC_ERROR_CODES_BY_NUMBER[TRPC_ERROR_CODES_BY_KEY.UNAUTHORIZED],
|
||||
message: `Authorization required!`,
|
||||
})
|
||||
}
|
||||
|
||||
export function internalServerError() {
|
||||
return new TRPCError({
|
||||
code: TRPC_ERROR_CODES_BY_NUMBER[
|
||||
TRPC_ERROR_CODES_BY_KEY.INTERNAL_SERVER_ERROR
|
||||
],
|
||||
message: `Internal Server Error!`,
|
||||
})
|
||||
}
|
||||
|
||||
export function badRequestError(msg = "Bad request!") {
|
||||
return new TRPCError({
|
||||
code: TRPC_ERROR_CODES_BY_NUMBER[TRPC_ERROR_CODES_BY_KEY.BAD_REQUEST],
|
||||
message: msg,
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user