mirror of
https://github.com/bellingcat/datasheet-server.git
synced 2026-06-10 12:28:34 +03:00
add index prototype for model layer
as the model layer only speaks URL, it returns a list of the URLs that it supports
This commit is contained in:
@@ -3,9 +3,18 @@ import copy from '../copy/en'
|
||||
|
||||
const STORAGE_DIRNAME = 'temp'
|
||||
|
||||
function partsFromFilename (fname) {
|
||||
const body = fname.slice(0, -5)
|
||||
return body.split('__')
|
||||
}
|
||||
|
||||
class StoreJson {
|
||||
index () {
|
||||
return Promise.resolve({})
|
||||
return Promise.resolve()
|
||||
.then(() => fs.readdir(STORAGE_DIRNAME))
|
||||
.then(files => files.filter(f => f.match(/.*\.json$/)))
|
||||
.then(jsons => jsons.map(partsFromFilename))
|
||||
.then(parts => parts.map(p => `${p[0]}/${p[1]}/${p[2]}`))
|
||||
}
|
||||
|
||||
save (url, data) {
|
||||
|
||||
Reference in New Issue
Block a user