Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Production deploy #2553

Merged
merged 3 commits into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ AWS_SECRET_KEY=👻

# User-uploaded S3 files require token-based access (token is used internally and shared with BOPS; local and pull request environments use the staging token)
FILE_API_KEY=👻
FILE_API_KEY_NEXUS=👻

# Editor/Preview
EDITOR_URL_EXT=http://localhost:3000
Expand Down
1 change: 1 addition & 0 deletions api.planx.uk/.env.test.example
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ AWS_ACCESS_KEY=👻
AWS_SECRET_KEY=👻

FILE_API_KEY=👻
FILE_API_KEY_NEXUS=👻

# Editor
EDITOR_URL_EXT=example.com
Expand Down
7 changes: 3 additions & 4 deletions api.planx.uk/modules/auth/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,9 @@ export const useSendEmailAuth: RequestHandler = (req, res, next): void => {
*/
assert(process.env.FILE_API_KEY, "Missing environment variable 'FILE_API_KEY'");
export const useFilePermission: RequestHandler = (req, _res, next): void => {
const isAuthenticated = isEqual(
req.headers["api-key"] as string,
process.env.FILE_API_KEY!,
);
const isAuthenticated =
isEqual(req.headers["api-key"] as string, process.env.FILE_API_KEY!) ||
isEqual(req.headers["api-key"] as string, process.env.FILE_API_KEY_NEXUS!);
if (!isAuthenticated) return next({ status: 401, message: "Unauthorised" });
return next();
};
Expand Down
1 change: 1 addition & 0 deletions api.planx.uk/modules/gis/service/digitalLand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export interface LocalAuthorityMetadata {
}

const localAuthorityMetadata: Record<string, LocalAuthorityMetadata> = {
birmingham: require("./local_authorities/metadata/birmingham"),
buckinghamshire: require("./local_authorities/metadata/buckinghamshire"),
camden: require("./local_authorities/metadata/camden"),
canterbury: require("./local_authorities/metadata/canterbury"),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
LAD20CD: E08000025
LAD20NM: Birmingham
LAD20NMW:
FID:

https://www.planning.data.gov.uk/entity/?dataset=article-4-direction-area&geometry_curie=statistical-geography%3AE08000025&entry_date_day=&entry_date_month=&entry_date_year=
https://docs.google.com/spreadsheets/d/19t4DKDvyWix1Vf5huuQPVf9L8e6jcq1W/edit#gid=207440632
*/

import { LocalAuthorityMetadata } from "../../digitalLand";

const planningConstraints: LocalAuthorityMetadata["planningConstraints"] = {
article4: {
// Planx granular values link to Digital Land entity.reference
records: {
"article4.birmingham.austinVillage": "30",
"article4.birmingham.bournvilleVillage": "8",
"article4.birmingham.cityWideHMO": "36",
"article4.birmingham.edgbaston": "15",
"article4.birmingham.greenfieldRoad": "32",
"article4.birmingham.highStSuttonColdfield": "13",
"article4.birmingham.moorPool": "7",
"article4.birmingham.moseleyVillage": "20",
"article4.birmingham.oldYardley": "5",
"article4.birmingham.sellyPark": "34",
"article4.birmingham.sellyParkAvenues": "33",
"article4.birmingham.stAgnes": "22",
},
},
};

export { planningConstraints };
1 change: 0 additions & 1 deletion api.planx.uk/modules/send/utils/exportZip.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ jest.mock("fs", () => ({
existsSync: () => true,
unlinkSync: () => undefined,
createWriteStream: () => undefined,
writeFileSync: () => undefined,
rmSync: () => undefined,
}));

Expand Down
10 changes: 3 additions & 7 deletions api.planx.uk/modules/send/utils/exportZip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,13 +193,9 @@ export class ExportZip {
const s3Key = url.split("/").slice(-2).join("/");
const decodedS3Key = decodeURIComponent(s3Key);
const { body } = await getFileFromS3(decodedS3Key);
if (!body) {
throw new Error("file not found");
}
const filePath = path.join(this.tmpDir, name);
fs.writeFileSync(filePath, body as Buffer);
this.zip.addLocalFile(filePath);
fs.unlinkSync(filePath);
if (!body) throw new Error("file not found");

this.zip.addFile(name, body as Buffer);
}

toBuffer(): Buffer {
Expand Down
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ services:
GOVUK_NOTIFY_API_KEY: ${GOVUK_NOTIFY_API_KEY}
HASURA_PLANX_API_KEY: ${HASURA_PLANX_API_KEY}
FILE_API_KEY: ${FILE_API_KEY}
FILE_API_KEY_NEXUS: ${FILE_API_KEY_NEXUS}
SLACK_WEBHOOK_URL: ${SLACK_WEBHOOK_URL}
ORDNANCE_SURVEY_API_KEY: ${ORDNANCE_SURVEY_API_KEY}
MINIO_PORT: ${MINIO_PORT}
Expand Down
2 changes: 2 additions & 0 deletions infrastructure/application/Pulumi.staging.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ config:
secure: AAABAPZz/bzFCZEZd+jzPpYP4HXAOLYQmLGf2YLQE2YPfMBUtDC83KCo2l2DJ4AL4OKL+jFFx8wrrJc6DDwXJQ==
application:file-api-key:
secure: AAABAN0LjLOgxCkr5ZqQLn6FkZPcrPlvNG4fbNZ02W2qC1VVYVee/3aToZQuXuokVwnIPNbbe2w=
application:file-api-key-nexus:
secure: AAABAJFgaBoTWNmZyXDkGRngwU8KpOt6CeBLxGBgBG0JFMsKK7rWT39TsjJ9pL1wZaBoT0YZhCg=
application:google-client-id: 987324067365-vpsk3kgeq5n32ihjn760ihf8l7m5rhh8.apps.googleusercontent.com
application:google-client-secret:
secure: AAABAGQuqQDU4S+vR+cQaFoa6xAeWU9clVaNonQ/dq0R8Dke+o0y7ALOmYMy4fOX4Pa6HiZl85npU/cbwy8HdMYaiA==
Expand Down
4 changes: 4 additions & 0 deletions infrastructure/application/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,10 @@ export = async () => {
name: "FILE_API_KEY",
value: config.requireSecret("file-api-key"),
},
{
name: "FILE_API_KEY_NEXUS",
value: config.requireSecret("file-api-key-nexus"),
},
{
name: "GOOGLE_CLIENT_ID",
value: config.require("google-client-id"),
Expand Down
Loading