mirror of
https://github.com/bellingcat/datasheet-server.git
synced 2026-06-11 12:58:32 +03:00
better saving schema for model layer
previously, the model layer had a confused interface, where it saved via blueprints, but loaded via a URL logic. This commit modifies Fetchers to save consistently via a URL
This commit is contained in:
@@ -1,20 +1,19 @@
|
||||
import fs from 'mz/fs'
|
||||
import { fmtSheetTitle } from '../lib/util'
|
||||
import copy from '../copy/en'
|
||||
|
||||
const STORAGE_DIRNAME = 'temp'
|
||||
|
||||
class StoreJson {
|
||||
save (bp) {
|
||||
return Promise.all(
|
||||
Object.keys(bp.routes).map(route =>
|
||||
fs.writeFile(
|
||||
`${STORAGE_DIRNAME}/${fmtSheetTitle(
|
||||
bp.sheet.name
|
||||
)}__${fmtSheetTitle(bp.name)}__${route}.json`,
|
||||
JSON.stringify(bp.routes[route].data)
|
||||
)
|
||||
)
|
||||
index () {
|
||||
return Promise.resolve({})
|
||||
}
|
||||
|
||||
save (url, data) {
|
||||
const parts = url.split('/')
|
||||
|
||||
return fs.writeFile(
|
||||
`${STORAGE_DIRNAME}/${parts[0]}__${parts[1]}__${parts[2]}.json`,
|
||||
JSON.stringify(data)
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user