Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
DojoBackendAPI
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
Dojo_Project_Nguyen
Backend
DojoBackendAPI
Commits
518d48c0
Commit
518d48c0
authored
11 months ago
by
kelly.nguyen
Browse files
Options
Downloads
Patches
Plain Diff
add branch add_export_route
parent
7aa9e1e0
No related branches found
No related tags found
No related merge requests found
Pipeline
#33194
failed
11 months ago
Stage: code_quality
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
ExpressAPI/src/managers/GitlabManager.ts
+12
-1
12 additions, 1 deletion
ExpressAPI/src/managers/GitlabManager.ts
ExpressAPI/src/routes/AssignmentRoutes.ts
+7
-0
7 additions, 0 deletions
ExpressAPI/src/routes/AssignmentRoutes.ts
with
19 additions
and
1 deletion
ExpressAPI/src/managers/GitlabManager.ts
+
12
−
1
View file @
518d48c0
...
...
@@ -3,7 +3,7 @@ import { StatusCodes }
import
GitlabVisibility
from
'
../shared/types/Gitlab/GitlabVisibility.js
'
;
import
express
from
'
express
'
;
import
SharedConfig
from
'
../shared/config/SharedConfig.js
'
;
import
{
CommitSchema
,
ExpandedUserSchema
,
Gitlab
,
MemberSchema
,
ProjectBadgeSchema
,
ProjectSchema
,
ReleaseSchema
,
RepositoryFileExpandedSchema
,
RepositoryFileSchema
,
RepositoryTreeSchema
}
from
'
@gitbeaker/rest
'
;
import
{
ArchiveType
,
CommitSchema
,
ExpandedUserSchema
,
Gitlab
,
MemberSchema
,
ProjectBadgeSchema
,
ProjectSchema
,
ReleaseSchema
,
RepositoryFileExpandedSchema
,
RepositoryFileSchema
,
RepositoryTreeSchema
}
from
'
@gitbeaker/rest
'
;
import
logger
from
'
../shared/logging/WinstonLogger.js
'
;
import
{
AccessLevel
,
EditProjectOptions
,
ProjectVariableSchema
,
ProtectedBranchAccessLevel
,
ProtectedBranchSchema
}
from
'
@gitbeaker/core
'
;
import
DojoStatusCode
from
'
../shared/types/Dojo/DojoStatusCode.js
'
;
...
...
@@ -267,6 +267,17 @@ class GitlabManager extends SharedGitlabManager {
return
Promise
.
reject
(
e
);
}
}
async
exportRepository
(
repoId
:
number
,
extension
:
ArchiveType
):
Promise
<
Blob
>
{
try
{
return
await
this
.
api
.
Repositories
.
showArchive
(
repoId
,
{
fileType
:
extension
});
}
catch
(
e
)
{
logger
.
error
(
JSON
.
stringify
(
e
));
return
Promise
.
reject
(
e
);
}
}
}
...
...
This diff is collapsed.
Click to expand it.
ExpressAPI/src/routes/AssignmentRoutes.ts
+
7
−
0
View file @
518d48c0
...
...
@@ -80,6 +80,7 @@ class AssignmentRoutes implements RoutesManager {
backend
.
post
(
'
/assignments/:assignmentNameOrUrl/corrections
'
,
SecurityMiddleware
.
check
(
true
,
SecurityCheckType
.
ASSIGNMENT_STAFF
),
ParamsValidatorMiddleware
.
validate
(
this
.
assignmentAddCorrigeValidator
),
this
.
linkUpdateAssignmentCorrection
(
false
).
bind
(
this
)
as
RequestHandler
);
backend
.
patch
(
'
/assignments/:assignmentNameOrUrl/corrections/:exerciseIdOrUrl
'
,
SecurityMiddleware
.
check
(
true
,
SecurityCheckType
.
ASSIGNMENT_STAFF
),
ParamsValidatorMiddleware
.
validate
(
this
.
assignmentUpdateCorrigeValidator
),
this
.
linkUpdateAssignmentCorrection
(
true
).
bind
(
this
)
as
RequestHandler
);
backend
.
delete
(
'
/assignments/:assignmentNameOrUrl/corrections/:exerciseIdOrUrl
'
,
SecurityMiddleware
.
check
(
true
,
SecurityCheckType
.
ASSIGNMENT_STAFF
),
this
.
unlinkAssignmentCorrection
.
bind
(
this
)
as
RequestHandler
);
backend
.
get
(
'
/assignments/:assignmentNameOrUrl/export
'
,
SecurityMiddleware
.
check
(
true
,
SecurityCheckType
.
ASSIGNMENT_STAFF
),
this
.
exportAssignment
.
bind
(
this
)
as
RequestHandler
);
}
// Get an assignment by its name or gitlab url
...
...
@@ -299,6 +300,12 @@ class AssignmentRoutes implements RoutesManager {
return
req
.
session
.
sendResponse
(
res
,
StatusCodes
.
OK
);
}
private
async
exportAssignment
(
req
:
express
.
Request
,
res
:
express
.
Response
)
{
let
ext
:
Gitlab
.
ArchiveType
=
'
zip
'
;
await
GitlabManager
.
exportRepository
(
req
.
boundParams
.
assignment
!
.
gitlabId
,
ext
);
return
req
.
session
.
sendResponse
(
res
,
StatusCodes
.
OK
);
}
}
...
...
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