Add basic text editor
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
|
||||
import superagent from 'superagent';
|
||||
import safe from 'safetydance';
|
||||
|
||||
export function createDirectoryModel(origin, accessToken, appId) {
|
||||
return {
|
||||
name: 'DirectoryModel',
|
||||
async listFiles(path) {
|
||||
const [error, result] = await safe(superagent.get(`${origin}/api/v1/apps/${appId}/files/${path}`).query({ access_token: accessToken }));
|
||||
if (error) {
|
||||
console.error('Failed to list files', error);
|
||||
return [];
|
||||
}
|
||||
|
||||
return result.body.entries;
|
||||
},
|
||||
async rename(oldPath, newPath) {
|
||||
|
||||
},
|
||||
async getFile(path) {
|
||||
const [error, result] = await safe(superagent.get(`${origin}/api/v1/apps/${appId}/files/${path}`).query({ access_token: accessToken }));
|
||||
if (error) {
|
||||
console.error('Failed to get file', error);
|
||||
return null;
|
||||
}
|
||||
|
||||
console.log(result.body);
|
||||
|
||||
return result.body;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export default {
|
||||
createDirectoryModel
|
||||
};
|
||||
Reference in New Issue
Block a user