Creates an API based on the specifications in a target JSON file. Communicates with MongoDB.
Request
struct Request<B, Q> {
body: B,
query: Q,
}
Endpoint
// Endpoint Specifications
struct EndpointSpec<M> {
uri: String,
endpoint_type: String, // GET, POST, UPDATE, etc.
model: Model<M>,
}
// Format for the data parameters on a request.
struct EndpointData<T, D> {
request_type: T,
request_data: D,
}
Endpoint Generator
-
Endpoint
should be created from aEndpointSpec
interface. -
Endpoint.send(data: EndpointData)
should run theEndpoint
callback function.
- apirc loader
- schema loader
- handler factory
- endpoint factory
- implement the config argument
apirc.json
{
"name": "my-api",
"schemas": [
"hello_schema.json"
],
"routes": [
{
"uri": "/hello",
"method": "GET",
"schema": "hello_schema"
}
]
},
hello_schema.json
[
{
"name": "hello_schema",
"schema": [
{
"name": "hello",
"type": "string"
}
]
},
{
"name": "world_schema",
"schema": [
{
"name": "world",
"type": "string"
}
]
}
]
--config or -c
specifies the JSON config file.