我是 NestJS 的初学者,我想为以下结构编写一个 DTO -
{
something: {
info: {
title: string,
score: number,
description: string,
time: string,
DateOfCreation: string
},
Store: {
item: {
question: string,
options: {
item: {
answer: string,
description: string,
id: string,
key: string,
option: string
}
}
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
我想为该嵌套数据对象编写一个 DTO。我找不到在 NestJS 中编写嵌套 DTO 的可靠示例。我是 NestJS 的初学者,之前从未使用过 DTO。所以请不要假设我知道一些事情。我将它与 Mongoose 一起使用。
我有一个带有简单用户身份验证的 nextjs 应用程序。这意味着我不希望注销的用户访问一些受保护的路由。该应用程序在开发版本中成功编译并按预期工作。但是当我使用时next build,我收到一条错误消息 -
Error occurred prerendering page "/createNewAdditionalInfo". Read more: https://err.sh/next.js/prerender-error
Error: 'redirect' can not be returned from getStaticProps during prerendering (/createNewAdditionalInfo)。
这是代码 -
export async function getStaticProps(ctx) {
let userObject;
let id;
const cookie = parseCookies(ctx);
if (cookie.auth) {
userObject = JSON.parse(cookie.auth);
id = userObject.id;
}
if (!id) {
return {
redirect: {
permanent: false,
destination: '/',
},
};
}
return {
props: {},
};
}
Run Code Online (Sandbox Code Playgroud)