Skip to content

Commit

Permalink
format .ts files
Browse files Browse the repository at this point in the history
npm run format
  • Loading branch information
zekehuntergreen committed Jan 25, 2024
1 parent a4d1d84 commit 93cee99
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 40 deletions.
22 changes: 11 additions & 11 deletions packages/api/src/config.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { findParameter, getParameters } from "./configHelpers";
import { findParameter, getParameters } from './configHelpers';
import { Parameter, SSM } from '@aws-sdk/client-ssm';

interface TranscriptionConfig {
test: string // TODO: This is just the foundation of getting params from SSM
test: string; // TODO: This is just the foundation of getting params from SSM
}

const region = process.env['AWS_REGION'];
Expand All @@ -16,14 +16,14 @@ export const getConfig = async (): Promise<TranscriptionConfig> => {
const paramPath = `/${stage}/investigations/transcription-service/`;

const parameters = await getParameters(paramPath, ssm);
const parameterNames = parameters.map((param: Parameter) => {
return param.Name;
});
const parameterNames = parameters.map((param: Parameter) => {
return param.Name;
});

console.log(`Parameters fetched: ${parameterNames.join(", ")}`);
const testParam = findParameter(parameters, paramPath, "test");
console.log(`Parameters fetched: ${parameterNames.join(', ')}`);
const testParam = findParameter(parameters, paramPath, 'test');

return {
test: testParam
}
};
return {
test: testParam,
};
};
18 changes: 9 additions & 9 deletions packages/api/src/configHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,19 @@ export const getParameters = async (
export const findParameter = (
parameters: Parameter[],
paramPath: string,
paramKey: string
): string => {
paramKey: string,
): string => {
const parameter = parameters.find(
(param: Parameter) => param.Name === `${paramPath}${paramKey}`
(param: Parameter) => param.Name === `${paramPath}${paramKey}`,
);

return getValueOfParam(paramKey, parameter);
};
};

export const getValueOfParam = (
export const getValueOfParam = (
paramKey: string,
parameter?: Parameter
): string => {
parameter?: Parameter,
): string => {
if (!parameter) {
throw new Error(`The parameter ${paramKey} hasn't been configured`);
}
Expand All @@ -65,4 +65,4 @@ export const findParameter = (
}
console.log(`Found value of parameter: ${paramKey}`);
return parameter.Value;
};
};
2 changes: 1 addition & 1 deletion packages/api/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const getApp = async () => {
const config = await getConfig();

// TODO: This is just for testing. Actual config values should never be logged
console.log(`config value retrieved: ${config.test}`);
console.log(`config value retrieved: ${config.test}`);

const app = express();
const apiRouter = express.Router();
Expand Down
18 changes: 13 additions & 5 deletions packages/cdk/bin/cdk.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
import "source-map-support/register";
import { GuRoot } from "@guardian/cdk/lib/constructs/root";
import { TranscriptionService } from "../lib/transcription-service";
import 'source-map-support/register';
import { GuRoot } from '@guardian/cdk/lib/constructs/root';
import { TranscriptionService } from '../lib/transcription-service';

const app = new GuRoot();
new TranscriptionService(app, "TranscriptionService-CODE", { stack: "investigations", stage: "CODE", env: { region: "eu-west-1" } });
new TranscriptionService(app, "TranscriptionService-PROD", { stack: "investigations", stage: "PROD", env: { region: "eu-west-1" } });
new TranscriptionService(app, 'TranscriptionService-CODE', {
stack: 'investigations',
stage: 'CODE',
env: { region: 'eu-west-1' },
});
new TranscriptionService(app, 'TranscriptionService-PROD', {
stack: 'investigations',
stage: 'PROD',
env: { region: 'eu-west-1' },
});
24 changes: 14 additions & 10 deletions packages/cdk/lib/transcription-service.test.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
import { App } from "aws-cdk-lib";
import { Template } from "aws-cdk-lib/assertions";
import { TranscriptionService } from "./transcription-service";
import { App } from 'aws-cdk-lib';
import { Template } from 'aws-cdk-lib/assertions';
import { TranscriptionService } from './transcription-service';

describe("The TranscriptionService stack", () => {
it("matches the snapshot", () => {
const app = new App();
const stack = new TranscriptionService(app, "TranscriptionService", { stack: "investigations", stage: "TEST", env: { region: "test-region" } });
const template = Template.fromStack(stack);
expect(template.toJSON()).toMatchSnapshot();
});
describe('The TranscriptionService stack', () => {
it('matches the snapshot', () => {
const app = new App();
const stack = new TranscriptionService(app, 'TranscriptionService', {
stack: 'investigations',
stage: 'TEST',
env: { region: 'test-region' },
});
const template = Template.fromStack(stack);
expect(template.toJSON()).toMatchSnapshot();
});
});
8 changes: 4 additions & 4 deletions packages/cdk/lib/transcription-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ export class TranscriptionService extends GuStack {
? 'transcribe.gutools.co.uk'
: 'transcribe.code.dev-gutools.co.uk';

const certificate = new GuCertificate(this, {
app: APP_NAME,
domainName: domainName,
});
const certificate = new GuCertificate(this, {
app: APP_NAME,
domainName: domainName,
});

const apiLambda = new GuApiLambda(this, 'transcription-service-api', {
fileName: 'api.zip',
Expand Down

0 comments on commit 93cee99

Please sign in to comment.