8 Commits

Author SHA1 Message Date
msramalho
854d744806 cleaning UI links to localhost only 2022-02-16 12:27:20 +01:00
msramalho
0155830cad making cors customizable 2022-02-16 12:27:05 +01:00
msramalho
96558a0cf7 updating example config 2022-02-16 12:26:37 +01:00
msramalho
b3d6d08289 updating package 2022-02-16 12:26:25 +01:00
msramalho
315adf0653 updated example config 2022-02-16 12:15:21 +01:00
msramalho
b19664ae33 adding config.js.example 2022-02-16 12:09:40 +01:00
msramalho
4e748a156a ignoring config.js 2022-02-16 12:09:18 +01:00
msramalho
14d6fe6db2 deleted config.js 2022-02-16 12:09:11 +01:00
9 changed files with 83 additions and 56 deletions

1
.gitignore vendored
View File

@@ -15,3 +15,4 @@ tags.lock
tags.temp
src/config.js
src/local.config.js
src/config.js

View File

@@ -59,6 +59,11 @@ Clone the repository to your local:
git clone https://www.github.com/forensic-architecture/datasheet-server
```
Copy [src/example.config.js](src/example.config.js) into `src/config.js` and modify
```
cp src/example.config.js src/config.js
```
Follow the steps in the [configuration](#configuration) section of this
document.

78
package-lock.json generated
View File

@@ -15,7 +15,7 @@
"dotenv": "^6.1.0",
"express": "^4.13.3",
"express-graphql": "^0.6.12",
"express-handlebars": "^5.3.1",
"express-handlebars": "^4.0.4",
"googleapis": "^39.1.0",
"graphql": "^0.13.2",
"morgan": "^1.8.0",
@@ -1288,7 +1288,7 @@
"version": "2.6.11",
"resolved": "https://registry.npmjs.org/core-js/-/core-js-2.6.11.tgz",
"integrity": "sha512-5wjnpaT/3dV+XB4borEsnAYQchn00XSgTAWKDkEqv+K8KevjbzmofK6hfJ9TZIlpj2N0xQpazy7PiRQiWHqzWg==",
"deprecated": "core-js@<3.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Please, upgrade your dependencies to the actual version of core-js.",
"deprecated": "core-js@<3.4 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Please, upgrade your dependencies to the actual version of core-js.",
"dev": true,
"hasInstallScript": true
},
@@ -1499,7 +1499,7 @@
"version": "2.1.8",
"resolved": "https://registry.npmjs.org/chokidar/-/chokidar-2.1.8.tgz",
"integrity": "sha512-ZmZUazfOzf0Nve7duiCKD23PFSCs4JPoYyccjUFF3aQkQadqBhfzhjkwBH2mNOG9cTBwhamM37EIsIkZw3nRgg==",
"deprecated": "Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies.",
"deprecated": "Chokidar 2 does not receive security updates since 2019. Upgrade to chokidar 3 with 15x fewer dependencies",
"dev": true,
"optional": true,
"dependencies": {
@@ -1934,7 +1934,7 @@
"version": "2.1.8",
"resolved": "https://registry.npmjs.org/chokidar/-/chokidar-2.1.8.tgz",
"integrity": "sha512-ZmZUazfOzf0Nve7duiCKD23PFSCs4JPoYyccjUFF3aQkQadqBhfzhjkwBH2mNOG9cTBwhamM37EIsIkZw3nRgg==",
"deprecated": "Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies.",
"deprecated": "Chokidar 2 does not receive security updates since 2019. Upgrade to chokidar 3 with 15x fewer dependencies",
"dev": true,
"dependencies": {
"anymatch": "^2.0.0",
@@ -2081,7 +2081,7 @@
"version": "2.6.11",
"resolved": "https://registry.npmjs.org/core-js/-/core-js-2.6.11.tgz",
"integrity": "sha512-5wjnpaT/3dV+XB4borEsnAYQchn00XSgTAWKDkEqv+K8KevjbzmofK6hfJ9TZIlpj2N0xQpazy7PiRQiWHqzWg==",
"deprecated": "core-js@<3.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Please, upgrade your dependencies to the actual version of core-js.",
"deprecated": "core-js@<3.4 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Please, upgrade your dependencies to the actual version of core-js.",
"dev": true,
"hasInstallScript": true
},
@@ -2392,7 +2392,7 @@
"version": "2.6.11",
"resolved": "https://registry.npmjs.org/core-js/-/core-js-2.6.11.tgz",
"integrity": "sha512-5wjnpaT/3dV+XB4borEsnAYQchn00XSgTAWKDkEqv+K8KevjbzmofK6hfJ9TZIlpj2N0xQpazy7PiRQiWHqzWg==",
"deprecated": "core-js@<3.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Please, upgrade your dependencies to the actual version of core-js.",
"deprecated": "core-js@<3.4 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Please, upgrade your dependencies to the actual version of core-js.",
"dev": true,
"hasInstallScript": true
},
@@ -3469,7 +3469,7 @@
"version": "2.6.11",
"resolved": "https://registry.npmjs.org/core-js/-/core-js-2.6.11.tgz",
"integrity": "sha512-5wjnpaT/3dV+XB4borEsnAYQchn00XSgTAWKDkEqv+K8KevjbzmofK6hfJ9TZIlpj2N0xQpazy7PiRQiWHqzWg==",
"deprecated": "core-js@<3.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Please, upgrade your dependencies to the actual version of core-js.",
"deprecated": "core-js@<3.4 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Please, upgrade your dependencies to the actual version of core-js.",
"dev": true,
"hasInstallScript": true
},
@@ -4162,7 +4162,7 @@
"version": "2.6.11",
"resolved": "https://registry.npmjs.org/core-js/-/core-js-2.6.11.tgz",
"integrity": "sha512-5wjnpaT/3dV+XB4borEsnAYQchn00XSgTAWKDkEqv+K8KevjbzmofK6hfJ9TZIlpj2N0xQpazy7PiRQiWHqzWg==",
"deprecated": "core-js@<3.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Please, upgrade your dependencies to the actual version of core-js.",
"deprecated": "core-js@<3.4 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Please, upgrade your dependencies to the actual version of core-js.",
"dev": true,
"hasInstallScript": true
},
@@ -4365,16 +4365,16 @@
}
},
"node_modules/express-handlebars": {
"version": "5.3.1",
"resolved": "https://registry.npmjs.org/express-handlebars/-/express-handlebars-5.3.1.tgz",
"integrity": "sha512-mHpf3PAYysgo6M2yl/r0p5ui/gHwVa7vLBgA3ht8HlNxRGcwXSAGOwKAtAEVdHs4j7FDb5ZGsAJoA8nFaogbGw==",
"version": "4.0.6",
"resolved": "https://registry.npmjs.org/express-handlebars/-/express-handlebars-4.0.6.tgz",
"integrity": "sha512-SWwmp4ERN/hPySdRnQYiNcJP/LHAeTz1qq0MXQ2ztZiMC6sKw1WathtVWWY+AUPkjV6eDmQXqybJQwnUsoI9vw==",
"dependencies": {
"glob": "^7.1.6",
"graceful-fs": "^4.2.6",
"handlebars": "^4.7.7"
"graceful-fs": "^4.2.4",
"handlebars": "^4.7.6"
},
"engines": {
"node": ">=v10.24.1"
"node": ">=0.10"
}
},
"node_modules/extend": {
@@ -5037,9 +5037,9 @@
}
},
"node_modules/graceful-fs": {
"version": "4.2.9",
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.9.tgz",
"integrity": "sha512-NtNxqUcXgpW2iMrfqSfR73Glt39K+BLwWsPs94yR63v45T0Wbej7eRmL5cWfwEgqXnmjQp3zaJTshdRW/qC2ZQ=="
"version": "4.2.4",
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.4.tgz",
"integrity": "sha512-WjKPNJF79dtJAVniUlGGWHYGz2jWxT6VhN/4m1NdkbZ2nOsEF+cI1Edgql5zCRhs/VsQYRvrXctxktVXZUkixw=="
},
"node_modules/graphql": {
"version": "0.13.2",
@@ -5084,9 +5084,9 @@
}
},
"node_modules/handlebars": {
"version": "4.7.7",
"resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.7.7.tgz",
"integrity": "sha512-aAcXm5OAfE/8IXkcZvCepKU3VzW1/39Fb5ZuqMtgI/hT8X2YgoMvBY5dLhq/cpOvw7Lk1nK/UF71aLG/ZnVYRA==",
"version": "4.7.6",
"resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.7.6.tgz",
"integrity": "sha512-1f2BACcBfiwAfStCKZNrUCgqNZkGsAT7UM3kkYtXuLo0KnaVfjKOyf7PRzB6++aK9STyT1Pd2ZCPe3EGOXleXA==",
"dependencies": {
"minimist": "^1.2.5",
"neo-async": "^2.6.0",
@@ -6649,7 +6649,7 @@
"version": "2.1.8",
"resolved": "https://registry.npmjs.org/chokidar/-/chokidar-2.1.8.tgz",
"integrity": "sha512-ZmZUazfOzf0Nve7duiCKD23PFSCs4JPoYyccjUFF3aQkQadqBhfzhjkwBH2mNOG9cTBwhamM37EIsIkZw3nRgg==",
"deprecated": "Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies.",
"deprecated": "Chokidar 2 does not receive security updates since 2019. Upgrade to chokidar 3 with 15x fewer dependencies",
"dev": true,
"dependencies": {
"anymatch": "^2.0.0",
@@ -8388,6 +8388,7 @@
"version": "0.5.3",
"resolved": "https://registry.npmjs.org/source-map-resolve/-/source-map-resolve-0.5.3.tgz",
"integrity": "sha512-Htz+RnsXWk5+P2slx5Jh3Q66vhQj1Cllm0zvnaY98+NFx+Dv2CF/f5O/t8x+KaNdrdIAsruNzoh/KpialbqAnw==",
"deprecated": "See https://github.com/lydell/source-map-resolve#deprecated",
"dev": true,
"dependencies": {
"atob": "^2.1.2",
@@ -8411,6 +8412,7 @@
"version": "0.4.0",
"resolved": "https://registry.npmjs.org/source-map-url/-/source-map-url-0.4.0.tgz",
"integrity": "sha1-PpNdfd1zYxuXZZlW1VEo6HtQhKM=",
"deprecated": "See https://github.com/lydell/source-map-url#deprecated",
"dev": true
},
"node_modules/spdx-correct": {
@@ -8977,9 +8979,9 @@
}
},
"node_modules/uglify-js": {
"version": "3.15.1",
"resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.15.1.tgz",
"integrity": "sha512-FAGKF12fWdkpvNJZENacOH0e/83eG6JyVQyanIJaBXCN1J11TUQv1T1/z8S+Z0CG0ZPk1nPcreF/c7lrTd0TEQ==",
"version": "3.11.5",
"resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.11.5.tgz",
"integrity": "sha512-btvv/baMqe7HxP7zJSF7Uc16h1mSfuuSplT0/qdjxseesDU+yYzH33eHBH+eMdeRXwujXspaCTooWHQVVBh09w==",
"optional": true,
"bin": {
"uglifyjs": "bin/uglifyjs"
@@ -12911,13 +12913,13 @@
}
},
"express-handlebars": {
"version": "5.3.1",
"resolved": "https://registry.npmjs.org/express-handlebars/-/express-handlebars-5.3.1.tgz",
"integrity": "sha512-mHpf3PAYysgo6M2yl/r0p5ui/gHwVa7vLBgA3ht8HlNxRGcwXSAGOwKAtAEVdHs4j7FDb5ZGsAJoA8nFaogbGw==",
"version": "4.0.6",
"resolved": "https://registry.npmjs.org/express-handlebars/-/express-handlebars-4.0.6.tgz",
"integrity": "sha512-SWwmp4ERN/hPySdRnQYiNcJP/LHAeTz1qq0MXQ2ztZiMC6sKw1WathtVWWY+AUPkjV6eDmQXqybJQwnUsoI9vw==",
"requires": {
"glob": "^7.1.6",
"graceful-fs": "^4.2.6",
"handlebars": "^4.7.7"
"graceful-fs": "^4.2.4",
"handlebars": "^4.7.6"
}
},
"extend": {
@@ -13461,9 +13463,9 @@
}
},
"graceful-fs": {
"version": "4.2.9",
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.9.tgz",
"integrity": "sha512-NtNxqUcXgpW2iMrfqSfR73Glt39K+BLwWsPs94yR63v45T0Wbej7eRmL5cWfwEgqXnmjQp3zaJTshdRW/qC2ZQ=="
"version": "4.2.4",
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.4.tgz",
"integrity": "sha512-WjKPNJF79dtJAVniUlGGWHYGz2jWxT6VhN/4m1NdkbZ2nOsEF+cI1Edgql5zCRhs/VsQYRvrXctxktVXZUkixw=="
},
"graphql": {
"version": "0.13.2",
@@ -13498,9 +13500,9 @@
}
},
"handlebars": {
"version": "4.7.7",
"resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.7.7.tgz",
"integrity": "sha512-aAcXm5OAfE/8IXkcZvCepKU3VzW1/39Fb5ZuqMtgI/hT8X2YgoMvBY5dLhq/cpOvw7Lk1nK/UF71aLG/ZnVYRA==",
"version": "4.7.6",
"resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.7.6.tgz",
"integrity": "sha512-1f2BACcBfiwAfStCKZNrUCgqNZkGsAT7UM3kkYtXuLo0KnaVfjKOyf7PRzB6++aK9STyT1Pd2ZCPe3EGOXleXA==",
"requires": {
"minimist": "^1.2.5",
"neo-async": "^2.6.0",
@@ -16539,9 +16541,9 @@
}
},
"uglify-js": {
"version": "3.15.1",
"resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.15.1.tgz",
"integrity": "sha512-FAGKF12fWdkpvNJZENacOH0e/83eG6JyVQyanIJaBXCN1J11TUQv1T1/z8S+Z0CG0ZPk1nPcreF/c7lrTd0TEQ==",
"version": "3.11.5",
"resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.11.5.tgz",
"integrity": "sha512-btvv/baMqe7HxP7zJSF7Uc16h1mSfuuSplT0/qdjxseesDU+yYzH33eHBH+eMdeRXwujXspaCTooWHQVVBh09w==",
"optional": true
},
"uid2": {

View File

@@ -25,7 +25,7 @@
"dotenv": "^6.1.0",
"express": "^4.13.3",
"express-graphql": "^0.6.12",
"express-handlebars": "^5.3.1",
"express-handlebars": "^4.0.4",
"googleapis": "^39.1.0",
"graphql": "^0.13.2",
"morgan": "^1.8.0",

View File

@@ -1,12 +0,0 @@
import { timemap } from './lib'
export default {
gsheets: [],
xlsx: [
{
name: 'timemap_data',
path: 'data/timemap_data.xlsx',
tabs: timemap.default
}
]
}

19
src/example.config.js Normal file
View File

@@ -0,0 +1,19 @@
import { timemap } from './lib'
export default {
gsheets: [],
xlsx: [
{
name: 'timemap_data',
path: 'data/timemap_data.xlsx',
tabs: timemap.default
}
],
cors: {
active: false,
corsOptions: { // meaningless unless active=true
origin: 'http://example.com',
optionsSuccessStatus: 200 // some legacy browsers (IE11, various SmartTVs) choke on 204
}
}
}

View File

@@ -7,6 +7,14 @@ import api from './api'
import dotenv from 'dotenv'
const hbs = require('express-handlebars')
let configJS
try {
configJS = require('./local.config.js').default
} catch (_) {
configJS = require('./config.js').default
}
dotenv.config()
let app = express()
@@ -17,13 +25,17 @@ app.engine('.hbs', hbs({
}))
app.set('view engine', '.hbs')
// enable cross origin requests explicitly in development
// enable cross origin requests explicitly in development OR if active in prod
const cors = require('cors')
if (process.env.NODE_ENV === 'development') {
const cors = require('cors')
console.log('Enabling CORS in development...')
app.use(cors())
} else if (configJS.cors.active === true) {
console.log('Enabling CORS in from config.js in prod...')
app.use(cors(configJS.cors.corsOptions))
}
const config = process.env
initialize(controller => {

View File

@@ -3,7 +3,7 @@ import fetch from 'node-fetch'
import childProcess from 'child_process'
const SERVER_LAUNCH_WAIT_TIME = 10 * 1000
const SERVER_ROOT = 'http://localhost:4040'
const SERVER_ROOT = ''
let serverProc = null
let serverExited = false
function checkStatus (res) {

View File

@@ -8,7 +8,7 @@
<div class="bp-source">{{ source }}</div>
</div>
{{#each urls}}
<div><a target="_blank" href="http://localhost:4040{{ this }}">{{ this }}</a></div>
<div><a target="_blank" href="{{ this }}">{{ this }}</a></div>
{{/each}}
</div>
{{ else }}
@@ -16,7 +16,7 @@
{{/each}}
</div>
<a class="bp-update-container" target="_blank" href="http://localhost:4040/api/update">
<a class="bp-update-container" target="_blank" href="/api/update">
<div class="bp-button">Update</div>
</div>