UNCLASSIFIED - NO CUI
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
fiesta-wagon-hello-express
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
Platform One
Party Bus
fiesta-wagon
hello-world-templates
fiesta-wagon-hello-express
Merge requests
!5
BULL-3221: express mvp
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
BULL-3221: express mvp
BULL-3221_express_mvp
into
main
Overview
0
Commits
4
Pipelines
0
Changes
13
Merged
Douglas Lagemann
requested to merge
BULL-3221_express_mvp
into
main
2 months ago
Overview
0
Commits
4
Pipelines
0
Changes
13
Expand
added unit tests, note that the dataLayer unit tests are also overwritten when dataLayer is replaced by a real implementation
added production dockerfile
0
0
Merge request reports
Compare
main
main (base)
and
latest version
latest version
8ba55331
4 commits,
2 months ago
13 files
+
5735
−
64
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
13
Search (e.g. *.vue) (Ctrl+P)
src/controller/controller.js
0 → 100644
+
56
−
0
Options
const
{
getDbVersion
,
healthCheck
}
=
require
(
'
../data/dataLayer
'
);
const
{
jwtDecode
}
=
require
(
'
jwt-decode
'
);
const
apiVersion
=
"
0.0.1
"
;
/**
* Perform a health check by ensuring data layer connectivity is healthy.
* */
exports
.
getHealth
=
async
(
req
,
res
)
=>
{
const
dbHealth
=
await
healthCheck
();
if
(
!
dbHealth
)
{
console
.
log
(
"
Unable to get DB health, returning 500 response
"
);
res
.
status
(
500
).
json
({
status
:
500
,
message
:
"
Internal Server Error
"
});
return
;
}
let
statusCode
=
500
;
if
(
dbHealth
.
healthy
)
{
statusCode
=
200
;
}
res
.
status
(
statusCode
).
json
({
status
:
statusCode
,
message
:
dbHealth
.
message
});
};
/**
* Return the user's current JWT. Useful to ensure that the app is integrated properly in the Party Bus infrastructure.
*/
exports
.
getUser
=
async
(
req
,
res
)
=>
{
try
{
const
header
=
req
.
headersDistinct
?.
Authorization
?.[
0
]
||
req
.
headersDistinct
?.
authorization
?.[
0
];
const
responseData
=
header
?
jwtDecode
(
header
)
:
{
result
:
"
no authorization header found
"
};
res
.
status
(
200
).
json
(
responseData
);
}
catch
(
error
)
{
const
errorResponse
=
{
error
:
'
Unable to read authorization header as jwt! Error:
'
+
error
.
message
}
res
.
status
(
400
).
json
(
errorResponse
);
}
};
/**
* Return basic version information. Useful to check that the app can query from its database.
*/
exports
.
getVersion
=
async
(
req
,
res
)
=>
{
const
dbVersion
=
await
getDbVersion
();
const
versionResponse
=
{
apiVersion
:
apiVersion
,
dbVersion
:
dbVersion
};
res
.
status
(
200
).
json
(
versionResponse
);
};
Loading