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

Restructure config files #6

Open
ThomasR opened this issue Feb 3, 2016 · 3 comments
Open

Restructure config files #6

ThomasR opened this issue Feb 3, 2016 · 3 comments

Comments

@ThomasR
Copy link
Contributor

ThomasR commented Feb 3, 2016

Current config file structure:

    "services": [
        {
            "active": true,
            "path": "exampleEndpoint",
            "file": "get-result.example.json"
        }, 
    ]

Better:

    "services": {
        "exampleEndpoint": {
            "active": true,
            "file": "get-result.example.json"
        },}

This makes sure that merging the foo.json with the foo.development.json file does not fail when the services are not in the same order.

@ThomasR
Copy link
Contributor Author

ThomasR commented Mar 17, 2016

Also, it would be nice to have a global "active" switch, in addition to the ones for each HTTP method

@ThomasR
Copy link
Contributor Author

ThomasR commented Apr 14, 2016

In order to achieve a mapping like this,

https://localhost:4242/example2/repos/SEITENBAU/mix-n-mock    ->    https://api.github.com/repos/SEITENBAU/mix-n-mock
https://localhost:4242/example2/users/SEITENBAU/repos         ->    https://api.github.com/users/SEITENBAU/repos
https://localhost:4242/example2/repos/exampleRepoEndpoint     ->    exampleRepoEndpoint.json
https://localhost:4242/example2/users/exampleUserEndpoint     ->    exampleUserEndpoint.json
https://localhost:4242/example2/exampleEndpoint               ->    exampleEndpoint.json

we want to have the following config structure:

server.root.json:
{
root: "/example2"
proxying: {
    "repos/*": "https://api.github.com/repos",
    "users/*": "https://api.github.com/users",
    "serviceBasePath": ""
}
}

GET.mock.json
{
    "active": true,
    "services": {
        "repos/exampleRepoEndpoint": {"file": "get-result.example.json"},
        "users/exampleUserEndpoint": {"file": "anotherExample.json", "active": true, "status": 417}
    }
}

@ThomasR ThomasR reopened this May 27, 2016
@ThomasR
Copy link
Contributor Author

ThomasR commented Sep 2, 2016

We should handle the serverRoot differently: add some middleware component that normalizes the path by stripping serverRoot (e.g. return path.relative(roots.serverRoot, requestedUrl)) and pass that to our routing components in routing.js; instead of manually fumbling around with things like

if (path.normalize(requestedFile) === path.normalize(paths.staticFilesDirAbs) && req.path.replace(/\/$/, '') !== roots.serverRoot) {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant