buckets: fixes data/get endpoint

This commit is contained in:
@wwwjim 2020-08-11 00:05:42 -07:00
parent 36fcc38bdc
commit aa271efdcb
2 changed files with 43 additions and 10 deletions

View File

@ -59,7 +59,6 @@ export default class ApplicationPage extends React.Component {
window.addEventListener("dragleave", this._handleDragLeave);
window.addEventListener("dragover", this._handleDragOver);
window.addEventListener("drop", this._handleDrop);
window.addEventListener("online", this._handleOnlineStatus);
window.addEventListener("offline", this._handleOnlineStatus);
}
@ -254,7 +253,8 @@ export default class ApplicationPage extends React.Component {
_handleDeleteYourself = async () => {
// TODO(jim):
// Put this somewhere better for messages.
const message = "Do you really want to delete your account? It will be permanently removed";
const message =
"Do you really want to delete your account? It will be permanently removed";
if (!window.confirm(message)) {
return false;
}
@ -450,8 +450,12 @@ export default class ApplicationPage extends React.Component {
<WebsitePrototypeWrapper
title="Slate: sign in"
description="Sign in to your Slate account to manage your assets."
url="https://slate.host/_">
<SceneSignIn onAuthenticate={this._handleAuthenticate} onNavigateTo={this._handleNavigateTo} />
url="https://slate.host/_"
>
<SceneSignIn
onAuthenticate={this._handleAuthenticate}
onNavigateTo={this._handleNavigateTo}
/>
</WebsitePrototypeWrapper>
);
}
@ -528,12 +532,17 @@ export default class ApplicationPage extends React.Component {
return (
<React.Fragment>
<WebsitePrototypeWrapper title={title} description={description} url={url}>
<WebsitePrototypeWrapper
title={title}
description={description}
url={url}
>
<ApplicationLayout
navigation={navigationElement}
header={headerElement}
sidebar={sidebarElement}
onDismissSidebar={this._handleDismissSidebar}>
onDismissSidebar={this._handleDismissSidebar}
>
{scene}
</ApplicationLayout>
<System.GlobalCarousel />

View File

@ -1,18 +1,42 @@
import * as Environment from "~/node_common/environment";
import * as MW from "~/node_common/middleware";
import * as Constants from "~/node_common/constants";
import * as Data from "~/node_common/data";
import * as Utilities from "~/node_common/utilities";
import FS from "fs-extra";
const initCORS = MW.init(MW.CORS);
const initAuth = MW.init(MW.RequireCookieAuthentication);
const TEXTILE_KEY_INFO = {
key: Environment.TEXTILE_HUB_KEY,
secret: Environment.TEXTILE_HUB_SECRET,
};
export default async (req, res) => {
initCORS(req, res);
initAuth(req, res);
const { buckets } = await Utilities.getBucketAPI();
const id = Utilities.getIdFromCookie(req);
if (!id) {
return res
.status(500)
.json({ decorator: "SERVER_DELETE_SLATE", error: true });
}
const user = await Data.getUserById({
id,
});
const {
buckets,
bucketKey,
bucketName,
} = await Utilities.getBucketAPIFromUserToken(user.data.tokens.api);
const r = await buckets.list();
const items = await buckets.listIpfsPath(r[0].path);
return res.status(200).send({
decorator: "SERVER_GET",
data: items.itemsList,
});
};