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
External 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 (HES-SO)
Projects
Backend
DojoBackendAPI
Commits
c574fcaf
Commit
c574fcaf
authored
1 year ago
by
joel.vonderwe
Committed by
michael.minelli
1 month ago
Browse files
Options
Downloads
Patches
Plain Diff
Add languages to sonar route
parent
8a4afa83
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
ExpressAPI/src/managers/SonarManager.ts
+13
-3
13 additions, 3 deletions
ExpressAPI/src/managers/SonarManager.ts
ExpressAPI/src/routes/BaseRoutes.ts
+3
-1
3 additions, 1 deletion
ExpressAPI/src/routes/BaseRoutes.ts
with
16 additions
and
4 deletions
ExpressAPI/src/managers/SonarManager.ts
+
13
−
3
View file @
c574fcaf
...
...
@@ -34,9 +34,7 @@ class SonarManager {
}
private
async
executePostRequest
<
T
>
(
url
:
string
,
data
?:
FormData
)
{
console
.
log
(
"
dhdidid
"
);
await
this
.
setPAT
();
// Always set PAT to be sure it has been set
console
.
log
(
"
hehe
"
,
btoa
(
SharedConfig
.
sonar
.
token
));
return
(
await
this
.
instance
.
post
<
T
>
(
url
,
data
,
{
headers
:
{
...
...
@@ -45,14 +43,26 @@ class SonarManager {
})).
data
;
}
private
async
executeGetRequest
<
T
>
(
url
:
string
)
{
return
(
await
this
.
instance
.
get
<
T
>
(
url
,
{
headers
:
{
Authorization
:
`Basic
${
btoa
(
SharedConfig
.
sonar
.
token
+
"
:
"
)
}
`
}
})).
data
;
}
async
createProjectFromGitlab
(
projectId
:
number
)
{
const
formData
=
new
FormData
();
formData
.
append
(
'
almSetting
'
,
'
dojo
'
);
formData
.
append
(
'
gitlabProjectId
'
,
projectId
.
toString
());
console
.
log
(
formData
);
return
await
this
.
executePostRequest
<
SonarProjectCreation
>
(
this
.
getApiUrl
(
SonarRoute
.
PROJECT_CREATE_GITLAB
),
formData
)
}
async
getLanguages
()
{
const
resp
=
await
this
.
executeGetRequest
<
{
languages
:
{
key
:
string
,
name
:
string
}[]}
>
(
this
.
getApiUrl
(
SonarRoute
.
GET_LANGUAGES
))
return
resp
.
languages
.
map
(
l
=>
l
.
key
)
}
}
export
default
new
SonarManager
();
\ No newline at end of file
This diff is collapsed.
Click to expand it.
ExpressAPI/src/routes/BaseRoutes.ts
+
3
−
1
View file @
c574fcaf
...
...
@@ -6,6 +6,7 @@ import Config from '../config/Config';
import
SharedConfig
from
'
../shared/config/SharedConfig
'
;
import
GlobalHelper
from
'
../helpers/GlobalHelper
'
;
import
SharedSonarManager
from
'
../shared/managers/SharedSonarManager
'
;
import
SonarManager
from
'
../managers/SonarManager
'
;
class
BaseRoutes
implements
RoutesManager
{
...
...
@@ -38,7 +39,8 @@ class BaseRoutes implements RoutesManager {
private
async
sonar
(
req
:
express
.
Request
,
res
:
express
.
Response
)
{
const
data
=
{
sonarEnabled
:
await
SharedSonarManager
.
isSonarSupported
()
sonarEnabled
:
await
SharedSonarManager
.
isSonarSupported
(),
languages
:
await
SonarManager
.
getLanguages
()
};
return
req
.
session
.
sendResponse
(
res
,
StatusCodes
.
OK
,
data
);
}
...
...
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