Skip to content
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

Feature/sl-72/implement mocking package/router #154

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 20 additions & 0 deletions .vscode/launch.json
@@ -0,0 +1,20 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"name": "vscode-jest-tests",
"request": "launch",
"args": [
"--runInBand"
],
"cwd": "${workspaceFolder}",
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"program": "${workspaceFolder}/node_modules/jest/bin/jest"
}
]
}
11 changes: 7 additions & 4 deletions packages/http-server/src/server.ts
Expand Up @@ -7,12 +7,12 @@ import { createInstance, IHttpConfig } from '@stoplight/prism-http';
// TODO: this is a trivial example, scratch code

const prism = createInstance({
config: async ({ query }) => {
config: async ({ url }) => {
const config: IHttpConfig = {};

if (query && query.__code) {
if (url.query && url.query.__code) {
config.mock = {
code: query.__code,
code: url.query.__code,
};
}

Expand All @@ -21,7 +21,10 @@ const prism = createInstance({
});

app.get('*', async (req: any, res: any) => {
const response = await prism.process({ method: req.method, host: req.host, path: req.path });
const response = await prism.process({
method: req.method,
url: { baseUrl: req.host, path: req.path },
});

if (response.data) {
res.send(response.data);
Expand Down
41 changes: 0 additions & 41 deletions packages/http/src/example.ts

This file was deleted.