Skip to content

Commit

Permalink
chore(api): use env var for base path url (#34)
Browse files Browse the repository at this point in the history
Co-authored-by: Grégoire Paris <[email protected]>
  • Loading branch information
pfongkye and greg0ire authored Jul 19, 2024
1 parent f1a9884 commit de5ee01
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .env.test
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@

API_BASE_PATH=/api/v1/homer
EMAIL_DOMAINS=my-domain.com,ext.my-domain.com
GITLAB_SECRET=GITLAB_SECRET
GITLAB_TOKEN=GITLAB_TOKEN
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,10 @@ Be sure to have all those installed:

Create a `.env` file containing the following variables:

- `API_BASE_PATH`

This is the base path that will be used to build the API URL to call homer, for example `https://homer.com<API_BASE_PATH>/command`.

- `GITLAB_SECRET`

This is a user generated secret, so you can put any value.
Expand Down
3 changes: 2 additions & 1 deletion src/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { logger } from '@/core/services/logger';
import { catchAsyncRouteErrors } from '@/core/utils/catchAsyncRouteErrors';
import { waitForNonReadyReleases } from '@/release/commands/create/utils/waitForNonReadyReleases';
import { REQUEST_BODY_SIZE_LIMIT } from './constants';
import { getEnvVariable } from './core/utils/getEnvVariable';
import { router } from './router';

const PORT = 3000;
Expand All @@ -36,7 +37,7 @@ export async function start(): Promise<() => Promise<void>> {
catchAsyncRouteErrors(stateRequestHandler)
);
app.use(securityMiddleware);
app.use('/api/v1/homer', router);
app.use(getEnvVariable('API_BASE_PATH'), router);
app.use(errorMiddleware);

const server = app.listen(PORT, async () => {
Expand Down

0 comments on commit de5ee01

Please sign in to comment.