Skip to content
Open
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
2 changes: 1 addition & 1 deletion .node-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
24.11.0
24.13.0
129 changes: 129 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
[workspace]
members = ["examples/todo", "examples/nns_proxy", "examples/icp_features"]
members = [
"examples/http",
"examples/icp_features",
"examples/nns_proxy",
"examples/todo",
]
resolver = "2"
11 changes: 10 additions & 1 deletion bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 13 additions & 1 deletion dfx.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"version": 1,
"dfx": "0.29.1",
"dfx": "0.30.2",
"output_env_file": ".env",
"networks": {
"local": {
Expand Down Expand Up @@ -113,6 +113,18 @@
},
"gzip": true,
"optimize": "cycles"
},
"http": {
"type": "rust",
"candid": "examples/http/http.did",
"package": "http-canister",
"frontend": {},
"declarations": {
"bindings": ["js", "ts"],
"output": "examples/http/declarations"
},
"gzip": true,
"optimize": "cycles"
}
}
}
1 change: 1 addition & 0 deletions docs/src/content/docs/guides/more-examples.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ but `@dfinity/pic` can be used with JavaScript and any other testing runner, suc
- The [NNS Proxy](https://github.com/dfinity/pic-js/tree/main/examples/nns_proxy) example demonstrates how to work with an NNS state directory.
- [Google Search](https://github.com/dfinity/pic-js/tree/main/examples/google_search) example demonstrates how to mock HTTPS Outcalls.
- [ICP Features](https://github.com/dfinity/pic-js/tree/main/examples/icp_features) example demonstrates how to work with PocketIC's ICP features.
- [HTTP](https://github.com/dfinity/pic-js/tree/main/examples/http) example demonstrates how to use "live" mode with an HTTP canister.
4 changes: 3 additions & 1 deletion examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ but `@dfinity/pic` can be used with JavaScript and any other testing runner, suc
- [Clock](./clock/README.md)
This example demonstrates how to work with the replica's system time, canister timers as well as checking for canister existence and cycle management.
- [Todo](./todo/README.md)
This example demonstrates how to work with more complex canisters, identities, canister upgrades, and stable memory management.
This example demonstrates how to work with more complex canisters, identities, canister upgrades, and stable memory management. It also shows how to use "live" mode with agent-js (in contrast to the pic-js actor).
- [Multicanister](./multicanister/README.md)
This example demonstrates how to work with multiple canisters and multiple subnets.
- [NNS Proxy](./nns_proxy/README.md)
This example demonstrates how to work with an NNS state directory.
- [Google Search](./google_search/README.md)
This example demonstrates how to mock HTTPS Outcalls.
- [HTTP](./http/README.md)
This example demonstrates how to use "live" mode with an HTTP canister.
13 changes: 13 additions & 0 deletions examples/http/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[package]
name = "http-canister"
version = "0.1.0"
edition = "2024"

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

[dependencies]
candid = "0.10"
ic-cdk = "0.18"
ic-http-certification = "3"
ic-asset-certification = "3"
15 changes: 15 additions & 0 deletions examples/http/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# HTTP

This example demonstrates how to use "live" mode with an HTTP canister.

Build the HTTP canister:

```shell
bun build:http
```

Run the HTTP tests:

```shell
bun test:http
```
18 changes: 18 additions & 0 deletions examples/http/http.did
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
type HttpRequest = record {
url : text;
method : text;
body : blob;
headers : vec record { text; text };
certificate_version : opt nat16;
};

type HttpResponse = record {
body : blob;
headers : vec record { text; text };
upgrade : opt bool;
status_code : nat16;
};

service : {
http_request : (HttpRequest) -> (HttpResponse) query;
};
11 changes: 11 additions & 0 deletions examples/http/src/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>HTTP Canister</title>
</head>
<body>
<h1>Hello, World!</h1>
</body>
</html>
Loading