-
Notifications
You must be signed in to change notification settings - Fork 14
feat: more tests, tiny refactor #69
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
Merged
Merged
Changes from 4 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
95c0858
snapshot - crawler tests, standby tests, fix linter issues, move stan…
MQ37 031b0b8
install playwright cicd
MQ37 4c67fb8
Update src/server.ts
MQ37 d802be0
port to number input
MQ37 b24fd15
Refactor request handlers and remove complex callback logic, use spying
MQ37 4a5416f
Merge remote-tracking branch 'origin/master' into feat/more-tests
MQ37 6efce85
eslint -> 9
MQ37 f654397
just return server no const
MQ37 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,35 @@ | ||
| name: Code Checks | ||
|
|
||
| on: | ||
| push: | ||
| branches: [ master ] | ||
| pull_request: | ||
| branches: [ master ] | ||
|
|
||
| jobs: | ||
| build-and-test: | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Setup Node.js | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: 'latest' | ||
| cache: 'npm' | ||
|
|
||
| - name: Install dependencies | ||
| run: npm ci | ||
|
|
||
| - name: Build | ||
| run: npm run build | ||
|
|
||
| - name: Lint | ||
| run: npm run lint | ||
|
|
||
| - name: Install Playwright | ||
| run: npx playwright install | ||
|
|
||
| - name: Test | ||
| run: npm run test |
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 |
|---|---|---|
|
|
@@ -9,3 +9,7 @@ storage | |
|
|
||
| # Added by Apify CLI | ||
| .venv | ||
| .aider* | ||
|
|
||
| # Actor run input | ||
| input.json | ||
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
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
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
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
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
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
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,50 @@ | ||
| import { SSEServerTransport } from '@modelcontextprotocol/sdk/server/sse.js'; | ||
| import { log } from 'crawlee'; | ||
| import express, { type Request, type Response } from 'express'; | ||
|
|
||
| import { Routes } from './const.js'; | ||
| import { RagWebBrowserServer } from './mcp/server.js'; | ||
| import { handleSearchRequest } from './search.js'; | ||
|
|
||
| export function createServer(): express.Express { | ||
| const app = express(); | ||
| const mcpServer = new RagWebBrowserServer(); | ||
| let transport: SSEServerTransport; | ||
|
|
||
| const HELP_MESSAGE = `Send a GET request to ${process.env.ACTOR_STANDBY_URL}/search?query=hello+world` | ||
| + ` or to ${process.env.ACTOR_STANDBY_URL}/messages to use Model context protocol.`; | ||
|
|
||
| app.get('/', async (req, res) => { | ||
| log.info(`Received GET message at: ${req.url}`); | ||
| res.status(200).json({ message: `Actor is running in Standby mode. ${HELP_MESSAGE}` }); | ||
| }); | ||
|
|
||
| app.get(Routes.SEARCH, async (req: Request, res: Response) => { | ||
| log.info(`Received GET message at: ${req.url}`); | ||
| await handleSearchRequest(req, res); | ||
| }); | ||
|
|
||
| app.head(Routes.SEARCH, async (req: Request, res: Response) => { | ||
| log.info(`Received HEAD message at: ${req.url}`); | ||
| res.writeHead(200, { 'Content-Type': 'application/json' }); | ||
| res.end(); | ||
| }); | ||
|
|
||
| app.get(Routes.SSE, async (req: Request, res: Response) => { | ||
| log.info(`Received GET message at: ${req.url}`); | ||
| transport = new SSEServerTransport(Routes.MESSAGE, res); | ||
| await mcpServer.connect(transport); | ||
| }); | ||
|
|
||
| app.post(Routes.MESSAGE, async (req: Request, res: Response) => { | ||
| log.info(`Received POST message at: ${req.url}`); | ||
| await transport.handlePostMessage(req, res); | ||
| }); | ||
|
|
||
| // Catch-all for undefined routes | ||
| app.use((req, res) => { | ||
| res.status(404).json({ message: `There is nothing at route ${req.method} ${req.originalUrl}. ${HELP_MESSAGE}` }); | ||
| }); | ||
|
|
||
| return app; | ||
| } |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.