-
Notifications
You must be signed in to change notification settings - Fork 217
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
Forum sample rework #2455
Merged
Merged
Forum sample rework #2455
Changes from 26 commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
f8b2d62
forum sample: fix demo script & other cleanup
letmaik da55875
wip, still broken
letmaik 70f76f4
add missing "type": "module"
letmaik f8a7c7d
add missing file extensions in ccf-app pkg
letmaik bc057ba
Merge branch 'letmaik/js-ccf-app-imports' into letmaik/forum-unit-tests
letmaik 97cff31
add .js exts
letmaik ba510f5
extend polyfill test
letmaik e78f4d8
docs
letmaik e33d2d5
wip
letmaik e8b247f
add dev notes
letmaik 624bd37
formatting
letmaik 2062e54
Merge branch 'letmaik/js-ccf-app-imports' into letmaik/forum-unit-tests
letmaik 0c80344
wip
letmaik 8c8320f
.
letmaik ab8b712
Merge branch 'letmaik/forum-sample-fix' into letmaik/forum-unit-tests
letmaik c54f8f9
cleanup
letmaik 360d11c
readme
letmaik 2b99e88
final round
letmaik ea9ec0b
readme
letmaik 37052d9
Merge remote-tracking branch 'origin/main' into letmaik/forum-unit-tests
letmaik 02f4e2b
docs
letmaik cb32bca
Merge remote-tracking branch 'origin/main' into letmaik/forum-unit-tests
letmaik 3601fef
diff
letmaik 4dda02f
fix e2e test
letmaik c712e1c
Merge branch 'main' into letmaik/forum-unit-tests
achamayou 4ace408
Merge branch 'main' into letmaik/forum-unit-tests
achamayou a04a49c
Merge branch 'main' into letmaik/forum-unit-tests
achamayou 287d092
Merge branch 'main' into letmaik/forum-unit-tests
achamayou b95265f
Merge branch 'main' into letmaik/forum-unit-tests
achamayou File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,4 +5,5 @@ build/ | |
.venv_ccf_sandbox/ | ||
.workspace_ccf/ | ||
*_opinions.csv | ||
*.jwt | ||
*.jwt | ||
*.pem |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,68 @@ | ||
# Confidential Forum sample app | ||
|
||
NOTE: This sample is a work-in-progress. | ||
See also the [TypeScript Application using tsoa](https://microsoft.github.io/CCF/main/build_apps/js_app_tsoa.html) documentation page for further details on how this sample is built using the tsoa framework. | ||
|
||
Install dependencies: | ||
## Getting started | ||
|
||
When running this sample against a CCF release, open `package.json` and replace the `file:` reference of `ccf-app` with a reference to a published version (adjust the version number accordingly): | ||
|
||
``` | ||
"@microsoft/ccf-app": "~1.0.0", | ||
``` | ||
|
||
Now you can continue with installing all dependencies: | ||
|
||
```sh | ||
npm install | ||
``` | ||
|
||
To run the demo and end-to-end tests, define the following environment variable: | ||
|
||
```sh | ||
export CCF_BINARY_DIR=/opt/ccf-x.y.z/bin | ||
``` | ||
|
||
If not defined, it assumes you built CCF from source and defaults to `CCF_BINARY_DIR=<repo_root>/build`. | ||
|
||
## Demo | ||
|
||
Start the sandbox: | ||
|
||
```sh | ||
npm start | ||
``` | ||
|
||
Open your browser at https://127.0.0.1:8000/app/site | ||
(Use `VERBOSE=1 npm start` for verbose output) | ||
|
||
Generate opinions, user identities and submit: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These edits are really a great addition |
||
Open your browser at https://127.0.0.1:8000/app/site and create the sample polls and opinions. | ||
The statistics will still be empty since the opinion threshold has not been reached yet. | ||
|
||
Now, generate more opinions, user identities and submit: | ||
|
||
```sh | ||
python3.8 test/demo/generate-opinions.py test/demo/polls.csv 9 | ||
npm run ts test/demo/generate-jwts.ts . 9 | ||
npm run ts test/demo/submit-opinions.ts . | ||
mkdir demo/data | ||
python3.8 demo/generate-opinions.py demo/data demo/polls.csv 9 | ||
npm run ts demo/generate-jwts.ts demo/data 9 | ||
npm run ts demo/submit-opinions.ts demo/data | ||
``` | ||
|
||
Return to the website and view the statistics which should be visible now. | ||
|
||
## Tests & debugging | ||
|
||
Run tests: | ||
|
||
```sh | ||
npm test | ||
# or: | ||
npm run test:unit # unit tests | ||
npm run test:e2e # end-to-end tests | ||
``` | ||
|
||
Unit tests run outside CCF and end-to-end tests run against a single CCF sandbox node. | ||
|
||
The unit tests make use of the [`ccf-app` polyfill](https://microsoft.github.io/CCF/main/js/ccf-app/modules/polyfill.html) and can be easily debugged in VS Code. | ||
The simplest workflow is using the [JavaScript Debug Terminal](https://code.visualstudio.com/docs/nodejs/nodejs-debugging#_javascript-debug-terminal) in VS Code. Set a break point and run `npm run test:unit` inside the JavaScript Debug Terminal. The debugger will attach and stop automatically. | ||
|
||
Debugging of JavaScript code running in CCF is currently not possible. | ||
However, all uncaught exceptions and output from `console.log()` are dumped to the node's log files. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const MINIMUM_OPINION_THRESHOLD = 10; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are CCF/enclave apps called services? If not, I would suggest to change services into e.g. enclaveApp. Services is confusing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This term comes from tsoa's docs: https://tsoa-community.github.io/docs/getting-started.html#defining-our-first-model. I've seen this before outside tsoa, another term would be
*Manager
but I'd like to stick to tsoa's docs here. The whole npm app runs inside CCF, not just the services.