Skip to content

Commit

Permalink
Endpoint to report curator-service version #2289
Browse files Browse the repository at this point in the history
  • Loading branch information
iamleeg committed Feb 21, 2022
1 parent 31b510e commit 8837c94
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 11 deletions.
25 changes: 19 additions & 6 deletions verification/curator-service/api/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,10 @@ if (env.SERVICE_ENV == 'locale2e') {
s3ForcePathStyle: true,
});
} else {
s3Client = new S3({ region: env.AWS_SERVICE_REGION, signatureVersion: 'v4' });
s3Client = new S3({
region: env.AWS_SERVICE_REGION,
signatureVersion: 'v4',
});
}

// Configure Email Client
Expand Down Expand Up @@ -183,10 +186,12 @@ const sourcesController = new SourcesController(
awsEventsClient,
env.DATASERVER_URL,
);
apiRouter.get('/sources',
apiRouter.get(
'/sources',
authenticateByAPIKey,
mustHaveAnyRole(['curator']),
sourcesController.list);
sourcesController.list,
);
apiRouter.get(
'/sources/:id([a-z0-9]{24})',
authenticateByAPIKey,
Expand Down Expand Up @@ -247,10 +252,12 @@ apiRouter.put(

// Configure cases controller proxying to data service.
const casesController = new CasesController(env.DATASERVER_URL, s3Client);
apiRouter.get('/cases',
apiRouter.get(
'/cases',
authenticateByAPIKey,
mustBeAuthenticated,
casesController.list);
casesController.list,
);
apiRouter.get(
'/cases/symptoms',
authenticateByAPIKey,
Expand Down Expand Up @@ -343,7 +350,8 @@ apiRouter.get(
'/users',
authenticateByAPIKey,
mustHaveAnyRole(['admin']),
usersController.list);
usersController.list,
);
apiRouter.put(
'/users/:id',
authenticateByAPIKey,
Expand Down Expand Up @@ -388,6 +396,11 @@ app.get('/health', (req: Request, res: Response) => {
return res.sendStatus(503);
});

// version handler.
app.get('/version', (req: Request, res: Response) => {
res.status(200).send(env.CURATOR_VERSION);
});

// API documentation.
const swaggerDocument = YAML.load('./openapi/openapi.yaml');
app.use(
Expand Down
14 changes: 9 additions & 5 deletions verification/curator-service/api/src/util/validate-env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export default function validateEnv(): Readonly<{
AWS_ACCESS_KEY_ID: string;
AWS_SECRET_ACCESS_KEY: string;
AWS_SERVICE_REGION: string;
CURATOR_VERSION: string;
DATASERVER_URL: string;
DB_CONNECTION_STRING: string;
EMAIL_USER_ADDRESS: string;
Expand All @@ -20,11 +21,10 @@ export default function validateEnv(): Readonly<{
SERVICE_ENV: string;
SESSION_COOKIE_KEY: string;
STATIC_DIR: string;
}> &
{
readonly [varName: string]: string | boolean | number | undefined;
// eslint-disable-next-line indent
} {
}> & {
readonly [varName: string]: string | boolean | number | undefined;
// eslint-disable-next-line indent
} {
return cleanEnv(process.env, {
AFTER_LOGIN_REDIRECT_URL: str({
desc: 'URL to redirect to after the oauth consent screen',
Expand All @@ -44,6 +44,10 @@ export default function validateEnv(): Readonly<{
desc: 'AWS region in which to interact with services/resources',
default: 'us-east-1',
}),
CURATOR_VERSION: str({
desc: 'version string to display in UI for bug reports etc.',
devDefault: '(local testing)',
}),
DATASERVER_URL: url({
desc: 'URL at which to make requests to the data-service API',
devDefault: 'http://localhost:3000',
Expand Down

0 comments on commit 8837c94

Please sign in to comment.