Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
InternshipManager-Back
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
GUVEN Kemal
InternshipManager-Back
Commits
099068fb
Commit
099068fb
authored
2 years ago
by
Ivan Alglave
Browse files
Options
Downloads
Patches
Plain Diff
fix: PUT not outputs and saves correctly the internship
parent
818ef0ba
No related branches found
Branches containing commit
No related tags found
1 merge request
!5
Crud internship
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/internships/dao/internships.dao.ts
+5
-3
5 additions, 3 deletions
src/internships/dao/internships.dao.ts
src/shared/HttpError.ts
+4
-0
4 additions, 0 deletions
src/shared/HttpError.ts
with
9 additions
and
3 deletions
src/internships/dao/internships.dao.ts
+
5
−
3
View file @
099068fb
import
{
Injectable
,
NotFoundException
}
from
'
@nestjs/common
'
;
import
{
InjectModel
}
from
'
@nestjs/mongoose
'
;
import
{
Model
}
from
'
mongoose
'
;
import
{
CONFLICT
}
from
'
src/shared/HttpError
'
;
import
{
BAD_REQUEST
,
CONFLICT
,
INTERNAL
}
from
'
src/shared/HttpError
'
;
import
{
STATE_STUDENT_ENTERS_INTERNSHIP_INFORMATION
}
from
'
src/shared/InternshipState
'
;
import
{
CreateInternshipDto
}
from
'
../dto/create-internship.dto
'
;
import
{
InternshipDto
}
from
'
../dto/internship.dto
'
;
...
...
@@ -58,6 +58,7 @@ export class InternshipDao {
):
Promise
<
Internship
|
void
>
=>
new
Promise
((
resolve
,
reject
)
=>
{
// Check if information modification is allowed -> current state is information input by student and updating is allowed
if
(
studentId
!==
internship
.
studentId
)
reject
(
BAD_REQUEST
);
const
decoratedInternship
=
this
.
toInternshipDtoWithTracking
(
internship
);
this
.
_internshipModel
.
findOneAndReplace
(
{
...
...
@@ -71,7 +72,8 @@ export class InternshipDao {
},
(
err
,
value
)
=>
{
if
(
err
)
reject
(
err
.
message
);
resolve
(
value
);
// if (typeof value !== typeof Internship) reject(INTERNAL);
resolve
(
value
as
Internship
);
},
);
});
...
...
@@ -90,7 +92,7 @@ export class InternshipDao {
return
{
...
createInternshipDto
,
tracking
:
{
state
:
'
state-1
'
,
state
:
STATE_STUDENT_ENTERS_INTERNSHIP_INFORMATION
,
},
};
};
...
...
This diff is collapsed.
Click to expand it.
src/shared/HttpError.ts
+
4
−
0
View file @
099068fb
...
...
@@ -3,10 +3,14 @@ import {
NotFoundException
,
ConflictException
,
UnprocessableEntityException
,
BadRequestException
,
InternalServerErrorException
,
}
from
'
@nestjs/common
'
;
export
const
NOT_FOUND
=
new
NotFoundException
();
export
const
CONFLICT
=
new
ConflictException
();
export
const
BAD_REQUEST
=
new
BadRequestException
();
export
const
INTERNAL
=
new
InternalServerErrorException
();
export
const
BAD_TRACKING_STATE
=
(
badState
:
string
)
=>
new
UnprocessableEntityException
(
`Unknown state [
${
badState
}
]`
);
export
const
CUSTOM
=
(
reason
:
string
,
errorStatus
:
number
)
=>
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment