-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Setup local user register & handle exception error to logger #6
Conversation
|
||
import { AppModule } from "./app.module"; | ||
|
||
async function bootstrap() { | ||
const app = await NestFactory.create(AppModule); | ||
app.use(morgan("default", { stream: logStream })); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does not described in PR content, should consider to add description about this
src/main.ts
Outdated
setupSwagger(app); | ||
await app.listen(3000); | ||
} | ||
|
||
const logStream = fs.createWriteStream("api.log", { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does this mean to log into single file in root folder? I would recommend to reconsider about log file save path and segmentation policy like by size or by date etc...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- generaly we would use
model
to represent database models, to use this word here would be confusing. - I would recommend to reconsider how to organize these files, like use a
exception-filter
to organizeall-exceptions
and this type together.
description: "Data Conflict", | ||
type: CreateConflictUserError, | ||
}) | ||
@ApiUnprocessableEntityResponse({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
generally will use 401 instead of 422 to represent that user given data is not correct.
|
||
@ApiProperty({ | ||
description: "User showname", | ||
example: "showname", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it would be better to use a name or something
}, | ||
}, | ||
}, | ||
example: "email has been registered.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be an array of message
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I recommend to create an auth module to handle register
, login
related features.
ref:
cc2fab5
to
0f4a61d
Compare
Setup local user register, handle exception error, and setup logger
Setup: