-
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
Move backend docu #16
Conversation
The main responsibilities of a controller is to define the REST API interface as openAPI specification and map DTO's to match the logic layers interfaces. | ||
|
||
```TypeScript | ||
@Post() |
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.
Make it sense to also put a example line for expected errors open API definition.
Empty line between 15-16
|
||
## openAPI specification | ||
|
||
Defining the request/response DTOs in a controller will define the openAPI specification automatically. Additional [validation rules](https://docs.nestjs.com/techniques/validation) and [openAPI definitions](https://docs.nestjs.com/openapi/decorators) can be added using decorators. For simplification, openAPI decorators should define a type and if a property is required, while additional decorators can be used from class-validator to validate content. |
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.
By any change of the API the vue client must be updated too.
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 that be part of the server docu? That the vue client is using a generated client seems to be a detail of the client to me, especially since the command has to be executed in the client repository.
Its also already documented here
https://documentation.dbildungscloud.dev/docs/nuxt-client/HowTo
|
||
## Mapping | ||
|
||
It is forbidden, to directly pass a DTO to a use-case or return an Entity (or other use-case result) via REST. In-between a mapper must transform the given data, to protect the logic layer from outside implications. |
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 is not wrong, but a picture with overall layer structure + name defintitions + dependency & mappings make more sense like a text.
|
||
A specification checks if a domain object fulfills the conditions of the specification. | ||
|
||
A specification can simply specify that a domain object is valid. E.g. a `Task` has an owner and a description. |
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.
Any hind how we use it?
Use methods that do more like simple getter/setter (to make class cohesion vsisible), props a private. Only methods that can handle by the domain object. It is allow that other domain object can pass by in props, but should not generate a new one.
try { | ||
someMethod(); | ||
} catch(error) { | ||
throw new ForbiddenException('some message', { cause: error }); |
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.
Do not work anymore. We has a ErrorUtil to pass the cause.
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.
please put in a correct example
super(); | ||
} | ||
|
||
getLogMessage(): ErrorLogMessage { |
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.
@SevenWaysDP if i remember correct you had one PR for implement loggables with cause error in test and add this examples also to confluence or?
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.
Is is not up to date anymore.
```TypeScript | ||
// doSomethingCrazy : Promise<retValue> | ||
it('bad async sample', async function (done) => { | ||
this.timeout(10000); |
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.
This is wrong. The timeout for a isolated test should be pass as 3. parameter. It is a bad example but not in case of this timeout.
You can create a mock using `createMock<Class>()`. As result you will recieved a `DeepMocked<Class>` | ||
|
||
```Typescript | ||
let fut: FeatureUnderTest; |
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.
We should not let stay featherJS examples inside to documentation. It not needed, for this show case.
The imports from golevelup should also be part of the example.
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.
what do you mean by feathers example?
describe('[method]', () => { | ||
describe('when [senario description that is prepared in setup]', () => { | ||
const setup = () => { | ||
// prepare the data and mocks for this scenario |
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 miss the part of deep mocked services should be mocked. Do not use Jest (expect it is a other method of the tested service in this file), use Once, use for async Resolve / Reject for syncron mockImplementation.
|
||
### Domain Layer | ||
|
||
The Domain Layer contains the business logic of the application. As mentioned above, it is not allowed to know about anything outside the domain layer itself. |
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.
Splitting UC and service in two layer. Nothing from UC should be importat into service layer.
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.
Expect the comments.
describe('createCourse', () => { | ||
// a "when..." sentence | ||
describe("When a student tries to create a course", (() => { | ||
// a "should..." sentence |
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 thint the const setup = () => is missed but maybe it is enough with the double explaination from line 76?
Description
Links to Tickets or other pull requests
Changes
Datasecurity
Deployment
New Repos, NPM pakages or vendor scripts
Screenshots of UI changes
Approval for review