You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: .tours/sample-cpp-app.tour
+14-24
Original file line number
Diff line number
Diff line change
@@ -3,12 +3,12 @@
3
3
"title": "Sample C++ App Tour",
4
4
"steps": [
5
5
{
6
-
"file": "src/app/app.cpp",
6
+
"file": "cpp/app/app.cpp",
7
7
"description": "This file defines a sample CCF C++ application. \n\nThe sample application is simple and does not make use of all CCF features (e.g. historical queries). However, it is a great starting point for new CCF developers.",
8
8
"line": 1
9
9
},
10
10
{
11
-
"file": "src/app/app.cpp",
11
+
"file": "cpp/app/app.cpp",
12
12
"description": "Here, the application is instantiated. \n\nThis lets CCF know that the application handlers should be registered and available on each CCF node starting this application. ",
13
13
"line": 120,
14
14
"selection": {
@@ -23,22 +23,22 @@
23
23
}
24
24
},
25
25
{
26
-
"file": "src/app/app.cpp",
26
+
"file": "cpp/app/app.cpp",
27
27
"description": "The application logic is defined in this namespace.\n\nIn particular, it defines:\n1. The types used by the app to record its state in the key-value store.\n2. The API schema for each endpoint.\n3. The HTTP endpoints that contain the business logic of the application and that can be invoked by client requests.",
28
28
"line": 12
29
29
},
30
30
{
31
-
"file": "src/app/app.cpp",
31
+
"file": "cpp/app/app.cpp",
32
32
"description": "The application makes use of a single key-value store map, which maps a `size_t` key to a `std::string` value (e.g. 0 -> \"hello world\").\n\nAll `put` operations on this map are recorded in the CCF ledger. ",
33
33
"line": 15
34
34
},
35
35
{
36
-
"file": "src/app/app.cpp",
36
+
"file": "cpp/app/app.cpp",
37
37
"description": "This defines the name of the `kv::Map` declared above. \n\nNote that the name is *not* prefixed with `public:` so all data written to this map is encrypted in the ledger. If the table was prefixed with `public:`, all writes to the map would be recorded in clear in the ledger, which is useful for auditable public data.",
38
38
"line": 16
39
39
},
40
40
{
41
-
"file": "src/app/app.cpp",
41
+
"file": "cpp/app/app.cpp",
42
42
"description": "CCF applications automatically generate their own OpenAPI specification (accessible via `GET /app/api`).\n\nThese lines specify metadata for the entire application.",
43
43
"line": 37,
44
44
"selection": {
@@ -53,12 +53,12 @@
53
53
}
54
54
},
55
55
{
56
-
"file": "src/app/app.cpp",
56
+
"file": "cpp/app/app.cpp",
57
57
"description": "This is the first HTTP handler defined by the application.\n\nIt lets users record an arbitrary message in the \"records\" private key-value map. The unique key of the message is set by the user as the `id` query parameter. \n\nEach handler is given a single transaction object (`ctx.tx`) that needs to be used to mutate and read from the key-value store.",
58
58
"line": 43
59
59
},
60
60
{
61
-
"file": "src/app/app.cpp",
61
+
"file": "cpp/app/app.cpp",
62
62
"description": "This is the CCF key-value store API to write to a specific map. \n\nA \"handle\" should be first retrieved on the map, using the `rw<Map>(RECORDS)` method on the unique transaction object `ctx.tx`. Then, a value (`in.msg`) can be recorded at a specific key (`id`) using the `put(key, value)` call. \n\nSee https://microsoft.github.io/CCF/release/2.x/build_apps/kv/index.html for the full key-value store API.",
63
63
"line": 66,
64
64
"selection": {
@@ -73,7 +73,7 @@
73
73
}
74
74
},
75
75
{
76
-
"file": "src/app/app.cpp",
76
+
"file": "cpp/app/app.cpp",
77
77
"description": "This installs the `write` handler as an HTTP endpoint.\n\nIt specifies:\n- The URI of the HTTP endpoint. In this case, `POST /app/log`. Note that all CCF application endpoints are prefixed with `/app`.\n- The content type of the HTTP request and response, in this case JSON.\n- The user authentication scheme. In this case, unauthenticated users are allowed to invoke the endpoint. See https://microsoft.github.io/CCF/release/2.x/build_apps/auth/index.html for the list of all supported authentication schemes.\n- The API schema to use in the generated OpenAPI specification.\n- The `id` query parameter at which the user message will be recorded. ",
78
78
"line": 71,
79
79
"selection": {
@@ -88,12 +88,12 @@
88
88
}
89
89
},
90
90
{
91
-
"file": "src/app/app.cpp",
91
+
"file": "cpp/app/app.cpp",
92
92
"description": "This is the second handler for this sample application.\n\nIt is similar to the first handler except that it only reads from the key-value store.",
93
93
"line": 77
94
94
},
95
95
{
96
-
"file": "src/app/app.cpp",
96
+
"file": "cpp/app/app.cpp",
97
97
"description": "Note that `make_read_only_endpoint` is used to specify that the endpoint does not write to the key-value store. \n\nThe endpoint is accessible at `GET /app/log` and as such, does not accept any request body.\n\n",
98
98
"line": 103,
99
99
"selection": {
@@ -108,29 +108,19 @@
108
108
}
109
109
},
110
110
{
111
-
"file": "src/app/app.cpp",
111
+
"file": "cpp/app/app.cpp",
112
112
"description": "That's it! \n\nFor more information on how to build CCF C++ applications, see https://microsoft.github.io/CCF/release/2.x/build_apps/example.html. \n\nFor any questions or bugs, please open an issue on Github: https://github.com/microsoft/CCF/issues/new/choose.",
113
113
"line": 122
114
114
},
115
115
{
116
116
"file": "README.md",
117
117
"description": "You can build the sample application by running the following steps.\n\nMake sure the dependencies have been installed, or that you have checked out this repository in a VSCode development container (see above).",
118
-
"line": 19
118
+
"line": 59
119
119
},
120
120
{
121
121
"file": "README.md",
122
122
"description": "Finally, you can run the application locally using the CCF sandbox script.\n\nYou can then interact with the application with `curl`.",
Template repository for JavaScript and C++ CCF applications.
8
8
9
9
## Quickstart
10
10
11
11
**The quickest way to build and run this sample CCF app is to checkout this repository locally in its development container by clicking:
12
12
[](https://vscode.dev/redirect?url=vscode://ms-vscode-remote.remote-containers/cloneInVolume?url=https://github.com/microsoft/ccf-app-template)**
13
13
14
-
All dependencies will be automatically installed (takes ~2 mins on first checkout) and the app can be quickly [built](#build) and [run](#run) by following [the steps below](#build).
14
+
All dependencies will be automatically installed (takes ~2 mins on first checkout).
15
15
16
+
Alternatively, if your organisation supports it, you can checkout this repository in a Github codespace: [](https://github.com/codespaces/new?hide_repo_select=true&ref=main&repo=496290904&machine=basicLinux32gb&devcontainer_path=.devcontainer.json&location=WestEurope)
16
17
17
-
Also check out the [code tour](#code-tour) to get an overview of the app.
18
+
---
19
+
20
+
## JavaScript
21
+
22
+
CCF apps can be written in JavaScript/TypeScript. This is the quickest way to develop new apps as this does not require any compilation step and the app can be updated on the fly, via [a governance proposal](https://microsoft.github.io/CCF/main/build_apps/js_app_bundle.html#deployment).
23
+
24
+
The JavaScript sample bundle is located in the [`js/`](js/) directory.
25
+
26
+
### Run JS app
27
+
28
+
```bash
29
+
$ /opt/ccf/bin/sandbox.sh --js-app-bundle ./js/
30
+
[12:00:00.000] Virtual mode enabled
31
+
[12:00:00.000] Starting 1 CCF node...
32
+
[12:00:00.000] Started CCF network with the following nodes:
33
+
[12:00:00.000] Node [0] = https://127.0.0.1:8000
34
+
[12:00:00.000] You can now issue business transactions to the libjs_generic application
35
+
[12:00:00.000] Loaded JS application: ./js/
36
+
[12:00:00.000] Keys and certificates have been copied to the common folder: .../ccf-app-template/workspace/sandbox_common
37
+
[12:00:00.000] See https://microsoft.github.io/CCF/main/use_apps/issue_commands.html for more information
38
+
[12:00:00.000] Press Ctrl+C to shutdown the network
Alternatively, if your organisation supports it, you can checkout this repository in a Github Codespace: [](https://github.com/codespaces/new?hide_repo_select=true&ref=main&repo=496290904&machine=basicLinux32gb&devcontainer_path=.devcontainer.json&location=WestEurope)
49
+
### Docker
50
+
51
+
It is possible to build a runtime image of the JavaScript application via docker:
CCF apps can also be written in C++. This offers better performance than JavaScript apps but requires a compilation step and a restart of the CCF node for deployment.
73
+
74
+
The C++ sample app is located in the [`cpp/`](cpp/) directory.
75
+
76
+
Also check out the [code tour](#code-tour) to get an overview of the C++ app.
If this repository is checked out on a bare VM (e.g. [for SGX deployments](https://docs.microsoft.com/en-us/azure/confidential-computing/quick-create-portal)), the dependencies required to build and run the CCF app can be installed as follows:
135
+
If this repository is checked out on a bare VM (e.g. [for SGX deployments](https://docs.microsoft.com/en-us/azure/confidential-computing/quick-create-portal)), the dependencies required to build and run the C++ app can be installed as follows:
@@ -97,4 +146,4 @@ See the [CCF official docs](https://microsoft.github.io/CCF/main/build_apps/inst
97
146
98
147
## Code Tour
99
148
100
-
In VSCode, a [code tour](https://marketplace.visualstudio.com/items?itemName=vsls-contrib.codetour) of this app can be started with: Ctrl + P, `> CodeTour: Start Tour`
149
+
In VSCode, a [code tour](https://marketplace.visualstudio.com/items?itemName=vsls-contrib.codetour) of the C++ app can be started with: Ctrl + P, `> CodeTour: Start Tour`
0 commit comments