Skip to content

Commit

Permalink
fix(): add content type to API responses
Browse files Browse the repository at this point in the history
  • Loading branch information
mikaelvesavuori committed Mar 27, 2023
1 parent 33a9c3d commit 4a7ccfd
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "gitmetrix",
"description": "Helps you find your team-level engineering metrics",
"version": "2.2.0",
"version": "2.2.1",
"author": "Mikael Vesavuori",
"license": "MIT",
"keywords": [
Expand Down
5 changes: 4 additions & 1 deletion src/infrastructure/frameworks/end.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@
*/
export function end(statusCode = 201, message?: Record<string, any> | number | string) {
if (!message) message = '';
const contentType =
typeof message === 'string' || typeof message === 'number' ? 'text/plain' : 'application/json';

return {
statusCode,
body: JSON.stringify(message),
headers: {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Credentials': true
'Access-Control-Allow-Credentials': true,
'Content-Type': contentType
}
};
}

0 comments on commit 4a7ccfd

Please sign in to comment.