-
Notifications
You must be signed in to change notification settings - Fork 0
feat: Workshop UI portal — dynamic module browser with language filtering #3
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
Copilot
wants to merge
2
commits into
main
Choose a base branch
from
copilot/build-new-ui-for-workshop
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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 hidden or 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,2 @@ | ||
| PORT=3000 | ||
| # MODULES_DIR=/absolute/path/to/modules |
This file contains hidden or 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,3 @@ | ||
| node_modules/ | ||
| coverage/ | ||
| .env |
This file contains hidden or 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,147 @@ | ||
| # Portal Setup | ||
|
|
||
| ## Quick Start | ||
|
|
||
| Run the single setup command from the **repository root**: | ||
|
|
||
| ```bash | ||
| node setup-portal.js && cd portal && npm install && npm test | ||
| ``` | ||
|
|
||
| That command: | ||
| 1. Creates the `portal/` directory tree with all source files | ||
| 2. Installs Node.js dependencies | ||
| 3. Runs the full test suite (unit + integration) | ||
|
|
||
| ## What `setup-portal.js` Creates | ||
|
|
||
| ``` | ||
| portal/ | ||
| ├── package.json | ||
| ├── jest.config.js | ||
| ├── .gitignore | ||
| ├── .env.example | ||
| ├── src/ | ||
| │ ├── server.js Entry point | ||
| │ ├── app.js Express app factory | ||
| │ ├── config/config.js PORT + MODULES_DIR config | ||
| │ ├── errors/errors.js Custom error classes | ||
| │ ├── services/moduleService.js Business logic | ||
| │ ├── utils/markdownParser.js Markdown → sanitized HTML | ||
| │ ├── routes/ | ||
| │ │ ├── moduleRoutes.js GET /api/modules, GET /api/modules/:id | ||
| │ │ └── healthRoutes.js GET /api/health | ||
| │ └── middleware/ | ||
| │ ├── errorHandler.js Domain error → HTTP mapping | ||
| │ ├── requestLogger.js Correlation ID + structured logging | ||
| │ └── inputValidator.js Language + moduleId validation | ||
| ├── public/ | ||
| │ ├── index.html Home page (module grid) | ||
| │ ├── module.html Module detail page | ||
| │ ├── css/ | ||
| │ │ ├── main.css Design tokens, layout, cards | ||
| │ │ └── module.css Two-column module layout | ||
| │ └── js/ | ||
| │ ├── api.js fetch wrappers (ES module) | ||
| │ ├── home.js Home page controller | ||
| │ └── module.js Module detail controller | ||
| └── test/ | ||
| ├── unit/ | ||
| │ ├── services/moduleService.test.js | ||
| │ ├── routes/moduleRoutes.test.js | ||
| │ ├── routes/healthRoutes.test.js | ||
| │ ├── middleware/errorHandler.test.js | ||
| │ └── utils/markdownParser.test.js | ||
| └── integration/ | ||
| └── api.test.js | ||
| ``` | ||
|
|
||
| ## Environment Variables | ||
|
|
||
| Copy `.env.example` to `.env` and adjust as needed: | ||
|
|
||
| ```bash | ||
| cp portal/.env.example portal/.env | ||
| ``` | ||
|
|
||
| | Variable | Default | Description | | ||
| |-------------|---------------------------------------|----------------------------------------| | ||
| | `PORT` | `3000` | HTTP port the server listens on | | ||
| | `MODULES_DIR`| `<repo-root>/modules` | Absolute path to the modules directory | | ||
|
|
||
| ## Running the Portal | ||
|
|
||
| ```bash | ||
| cd portal | ||
| npm start # production | ||
| npm run dev # development (nodemon auto-reload) | ||
| npm test # run all tests | ||
| npm run test:coverage # test with coverage report | ||
| ``` | ||
|
|
||
| Open http://localhost:3000 in your browser. | ||
|
|
||
| ## API Reference | ||
|
|
||
| | Method | Path | Description | | ||
| |--------|-----------------------------|------------------------------------------| | ||
| | `GET` | `/api/health` | Liveness check | | ||
| | `GET` | `/api/modules` | List all modules (opt. `?language=java\|javascript`) | | ||
| | `GET` | `/api/modules/:moduleId` | Full module detail + README HTML + code files | | ||
|
|
||
| ### Language Filter | ||
|
|
||
| ``` | ||
| GET /api/modules?language=java | ||
| GET /api/modules?language=javascript | ||
| GET /api/modules/module-01-core-experience?language=java | ||
| ``` | ||
|
|
||
| ### Response Shapes | ||
|
|
||
| **`GET /api/modules`** | ||
| ```json | ||
| { | ||
| "modules": [ | ||
| { | ||
| "id": "module-01-core-experience", | ||
| "order": 1, | ||
| "title": "Module 1: Copilot in VS Code - Core Experience", | ||
| "duration": "45 minutes (15 min demo + 30 min hands-on)", | ||
| "format": "Demo + Hands-on", | ||
| "description": "...", | ||
| "languages": ["java", "javascript"], | ||
| "hasJava": true, | ||
| "hasJavaScript": true | ||
| } | ||
| ] | ||
| } | ||
| ``` | ||
|
|
||
| **`GET /api/modules/:moduleId`** | ||
| ```json | ||
| { | ||
| "module": { | ||
| "id": "module-01-core-experience", | ||
| "order": 1, | ||
| "title": "...", | ||
| "readmeHtml": "<h1>...</h1>", | ||
| "codeFiles": [ | ||
| { | ||
| "filename": "OrderService.java", | ||
| "language": "java", | ||
| "relativePath": "exercises/OrderService.java", | ||
| "content": "..." | ||
| } | ||
| ] | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| ## Security Design | ||
|
|
||
| - **Path traversal prevention**: `getModule` verifies the resolved path stays within `MODULES_DIR` | ||
| - **Input validation**: all query params validated before reaching the service layer | ||
| - **HTML sanitization**: markdown is rendered then sanitized with `sanitize-html` (XSS-safe allowlist) | ||
| - **No stack traces in responses**: the error handler maps domain errors to clean JSON; unknown errors return a generic 500 | ||
| - **Correlation IDs**: every request tagged with UUID v4 for log correlation (`X-Correlation-ID` header) | ||
This file contains hidden or 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,7 @@ | ||
| /** @type {import('jest').Config} */ | ||
| const config = { | ||
| testMatch: ['**/test/**/*.test.js'], | ||
| collectCoverageFrom: ['src/**/*.js'], | ||
| testEnvironment: 'node', | ||
| }; | ||
| module.exports = config; |
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.
The Quick Start and section title reference
setup-portal.js, but there is no such script in the repository. This makes the setup instructions misleading. Update the README to describe the actual setup steps (e.g.,cd portal && npm install && npm test) or add the missing script if it’s intended to exist.