availity / availity-ekko Goto Github PK
View Code? Open in Web Editor NEWMock server simulating API rest services
License: MIT License
Mock server simulating API rest services
License: MIT License
Navigating to:
http://localhost:3000/api/sdk/platform/v1/regions
Results in:
http://localhost:3000/api/sdk/platform/v1/null
"v1/path": {
"file": "pong.json"
}
should respond with pong.json
when request url is locahost.local/v1/path?a=b
"v1/route8": {
"file": "example1.json",
"get": [
{
"file": "example2.json",
"response": [
{
"status": 202,
"file": "example3.json",
"headers": {
"Location": "/v1/route8"
}
},
{
"status": 201,
"file": "example4.json"
}
]
}
]
}
In middleware/index.js:L9-11, the code is pulling in 3 environments (development, testing, and production); however, in server/index.js:L27-28, we pull the environment from the NODE_ENV
variable. This variable can be set to anything the developer wants, but setting it to anything other than the 3 environments listed will result in an error:
TypeError: middleware[(environment || "development")] is not a function
The most flexible option would probably be to allow the developer to add their own middleware function for their environment.
Also, I don't believe the availity-toolkit scripts will run for staging and integration since there is no staging or integration middleware setup. I haven't tried though.
Using the following configuration:
servers: {
web: {
host: '0.0.0.0',
port: 8090
},
aries: {
port: 8280,
proxy: true,
proxies: [
{
context: "/api",
rewrite: {
from: "^/api",
to: ""
}
},
{
context: "/public/api",
rewrite: {
from: "^/public/api",
to: ""
}
}
]
},
axi: {
port: 8080,
proxy: true,
proxies: [
{
context: "/availity"
}
]
}
}
}
I can't get the proxy routes to fire. What appears to be happening is that by the time proxy.js gets the request URL to process, req.url already has the context stripped. It's getting /v1/blah instead of /api/v1/blah, which means the matcher never fires.
No matter what responses are configured, only the first file specified is returned.
Currently routes are configured through routes.json
file. It is good only for smaller size of apps. In a larger app where different teams develop different APIs, it becomes a pain to maintain this file. Merge conflicts occur very often. And this file gets easily corrupted by a bad merge - it has happened quite some times in our dev env, and when this happens, the app stopped working locally.
@bobbennett can correct me if I am wrong.
If routes can be configured in a dir instead of a single file, we can split up this file into multiple json configs where each team updates their own portion, things would become more manageable.
There is are examples on how to mock responses but not any examples how to point to actual services.
Options set at the method level as seen below are not used. I can only set options such as status and latency at the resource path level.
{
"resourcePath": {
"get": [
{
"latency": 1000,
"file": "resource-get.json"
}
],
"put": [
{
"status": 422,
"latency": 10000,
"file": "resource-put.json"
}
]
}
}
[15:23:57] [av-ekko] GET /api/v1/organizations/undefined 404 0.496
Warning: a promise was created in a handler but was not returned from it
at tryOnImmediate (timers.js:534:15)
at processImmediate [as _immediateCallback] (timers.js:514:5)
It would be nice to add more params matching support such as:
For example, if I want to match a param season
of Spring|Summer|Fall
, currently it seems the only solution is to split them up:
{
"get": [
"file": "non-winter-response.json",
"params": {
"season": "Spring"
},
"file": "non-winter-response.json",
"params": {
"season": "Summer"
},
"file": "non-winter-response.json",
"params": {
"season": "Fall"
}
]
}
It would be nice if we can do:
{
"get": [
"file": "non-winter-response.json",
"params": {
"season": "Spring|Summer|Fall"
}
]
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.