export default function errorHandler(error, req, res, next) {
const status = error.code ?? 500;
if (error.name === "UnauthorizedError") {
res.status(401).send("invalid token...");
}
return res.status(status).json({
path: req.path,
method: req.method,
message: error.message ?? "Internal Server Error",
data: error.data ?? undefined,
date: new Date(),
});
}
if (!foo) {
const error = new Error("존재하지 않는 foo입니다.");
error.code = 404;
throw error;
}
.prettierrc
Next.js 팩 : Turbo pack
import 경로 : 멀리 있는 건 절대경로, 가까이 있는 건 상대경로
.gitignore :
.env
*.http
node_modules
.next/