Merge branch 'develop' into feature/view_edit_refactor

This commit is contained in:
Tom Russell 2019-09-17 21:25:50 +01:00 committed by GitHub
commit a022d90e59
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 142 additions and 37 deletions

69
app/package-lock.json generated
View File

@ -2875,9 +2875,9 @@
"dev": true "dev": true
}, },
"buffer-writer": { "buffer-writer": {
"version": "1.0.1", "version": "2.0.0",
"resolved": "https://registry.npmjs.org/buffer-writer/-/buffer-writer-1.0.1.tgz", "resolved": "https://registry.npmjs.org/buffer-writer/-/buffer-writer-2.0.0.tgz",
"integrity": "sha1-Iqk2kB4wKa/NdUfrRIfOtpejvwg=" "integrity": "sha512-a7ZpuTZU1TRtnwyCNW3I5dc0wWNC3VR9S++Ewyk2HHZdrO3CQJqSpd+95Us590V6AL7JqUAH2IwZ/398PmNFgw=="
}, },
"buffer-xor": { "buffer-xor": {
"version": "1.0.3", "version": "1.0.3",
@ -3439,9 +3439,9 @@
"dev": true "dev": true
}, },
"connect-pg-simple": { "connect-pg-simple": {
"version": "5.0.0", "version": "6.0.1",
"resolved": "https://registry.npmjs.org/connect-pg-simple/-/connect-pg-simple-5.0.0.tgz", "resolved": "https://registry.npmjs.org/connect-pg-simple/-/connect-pg-simple-6.0.1.tgz",
"integrity": "sha512-WZ7xkN+qe5bbDLgZ1L9GxnSbr155cJHmfNRzVR5hBvqio7Pg/vuH7Cf8lPUSFClQjtybYSejUqyO54sYt4cg+w==", "integrity": "sha512-zW5AOtRNOLcXxphSmQ+oYj0snlLs1Je3u5K2NWyF7WhMVoPvnQXraK2wzS8f7qLwhMcmYukah2ymu0Gdxf7Qsg==",
"requires": { "requires": {
"pg": "^7.4.3" "pg": "^7.4.3"
} }
@ -9484,7 +9484,7 @@
}, },
"minimist": { "minimist": {
"version": "0.0.8", "version": "0.0.8",
"resolved": "http://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz",
"integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=" "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0="
}, },
"minipass": { "minipass": {
@ -10236,9 +10236,9 @@
"dev": true "dev": true
}, },
"packet-reader": { "packet-reader": {
"version": "0.3.1", "version": "1.0.0",
"resolved": "https://registry.npmjs.org/packet-reader/-/packet-reader-0.3.1.tgz", "resolved": "https://registry.npmjs.org/packet-reader/-/packet-reader-1.0.0.tgz",
"integrity": "sha1-zWLmCvjX/qinBexP+ZCHHEaHHyc=" "integrity": "sha512-HAKu/fG3HpHFO0AA8WE8q2g+gBJaZ9MG7fcKk+IJPLTGAD6Psw4443l+9DGRbOIh3/aXr7Phy0TjilYivJo5XQ=="
}, },
"pako": { "pako": {
"version": "1.0.10", "version": "1.0.10",
@ -10410,15 +10410,15 @@
"dev": true "dev": true
}, },
"pg": { "pg": {
"version": "7.4.3", "version": "7.12.1",
"resolved": "https://registry.npmjs.org/pg/-/pg-7.4.3.tgz", "resolved": "https://registry.npmjs.org/pg/-/pg-7.12.1.tgz",
"integrity": "sha1-97b5P1NA7MJZavu5ShPj1rYJg0s=", "integrity": "sha512-l1UuyfEvoswYfcUe6k+JaxiN+5vkOgYcVSbSuw3FvdLqDbaoa2RJo1zfJKfPsSYPFVERd4GHvX3s2PjG1asSDA==",
"requires": { "requires": {
"buffer-writer": "1.0.1", "buffer-writer": "2.0.0",
"packet-reader": "0.3.1", "packet-reader": "1.0.0",
"pg-connection-string": "0.1.3", "pg-connection-string": "0.1.3",
"pg-pool": "~2.0.3", "pg-pool": "^2.0.4",
"pg-types": "~1.12.1", "pg-types": "^2.1.0",
"pgpass": "1.x", "pgpass": "1.x",
"semver": "4.3.2" "semver": "4.3.2"
}, },
@ -10446,9 +10446,9 @@
"integrity": "sha512-8aZ9xdx7Pe/ppFYVOqvU5KgmM6ttXjaBlsl9Y8yzrUH4xSNVucJKKOwm4Y4H+LCvzZGjZIm4Rkf2Ajt5ixtkBQ==" "integrity": "sha512-8aZ9xdx7Pe/ppFYVOqvU5KgmM6ttXjaBlsl9Y8yzrUH4xSNVucJKKOwm4Y4H+LCvzZGjZIm4Rkf2Ajt5ixtkBQ=="
}, },
"pg-pool": { "pg-pool": {
"version": "2.0.3", "version": "2.0.7",
"resolved": "https://registry.npmjs.org/pg-pool/-/pg-pool-2.0.3.tgz", "resolved": "https://registry.npmjs.org/pg-pool/-/pg-pool-2.0.7.tgz",
"integrity": "sha1-wCIDLIlJ8xKk+R+2QJzgQHa+Mlc=" "integrity": "sha512-UiJyO5B9zZpu32GSlP0tXy8J2NsJ9EFGFfz5v6PSbdz/1hBLX1rNiiy5+mAm5iJJYwfCv4A0EBcQLGWwjbpzZw=="
}, },
"pg-promise": { "pg-promise": {
"version": "8.7.5", "version": "8.7.5",
@ -10521,13 +10521,14 @@
} }
}, },
"pg-types": { "pg-types": {
"version": "1.12.1", "version": "2.2.0",
"resolved": "https://registry.npmjs.org/pg-types/-/pg-types-1.12.1.tgz", "resolved": "https://registry.npmjs.org/pg-types/-/pg-types-2.2.0.tgz",
"integrity": "sha1-1kCH45A7WP+q0nnnWVxSIIoUw9I=", "integrity": "sha512-qTAAlrEsl8s4OiEQY69wDvcMIdQN6wdz5ojQiOy6YRMuynxenON0O5oCpJI6lshc6scgAY8qvJ2On/p+CXY0GA==",
"requires": { "requires": {
"postgres-array": "~1.0.0", "pg-int8": "1.0.1",
"postgres-array": "~2.0.0",
"postgres-bytea": "~1.0.0", "postgres-bytea": "~1.0.0",
"postgres-date": "~1.0.0", "postgres-date": "~1.0.4",
"postgres-interval": "^1.1.0" "postgres-interval": "^1.1.0"
} }
}, },
@ -13144,9 +13145,9 @@
} }
}, },
"postgres-array": { "postgres-array": {
"version": "1.0.2", "version": "2.0.0",
"resolved": "https://registry.npmjs.org/postgres-array/-/postgres-array-1.0.2.tgz", "resolved": "https://registry.npmjs.org/postgres-array/-/postgres-array-2.0.0.tgz",
"integrity": "sha1-jgsy6wO/d6XAp4UeBEHBaaJWojg=" "integrity": "sha512-VpZrUqU5A69eQyW2c5CA1jtLecCsN2U/bD6VilrFDWq5+5UIEVO7nazS3TEcHf1zuPYO/sqGvUvW62g86RXZuA=="
}, },
"postgres-bytea": { "postgres-bytea": {
"version": "1.0.0", "version": "1.0.0",
@ -13154,9 +13155,9 @@
"integrity": "sha1-AntTPAqokOJtFy1Hz5zOzFIazTU=" "integrity": "sha1-AntTPAqokOJtFy1Hz5zOzFIazTU="
}, },
"postgres-date": { "postgres-date": {
"version": "1.0.3", "version": "1.0.4",
"resolved": "https://registry.npmjs.org/postgres-date/-/postgres-date-1.0.3.tgz", "resolved": "https://registry.npmjs.org/postgres-date/-/postgres-date-1.0.4.tgz",
"integrity": "sha1-4tiXAu/bJY/52c7g/pG9BpdSV6g=" "integrity": "sha512-bESRvKVuTrjoBluEcpv2346+6kgB7UlnqWZsnbnCccTNq/pqfj1j6oBaN5+b/NrDXepYUT/HKadqv3iS9lJuVA=="
}, },
"postgres-interval": { "postgres-interval": {
"version": "1.1.2", "version": "1.1.2",
@ -13612,7 +13613,7 @@
"dependencies": { "dependencies": {
"minimist": { "minimist": {
"version": "1.2.0", "version": "1.2.0",
"resolved": "http://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz",
"integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=" "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ="
} }
} }
@ -17021,7 +17022,7 @@
"dependencies": { "dependencies": {
"minimist": { "minimist": {
"version": "1.2.0", "version": "1.2.0",
"resolved": "http://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz",
"integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=",
"dev": true "dev": true
} }
@ -17862,7 +17863,7 @@
}, },
"wrap-ansi": { "wrap-ansi": {
"version": "2.1.0", "version": "2.1.0",
"resolved": "http://registry.npmjs.org/wrap-ansi/-/wrap-ansi-2.1.0.tgz", "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-2.1.0.tgz",
"integrity": "sha1-2Pw9KE3QV5T+hJc8rs3Rz4JP3YU=", "integrity": "sha1-2Pw9KE3QV5T+hJc8rs3Rz4JP3YU=",
"dev": true, "dev": true,
"requires": { "requires": {

View File

@ -18,7 +18,7 @@
"@mapbox/sphericalmercator": "^1.1.0", "@mapbox/sphericalmercator": "^1.1.0",
"body-parser": "^1.19.0", "body-parser": "^1.19.0",
"bootstrap": "^4.3.1", "bootstrap": "^4.3.1",
"connect-pg-simple": "^5.0.0", "connect-pg-simple": "^6.0.1",
"express": "^4.17.1", "express": "^4.17.1",
"express-session": "^1.16.2", "express-session": "^1.16.2",
"leaflet": "^1.5.1", "leaflet": "^1.5.1",

View File

@ -72,8 +72,7 @@ async function resetPassword(req: express.Request, res: express.Response) {
if(req.body.email != undefined) { if(req.body.email != undefined) {
// first stage: send reset token to email address // first stage: send reset token to email address
// this relies on the API being on the same hostname as the frontend const origin = getWebAppOrigin();
const { origin } = new URL(req.protocol + '://' + req.headers.host);
await passwordResetService.sendPasswordResetToken(req.body.email, origin); await passwordResetService.sendPasswordResetToken(req.body.email, origin);
return res.status(202).send({ success: true }); return res.status(202).send({ success: true });
@ -96,6 +95,14 @@ async function resetPassword(req: express.Request, res: express.Response) {
} }
} }
function getWebAppOrigin() : string {
const origin = process.env.WEBAPP_ORIGIN;
if (origin == undefined) {
throw new Error('WEBAPP_ORIGIN not defined');
}
return origin;
}
export default { export default {
createUser, createUser,
getCurrentUser, getCurrentUser,

View File

@ -25,6 +25,7 @@ module.exports = {
MAIL_SERVER_PORT: 587, MAIL_SERVER_PORT: 587,
MAIL_SERVER_USER: "mail_username", MAIL_SERVER_USER: "mail_username",
MAIL_SERVER_PASSWORD: "longrandompassword", MAIL_SERVER_PASSWORD: "longrandompassword",
WEBAPP_ORIGIN: "http://localhost:3000",
} }
} }
] ]

View File

@ -22,6 +22,7 @@ module.exports = {
MAIL_SERVER_PORT: 587, MAIL_SERVER_PORT: 587,
MAIL_SERVER_USER: "mail_username", MAIL_SERVER_USER: "mail_username",
MAIL_SERVER_PASSWORD: "longrandompassword", MAIL_SERVER_PASSWORD: "longrandompassword",
WEBAPP_ORIGIN: "https://beta.colouring.london",
} }
} }
] ]

View File

@ -0,0 +1,28 @@
-- Remove sustainability fields, update in paralell with adding new fields
-- BREEAM rating
ALTER TABLE buildings DROP COLUMN IF EXISTS sust_breeam_rating;
-- BREEAM date
ALTER TABLE buildings DROP COLUMN IF EXISTS sust_breeam_date;
-- DEC (display energy certifcate, only applies to non domestic buildings)
ALTER TABLE buildings DROP COLUMN IF EXISTS sust_dec;
-- DEC date
ALTER TABLE buildings DROP COLUMN IF EXISTS sust_dec_date;
--DEC certifcate lmk key, this would be lmkkey, no online lookup but can scrape through API. Numeric (25)
ALTER TABLE buildings DROP COLUMN IF EXISTS sust_dec_lmkey;
-- Aggregate EPC rating (Estimated) for a building, derived from inidividual certificates
ALTER TABLE buildings DROP COLUMN IF EXISTS sust_aggregate_estimate_epc;
-- Last significant retrofit date YYYY
ALTER TABLE buildings DROP COLUMN IF EXISTS sust_retrofit_date;
--How much embodied carbon? One for ML, tons CO2 int
ALTER TABLE buildings DROP COLUMN IF EXISTS sust_embodied_carbon;
--Life expectancy of the building, via further analysis
ALTER TABLE buildings DROP COLUMN IF EXISTS sust_life_expectancy;
--Average lifespan of typology based on statistical analysis of similar stock
ALTER TABLE buildings DROP COLUMN IF EXISTS sust_lifespan_average;

View File

@ -0,0 +1,67 @@
-- BREEAM ratings, one of:
-- - Outstanding
-- - Excellent
-- - Very good
-- - Good
-- - Pass
-- - Unclassified
CREATE TYPE sust_breeam_rating
AS ENUM ('Outstanding',
'Excellent',
'Very good',
'Good',
'Pass',
'Unclassified');
ALTER TABLE buildings
ADD COLUMN IF NOT EXISTS sust_breeam_rating sust_breeam_rating DEFAULT 'Unclassified';
-- Date of BREEAM
ALTER TABLE buildings
ADD COLUMN IF NOT EXISTS sust_breeam_date smallint;
-- DEC (display energy certifcate, only applies to non domestic buildings)
-- A - G
CREATE TYPE sust_dec
AS ENUM ('A',
'B',
'C',
'D',
'E',
'F',
'G');
-- Date of DEC YYYY
ALTER TABLE buildings
ADD COLUMN IF NOT EXISTS sust_dec_date smallint;
ALTER TABLE buildings
ADD COLUMN IF NOT EXISTS sust_dec sust_dec;
-- Aggregate EPC rating (Estimated) for a building, derived from inidividual certificates
-- A+ - G
CREATE TYPE sust_aggregate_estimate_epc
AS ENUM ('A',
'B',
'C',
'D',
'E',
'F',
'G');
ALTER TABLE buildings
ADD COLUMN IF NOT EXISTS sust_aggregate_estimate_epc sust_aggregate_estimate_epc;
-- Last significant retrofit date YYYY
ALTER TABLE buildings
ADD COLUMN IF NOT EXISTS sust_retrofit_date smallint;
--How much embodied carbon? One for ML, tons CO2 int
ALTER TABLE buildings ADD COLUMN IF NOT EXISTS sust_embodied_carbon numeric(7,2);
--Life expectancy of the building, via further analysis
ALTER TABLE buildings ADD COLUMN IF NOT EXISTS sust_life_expectancy smallint;
--Average lifespan of typology based on statistical analysis of similar stock
ALTER TABLE buildings ADD COLUMN IF NOTE EXISTS sust_lifespan_average smallint;