mirror of
https://github.com/bellingcat/datasheet-server.git
synced 2026-06-11 04:48:32 +03:00
Merge pull request #14 from forensic-architecture/topic/with-example
Topic/with example
This commit is contained in:
@@ -32,7 +32,9 @@ Datasheet server makes resources from a spreadsheet available as a structured AP
|
||||
## [Overview](#overview)
|
||||
Datasheet server is a Node server developed at [Forensic Architecture](https://forensic-architecture.org) to make data that is being dynamically modified by researchers concurrently consumable for programmatic applications as an API. We use spreadsheets extensively to keep track of information during [our investigations](http://forensic-architecture.org/cases), and we often want to make this data available via structured queries to make it available in a frontend web application, a game engine, or another use case.
|
||||
|
||||
Querying data directly from spreadsheets is brittle, as it relies on the maintenance of a rigid structure in the sheets at all times. By putting Datasheet Server as a proxy that sits in between source sheets and their consumers, it is possible to dynamically modify sheets without breaking applications. A data admin can then use Datasheet Server to ensure that applications always receive eligible data, without foregoing the spreadsheets as sources of truth.
|
||||
Querying data directly from spreadsheets is brittle, as it relies on the maintenance of a rigid structure in the sheets at all times. By putting Datasheet Server as a proxy that sits in between source sheets and their consumers, it is possible to dynamically modify sheets without breaking applications. A data admin can then use Datasheet Server to ensure that applications always receive eligible data, without foregoing the spreadsheets as sources of truth.
|
||||
|
||||
To see how to get a local instance of datasheet server running in practice, see [this wiki](https://github.com/forensic-architecture/timemap/wiki/Setting-up-a-local-instance-of-Timemap) explaining how to use it to feed data from a Google Sheet to a local instance of [Timemap](https://github.com/forensic-architecture/timemap).
|
||||
|
||||
### Design Concepts
|
||||
The codebase currently only supports Google Sheets as a source, and a REST-like format as a query language. It is designed, however, with extensibility in mind.
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
"description": "Starter project for an ES6 RESTful Express API",
|
||||
"main": "dist",
|
||||
"scripts": {
|
||||
"dev": "nodemon -w src --exec \"babel-node src\"",
|
||||
"build": "npx babel src -d dist",
|
||||
"dev": "NODE_ENV=development nodemon -w src --exec \"babel-node src\"",
|
||||
"build": "NODE_ENV=production npx babel src -d dist",
|
||||
"start": "node dist",
|
||||
"lint": "standard \"src/**/*.js\" \"test/**/*/js\"",
|
||||
"test-watch": "ava --watch",
|
||||
@@ -20,7 +20,7 @@
|
||||
"dependencies": {
|
||||
"body-parser": "^1.13.3",
|
||||
"compression": "^1.5.2",
|
||||
"cors": "^2.7.1",
|
||||
"cors": "^2.8.5",
|
||||
"express": "^4.13.3",
|
||||
"express-graphql": "^0.6.12",
|
||||
"googleapis": "^32.0.0",
|
||||
|
||||
@@ -20,9 +20,8 @@ export default ({ config, controller }) => {
|
||||
.retrieveFrag(source, tab, resource, frag)
|
||||
.then(data => res.json(data))
|
||||
.catch(err =>
|
||||
res.json({
|
||||
error: err.message
|
||||
})
|
||||
res.status(err.status || 501)
|
||||
.send()
|
||||
)
|
||||
})
|
||||
|
||||
@@ -31,9 +30,8 @@ export default ({ config, controller }) => {
|
||||
.retrieve(req.params.source, req.params.tab, req.params.resource)
|
||||
.then(data => res.json(data))
|
||||
.catch(err =>
|
||||
res.json({
|
||||
error: err.message
|
||||
})
|
||||
res.status(err.status || 501)
|
||||
.send()
|
||||
)
|
||||
})
|
||||
|
||||
|
||||
@@ -3,14 +3,17 @@ import BP from './lib/blueprinters'
|
||||
export default {
|
||||
port: 4040,
|
||||
googleSheets: {
|
||||
email: 'project-name@reliable-baptist-23338.iam.gserviceaccount.com',
|
||||
privateKey: 'SOME_PRIVATE_KEY',
|
||||
email: 'SOME_SERVICE_ACCOUNT_EMAIL',
|
||||
privateKey: 'SOME_SERVICE_ACCOUNT_PRIVATE_KEY',
|
||||
sheets: [
|
||||
{
|
||||
name: 'example',
|
||||
id: '1s-vfBR8Uy-B-TLO_C5Ozw4z-L0E3hdP8ohMV761ouRI',
|
||||
id: '1UC7DkCFeUXHfpUxUGruExwFbP4pqVBdJLOKfo6wDDGk',
|
||||
tabs: {
|
||||
objects: [BP.byRow]
|
||||
export_events: [BP.byId, BP.byRow],
|
||||
export_categories: [BP.byGroup, BP.byRow],
|
||||
export_sites: BP.byRow,
|
||||
export_tags: BP.byTree
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
@@ -8,6 +8,13 @@ import config from './config'
|
||||
let app = express()
|
||||
app.server = http.createServer(app)
|
||||
|
||||
// enable cross origin requests explicitly in development
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
const cors = require('cors')
|
||||
console.log('Enabling CORS in development...')
|
||||
app.use(cors())
|
||||
}
|
||||
|
||||
initialize(controller => {
|
||||
app.use(
|
||||
middleware({
|
||||
|
||||
@@ -1267,9 +1267,9 @@ core-util-is@~1.0.0:
|
||||
version "1.0.2"
|
||||
resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7"
|
||||
|
||||
cors@^2.7.1:
|
||||
version "2.8.4"
|
||||
resolved "https://registry.yarnpkg.com/cors/-/cors-2.8.4.tgz#2bd381f2eb201020105cd50ea59da63090694686"
|
||||
cors@^2.8.5:
|
||||
version "2.8.5"
|
||||
resolved "https://registry.yarnpkg.com/cors/-/cors-2.8.5.tgz#eac11da51592dd86b9f06f6e7ac293b3df875d29"
|
||||
dependencies:
|
||||
object-assign "^4"
|
||||
vary "^1"
|
||||
|
||||
Reference in New Issue
Block a user