-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bugfix: ensure backend api routes are configured and respond to reque…
…st (#30)
- Loading branch information
1 parent
e6fc708
commit 141263f
Showing
7 changed files
with
56 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,13 @@ | ||
.DS_STORE | ||
|
||
/build | ||
/node_modules | ||
/be/.env | ||
/be/**/logs/* | ||
be/node_modules/ | ||
fe/node_modules/ | ||
|
||
# e2e test output | ||
# e2e test output and artifacts | ||
cypress/screenshots/ | ||
nohup.out | ||
/tmp/**/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
|
||
|
||
import { App } from './app.js'; | ||
import { HealthRoute } from './src/routes/health.routes.js'; | ||
import { UserRoute } from './src/routes/user.routes.js'; | ||
|
||
// ValidateEnv(); | ||
|
||
const app = new App([new UserRoute()]); | ||
const app = new App([new HealthRoute(), new UserRoute()]); | ||
|
||
app.listen(); | ||
app.listen(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// TODO: add swagger docs. get health and E2E test working first. | ||
|
||
import { Router } from 'express' | ||
|
||
// memoize router so that when the consumers retrieve it through getter, | ||
// it's not a fresh instance, as that essentially wipes out the routes | ||
const router = Router() | ||
|
||
export class HealthRoute { | ||
get path() { | ||
return '/health' | ||
} | ||
|
||
get router() { | ||
return router | ||
} | ||
|
||
constructor() { | ||
this.initializeRoutes() | ||
} | ||
|
||
buildResponse(req, res) { | ||
res.status(200).json({ data: { attributes: { healthy: true } } }) | ||
} | ||
|
||
initializeRoutes() { | ||
this.router.get(this.path, this.buildResponse) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,14 @@ | ||
import React from 'react' | ||
import App from './App' | ||
import ReactDOM from 'react-dom' | ||
import { api } from '../services/api' | ||
|
||
ReactDOM.render(<App />, document.getElementById('root')) | ||
const root = document.getElementById('root') | ||
|
||
api.get('/api/v1/health').then((response) => { | ||
if (response.healthy) { | ||
root.classList.add('backend-healthy') | ||
} | ||
}) | ||
|
||
ReactDOM.render(<App />, root) |