Skip to content

feat: demo http outcall with Dog API #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,491 changes: 1,491 additions & 0 deletions Cargo.lock

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[workspace]
members = [
"src/satellite"
]
resolver = "2"
12 changes: 12 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
services:
juno-satellite:
image: junobuild/satellite:latest
ports:
- 5987:5987
volumes:
- juno_satellite:/juno/.juno
- ./juno.dev.config.js:/juno/juno.dev.config.js
- ./target/deploy:/juno/target/deploy/

volumes:
juno_satellite:
28 changes: 28 additions & 0 deletions juno.dev.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { defineDevConfig } from "@junobuild/config";

/** @type {import('@junobuild/config').JunoDevConfig} */
export default defineDevConfig(() => ({
satellite: {
collections: {
db: [
{
collection: "notes",
read: "managed",
write: "managed",
memory: "storage",
mutablePermissions: false
},
],
storage: [
{
collection: "images",
read: "managed",
write: "managed",
memory: "storage",
mutablePermissions: false
}
],
},
controllers: [],
},
}));
7 changes: 3 additions & 4 deletions src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ import { Modal } from "./components/Modal";
import { Table } from "./components/Table";

function App() {
// TODO: STEP_2_INITIALIZATION
// useEffect(() => {
// (async () => await initSatellite())();
// }, []);
useEffect(() => {
(async () => await initSatellite())();
}, []);

return (
<>
Expand Down
4 changes: 1 addition & 3 deletions src/components/Auth.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ export const Auth = ({ children }) => {
const [user, setUser] = useState(undefined);

useEffect(() => {
// TODO: STEP_4_AUTH_SUBSCRIBE
const sub = () => undefined;
// const sub = authSubscribe((user) => setUser(user));
const sub = authSubscribe((user) => setUser(user));

return () => sub();
}, []);
Expand Down
5 changes: 1 addition & 4 deletions src/components/Login.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,5 @@ import { signIn } from "@junobuild/core";
import { Button } from "./Button";

export const Login = () => {
//TODO: STEP_3_AUTH_SIGN_IN
// onClick={signIn}

return <Button>Sign in</Button>;
return <Button onClick={signIn}>Sign in</Button>;
};
4 changes: 1 addition & 3 deletions src/components/Logout.jsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import { signOut } from "@junobuild/core";

export const Logout = () => {
//TODO: STEP_5_AUTH_SIGN_OUT
// onClick={signOut}

return (
<button
onClick={signOut}
type="button"
className="dark:text-white flex items-center gap-2 mt-24 hover:text-lavender-blue-500 active:text-lavender-blue-400"
>
Expand Down
35 changes: 15 additions & 20 deletions src/components/Modal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,32 +38,27 @@ export const Modal = () => {
if (file !== undefined) {
const filename = `${user.key}-${file.name}`;

// TODO: STEP_8_UPLOAD_FILE
const downloadUrl = undefined;
// const { downloadUrl } = await uploadFile({
// collection: "images",
// data: file,
// filename,
// });
const { downloadUrl } = await uploadFile({
collection: "images",
data: file,
filename,
});

url = downloadUrl;
}

const key = nanoid();

// TODO: STEP_6_SET_DOC
// await setDoc({
// collection: "notes",
// doc: {
// key,
// data: {
// text: inputText,
// },
// },
// });

// TODO: STEP_9_ADD_REFERENCE
// ...(url !== undefined && { url }),
await setDoc({
collection: "notes",
doc: {
key,
data: {
text: inputText,
...(url !== undefined && { url }),
},
},
});

setShowModal(false);

Expand Down
8 changes: 3 additions & 5 deletions src/components/Table.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,9 @@ export const Table = () => {
}, []);

const list = async () => {
// TODO: STEP_7_LIST_DOCS
const items = [];
// const { items } = await listDocs({
// collection: "notes",
// });
const { items } = await listDocs({
collection: "notes",
});

setItems(items);
};
Expand Down
19 changes: 19 additions & 0 deletions src/satellite/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[package]
name = "satellite"
version = "0.0.1"
edition = "2021"

[lib]
crate-type = ["cdylib"]

[dependencies]
candid = "0.10.2"
ic-cdk = "0.12.1"
ic-cdk-macros = "0.8.1"
serde = "1.0.190"
serde_cbor = "0.11.2"
serde_json = "1.0.113"
junobuild-satellite = "0.0.17"
junobuild-macros = "0.0.2"
junobuild-utils = "0.0.1"

Loading