mirror of
https://github.com/scratchfoundation/scratch-www.git
synced 2024-11-23 07:38:07 -05:00
Add ScratchStorage subclass for getting project JSON
This commit is contained in:
parent
df0db1b2c3
commit
ca91294b31
1 changed files with 26 additions and 0 deletions
26
src/lib/storage.js
Normal file
26
src/lib/storage.js
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
import ScratchStorage from 'scratch-storage';
|
||||||
|
|
||||||
|
const PROJECT_SERVER = 'https://projects.scratch.mit.edu';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wrapper for ScratchStorage which adds default web sources.
|
||||||
|
* @todo make this more configurable
|
||||||
|
*/
|
||||||
|
class Storage extends ScratchStorage {
|
||||||
|
constructor () {
|
||||||
|
super();
|
||||||
|
this.addWebSource( // https://github.com/babel/babel/issues/7022
|
||||||
|
[this.AssetType.Project],
|
||||||
|
projectAsset => {
|
||||||
|
const [projectId, revision] = projectAsset.assetId.split('.');
|
||||||
|
return revision ?
|
||||||
|
`${PROJECT_SERVER}/internalapi/project/${projectId}/get/${revision}` :
|
||||||
|
`${PROJECT_SERVER}/internalapi/project/${projectId}/get/`;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const storage = new Storage();
|
||||||
|
|
||||||
|
export default storage;
|
Loading…
Reference in a new issue