autoserver
v0.5.0
Published
Create a full-featured REST/GraphQL API from a configuration file
Downloads
130
Maintainers
Readme
Create a full-featured REST/GraphQL API from a configuration file.
Development status
This project is still in active development, and is not ready for production. Key features are currently missing.
If you want to follow our progress in the meantime, you are welcome to star this repository.
Overview
Create a simple configuration file describing your data model:
engine: 0
collections:
users:
description: User of the API
attributes:
id:
type: string
age:
type: integer
score:
type: number
alias: high_score
default: 10
validate:
minimum: 20
reports:
type: reports[]
reports:
attributes:
id:
type: string
content:
type: string
default:
database: mongodb
databases:
mongodb:
hostname: localhost
password: secret_mongodb_password
dbname: my_database_name
protocols:
http:
port: 5001
Then start a full-featured web API.
$ autoserver
Clients will now be able to perform GraphQL requests:
{
find_users(
filter: { score: { _gt: 100 } }
order: "score"
) {
id
age
score
reports: { content }
}
}
Or REST requests:
GET /rest/users/?filter.score._gt=100&order=score&populate=reports
{
"data": [
{
"id": "15",
"age": 32,
"score": 150,
"reports": { "id": "65", "content": "..." }
},
{
"id": "251",
"age": 24,
"score": 168,
"reports": { "id": "67", "content": "..." }
},
{
"id": "7",
"age": 51,
"score": 192,
"reports": { "id": "10", "content": "..." }
}
]
}
Features
- Multiple RPC systems, including REST, GraphQL and JSON-RPC
- GraphQL debugging, including introspection, interactive debugger and GraphQL schema printing
- Multiple databases support, including MongoDB and an in-memory database. Different databases can be used at the same time.
- Multiple protocols handling, with support for HTTP/1.1 only at the moment
- Multiple formats support for the configuration files, the client request payloads and the server responses, including JSON, YAML, x-www-form-urlencoded, JavaScript, Hjson, JSON5 and INI
- automatic logging and performance monitoring
- extensive error handling and reporting
- CRUD commands: find, create, patch, upsert, delete. Each command can be performed on a single model or on several models.
- Advanced mutations like incrementing, regular expression replacement, cross-attributes mutations, slicing, etc.
- relations, nested commands and populating between models, including for mutations
- filtering
- sorting
- selecting
- renaming attributes
- pagination
- input validation
- authorization, including readonly attributes
- default values
- computed attributes and normalization
- aliases
- automatic attributes:
created_time
,updated_time
,created_by
,updated_by
- compression of both the response and the request, for any protocol. Brotli support.
- dry runs
- silent outputs
- plugins
- custom logic can be added in JavaScript
Documentation
The documentation is here.
Badge
The following badge can be added to your project:
[![autoserver](https://img.shields.io/badge/auto-server-406890.svg?logo=data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+CjxzdmcKICAgeG1sbnM6ZGM9Imh0dHA6Ly9wdXJsLm9yZy9kYy9lbGVtZW50cy8xLjEvIgogICB4bWxuczpjYz0iaHR0cDovL2NyZWF0aXZlY29tbW9ucy5vcmcvbnMjIgogICB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiCiAgIHhtbG5zOnN2Zz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciCiAgIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIKICAgeG1sOnNwYWNlPSJwcmVzZXJ2ZSIKICAgZW5hYmxlLWJhY2tncm91bmQ9Im5ldyAwIDAgNDU5IDQ1OSIKICAgdmlld0JveD0iMCAwIDQwNS4yMjY5OSA0MDUuMjI4IgogICBoZWlnaHQ9IjQwNS4yMjgiCiAgIHdpZHRoPSI0MDUuMjI2OTkiCiAgIHk9IjBweCIKICAgeD0iMHB4IgogICBpZD0iTGF5ZXJfMSIKICAgdmVyc2lvbj0iMS4xIj48bWV0YWRhdGEKICAgaWQ9Im1ldGFkYXRhMTA4NSI+PHJkZjpSREY+PGNjOldvcmsKICAgICAgIHJkZjphYm91dD0iIj48ZGM6Zm9ybWF0PmltYWdlL3N2Zyt4bWw8L2RjOmZvcm1hdD48ZGM6dHlwZQogICAgICAgICByZGY6cmVzb3VyY2U9Imh0dHA6Ly9wdXJsLm9yZy9kYy9kY21pdHlwZS9TdGlsbEltYWdlIiAvPjxkYzp0aXRsZT48L2RjOnRpdGxlPjwvY2M6V29yaz48L3JkZjpSREY+PC9tZXRh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