15 Commits

Author SHA1 Message Date
dependabot[bot]
a1b77cba73 Bump node-fetch from 2.6.1 to 3.1.1
Bumps [node-fetch](https://github.com/node-fetch/node-fetch) from 2.6.1 to 3.1.1.
- [Release notes](https://github.com/node-fetch/node-fetch/releases)
- [Changelog](https://github.com/node-fetch/node-fetch/blob/main/docs/CHANGELOG.md)
- [Commits](https://github.com/node-fetch/node-fetch/compare/v2.6.1...v3.1.1)

---
updated-dependencies:
- dependency-name: node-fetch
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-01-22 12:42:29 +00:00
Lachlan Kermode
a6337e9cba Use npm in Dockerfile rather than yarn 2022-01-15 01:48:55 -05:00
Lachlan Kermode
18b20356b5 Update source data to point to live URLs 2021-10-22 12:15:11 -04:00
Lachlan Kermode
75cb1a43cf Fix/package lock; better example data (#79)
* Update package-lock.json

* Update caniuse-lite

* Update XLSX data to be more descriptive of timemap's features
2021-10-21 17:36:19 +02:00
Ebrahem Farooqui
71a8687003 Merge pull request #74 from forensic-architecture/feature/add-shapes-filter-panel
Adding export_shapes endpoint
2021-05-24 22:47:57 -07:00
Ebrahem Farooqui
63d168a964 changing push branch to dev 2021-05-24 22:18:28 -07:00
Ebrahem Farooqui
4d310270d5 changing push branch temp 2021-05-24 22:17:10 -07:00
efarooqui
a6cc9491c6 Adding export_shapes endpoint 2021-05-24 16:10:34 -07:00
efarooqui
0ee207dc75 Linting fixes 2021-04-30 19:34:29 -07:00
efarooqui
7e97c5c227 Minor comment to trigger job 2021-04-30 19:31:16 -07:00
efarooqui
978d572660 Minor comment to trigger job 2021-04-14 19:58:55 -07:00
efarooqui
8bd5f38ac4 Error logging for gsheet fetch 2021-04-14 18:07:48 -07:00
efarooqui
6ab37ccb70 Extraneous comment added to trigger job 2021-04-14 16:35:27 -07:00
efarooqui
4976bfd985 Merge branch 'develop' of https://www.github.com/forensic-architecture/datasheet-server into develop 2021-04-14 16:12:46 -07:00
efarooqui
d713a15879 Adding comment to trigger job 2021-04-14 16:11:40 -07:00
12 changed files with 9657 additions and 100 deletions

View File

@@ -4,12 +4,12 @@ LABEL authors="Lachlan Kermode <lk@forensic-architecture.org>"
# Install app dependencies
COPY package.json /www/package.json
RUN cd /www; yarn
RUN cd /www; npm install
# Copy app source
COPY . /www
WORKDIR /www
RUN yarn build
RUN npm run build
RUN mkdir -p data
# set your port
@@ -17,4 +17,4 @@ ENV PORT 4040
EXPOSE 4040
# start command as per package.json
CMD ["yarn", "start"]
CMD ["npm", "start"]

Binary file not shown.

9664
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -3,7 +3,6 @@
"version": "0.3.0",
"description": "Starter project for an ES6 RESTful Express API",
"main": "dist",
"type": "module",
"scripts": {
"dev": "env NODE_ENV=development nodemon -w src --exec \"babel-node src\"",
"build": "env NODE_ENV=production npx babel src -d dist",
@@ -27,12 +26,11 @@
"express": "^4.13.3",
"express-graphql": "^0.6.12",
"express-handlebars": "^4.0.4",
"file-system": "^2.2.2",
"googleapis": "^39.1.0",
"graphql": "^0.13.2",
"morgan": "^1.8.0",
"mz": "^2.7.0",
"node-fetch": "^2.6.1",
"node-fetch": "^3.1.1",
"object-hash": "^1.3.0",
"ramda": "^0.25.0",
"resource-router-middleware": "^0.6.0",

View File

@@ -4,7 +4,6 @@ import copy from '../copy/en'
export default ({ config, controller }) => {
let api = Router()
const fileDest = config.EXPORT_FILE_DEST || null
api.get('/', (req, res) => {
res.json({
@@ -23,20 +22,6 @@ export default ({ config, controller }) => {
})
})
api.get('/export', (req, res) => {
controller
.retrieveAll(fileDest)
.then(msg =>
res.json({
success: msg
})
)
.catch(err =>
res.status(404)
.send({ error: err.message, err })
)
})
api.get('/update', (req, res) => {
controller
.update()
@@ -45,10 +30,10 @@ export default ({ config, controller }) => {
success: msg
})
)
.catch(err =>
.catch(err => {
res.status(404)
.send({ error: err.message, err })
)
})
})
api.get('/:sheet/:tab/:resource/:frag', (req, res) => {

View File

@@ -1,10 +1,6 @@
export default {
errors: {
update: 'The server could not update. Check your API credentials and internet connection and try again.',
export: {
fileMissing: 'The server could not export. Check that you provided a file path to export to and try again.',
writeFailed: 'The server could not export the data to the file. There is an issue with the data format'
},
onlySheet: 'You cannot query a sheet directly. The URL needs to be in the format /:sheet/:tab/:resource.',
onlyTab: 'You cannot query a tab directly. The URL needs to be in the format /:sheet/:tab/:resource.',
noSheet: sheet => `The sheet ${sheet} is not available in this server.`,
@@ -13,7 +9,6 @@ export default {
modelLayer: prts => `Something went wrong at the model layer`
},
success: {
update: 'All sheets updated',
export: dest => `All resources exported to the file: ${dest}`
update: 'All sheets updated'
}
}

View File

@@ -7,6 +7,7 @@ function prefixedTabs (prefix, cfg) {
[`${prf('events')}export_events`]: BP.deeprows,
[`${prf('associations')}export_associations`]: BP.deeprows,
[`${prf('sources')}export_sources`]: BP.deepids,
[`${prf('shapes')}export_shapes`]: BP.deeprows,
[`${prf('sites')}export_sites`]: BP.rows
}
}

View File

@@ -1,8 +1,7 @@
import copy from '../copy/en'
import { exportToFile } from '../lib/util'
/**
* Controller
* Controller class
*
*/
class Controller {
@@ -40,37 +39,6 @@ class Controller {
})
}
// Controller function to retrieve all blueprints and export to user defined file location
retrieveAll (fileDest) {
if (!fileDest) return Promise.reject(new Error(copy.errors.export.fileMissing))
const indexedData = {}
const urls = []
const bps = this.blueprints()
return Promise.all(
bps.map(bp => {
const resource = Object.keys(bp.resources)[0]
urls.push(bp.urls[0])
return this.retrieve(bp.sheet.name, bp.name, resource)
})
).then(async results => {
if (results.every(res => res)) {
urls.forEach((item, idx) => {
indexedData[item] = results[idx]
})
try {
const message = await exportToFile(fileDest, indexedData)
return message
} catch (e) {
return Promise.reject(e)
}
} else {
throw new Error(copy.errors.export.writeFailed)
}
})
}
retrieve (sheet, tab, resource) {
if (this._sheetExists(sheet)) {
const fetcher = this.fetchers[sheet]

View File

@@ -217,7 +217,10 @@ class GsheetFetcher extends Fetcher {
})
.then(this._buildBlueprintsAsync())
.then(() => true)
.catch(() => false)
.catch((err) => {
console.log(`Error fetching gsheets: ${err.message} `)
return false
})
}
}

View File

@@ -1,6 +1,4 @@
import R from 'ramda'
import { promises as fs } from 'file-system'
import copy from '../copy/en'
/* eslint-disable */
String.prototype.replaceAll = function (search, replacement) {
@@ -16,18 +14,6 @@ function camelize (str) {
})
}
export async function exportToFile (fileDest, data) {
const stringifiedData = JSON.stringify(data, null, 2)
const filePath = `${fileDest}/export.json`
try {
await fs.writeFile(filePath, stringifiedData)
return copy.success.export(filePath)
} catch (err) {
throw new Error(copy.errors.export.writeFailed)
}
}
export const fmtObj = R.curry(
(
columnNames,

View File

@@ -19,7 +19,6 @@ class StoreJson {
save (url, data) {
const parts = url.split('/')
return fs.writeFile(
`${STORAGE_DIRNAME}/${parts[0]}__${parts[1]}__${parts[2]}.json`,
JSON.stringify(data)

View File

@@ -12,6 +12,8 @@ const egInput1 = [
[4, 5, 6]
]
// Test default blueprint exports
// Smoke tests
test('defaultBlueprint exports', t => {
const expected = {
sheet: {