All Projects → serayuzgur → Weld

serayuzgur / Weld

Licence: mit
Full fake REST API generator written with Rust

Programming Languages

rust
11053 projects

Projects that are alternatives of or similar to Weld

mokker
The mock does not mock you. The video: https://www.youtube.com/watch?v=gGLNJpC-Ov0
Stars: ✭ 13 (-91.1%)
Mutual labels:  mock, json-api, mock-server
Dictfier
Python library to convert/serialize class instances(Objects) both flat and nested into a dictionary data structure. It's very useful in converting Python Objects into JSON format
Stars: ✭ 67 (-54.11%)
Mutual labels:  json-api, json
Json Api Dart
JSON:API client for Dart/Flutter
Stars: ✭ 53 (-63.7%)
Mutual labels:  json-api, json
Json Benchmark
nativejson-benchmark in Rust
Stars: ✭ 93 (-36.3%)
Mutual labels:  json, serde
Easy mock api
easy mock json api
Stars: ✭ 145 (-0.68%)
Mutual labels:  json, mock
Generator Http Fake Backend
Yeoman generator for building a fake backend by providing the content of JSON files or JavaScript objects through configurable routes.
Stars: ✭ 49 (-66.44%)
Mutual labels:  json, mock
Httpmock
HTTP mocking library for Rust.
Stars: ✭ 76 (-47.95%)
Mutual labels:  mock, mock-server
Dyson
Node server for dynamic, fake JSON.
Stars: ✭ 814 (+457.53%)
Mutual labels:  json, mock
Athena Express
athena-express makes it easier to execute SQL queries on Amazon Athena by chaining together a bunch of methods in the AWS SDK. This allows you to execute SQL queries AND fetch JSON results in the same synchronous call - well suited for web applications.
Stars: ✭ 111 (-23.97%)
Mutual labels:  json-api, json
Symfony Jsonapi
JSON API Transformer Bundle for Symfony 2 and Symfony 3
Stars: ✭ 114 (-21.92%)
Mutual labels:  json-api, json
Mockit
A tool to quickly mock out end points, setup delays and more...
Stars: ✭ 1,534 (+950.68%)
Mutual labels:  json, mock
Wiremockui
Wiremock UI - Tool for creating mock servers, proxies servers and proxies servers with the option to save the data traffic from an existing API or Site.
Stars: ✭ 38 (-73.97%)
Mutual labels:  mock, mock-server
Node Quick Mock
🌞 基于Express的mock接口平台
Stars: ✭ 33 (-77.4%)
Mutual labels:  json, mock
Jsonapi parameters
Rails-way to consume JSON:API input
Stars: ✭ 50 (-65.75%)
Mutual labels:  json-api, json
Easy Mock Server
A mock server for json and mock template files
Stars: ✭ 22 (-84.93%)
Mutual labels:  json, mock-server
Accord
Data validation library for Rust
Stars: ✭ 72 (-50.68%)
Mutual labels:  json, serde
Bricks
A standard library for microservices.
Stars: ✭ 142 (-2.74%)
Mutual labels:  json-api, json
Flutter login
100% Shared Code Android/iOS Login Example - JSON API
Stars: ✭ 589 (+303.42%)
Mutual labels:  json-api, json
Api
姬长信API For Docker 一个基于多种编程语言开源免费不限制提供生活常用,出行服务,开发工具,金融服务,通讯服务和公益大数据的平台.
Stars: ✭ 743 (+408.9%)
Mutual labels:  json-api, json
Rki Covid Api
🦠🇩🇪📈 An API for the spread of covid-19 in Germany. Data from Robert-Koch-Institut.
Stars: ✭ 98 (-32.88%)
Mutual labels:  json-api, json

Weld

Full fake REST API generator.

weldmock' current version badge Build Status codecov

This project is heavily inspired by json-server, written with rust.

Synopsis

Our first aim is to generate a fake api from the given data source (JSON). It may have bugs, missing features but if you contribute they all will be fixed.

Version CHANGELOG

Techs

Installation

  1. Download and install Rust from here
  2. Download and install Cargo from here
  3. Clone and run the project.
git clone https://github.com/serayuzgur/weld.git
cd weld
cargo run

Usage

Running

Executable can take configuration path otherwise it will use default ./weld.json. If we take project folder as root, commands should look like one of these. If you you use cargo build --release version change debug with release.

./target/debug/weld  
./target/debug/weld weld.json
./target/debug/weld <path_to_config>.json

./target/release/weld  
./target/release/weld weld.json
./target/release/weld <path_to_config>.json

Configuration

Configuration file is a very simple json file which is responsible to hold server and database properties.

{
    "server": {
        "host": "127.0.0.1",
        "port": 8080
    },
    "database": {
        "path": "db.json"
    }
}

Database

Database is a simple json file.

{
    "owner": {
        "name": "seray",
        "surname": "uzgur"
    },
    "posts": [
        {
            "author": {
                "name": "seray",
                "surname": "uzgur"
            },
            "body": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec odio. Praesent libero.",
            "id": 1,
            "tags": [
                {
                    "id": 1,
                    "name": "tech"
                },
                {
                    "id": 2,
                    "name": "web"
                }
            ],
            "title": "Rust Rocks!"
        },
        {
            "author": {
                "name": "kamil",
                "surname": "bukum"
            },
            "body": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec odio. Praesent libero.",
            "id": 2,
            "tags": [
                {
                    "id": 1,
                    "name": "tech"
                },
                {
                    "id": 2,
                    "name": "web"
                }
            ],
            "title": "TypeScript is Awesome"
        }
    ],
    "version": "10.1.1"
}

Here the owner and posts are tables. They can be empty arrays/objects but they must exist as is.

NOTE : id: Column is a must, all parsing uses it.

API

Api usage is pretty simple. For now it does not support filters one other query params. Here is the list of the calls you can make with examples.

  • Get List <host>:<port>/<table> GET
  • Get Record <host>:<port>/<table>/<id> GET
  • Insert Record <host>:<port>/<table> POST
  • Update Record <host>:<port>/<table>/<id> PUT
  • Delete Record <host>:<port>/<table>/<id> DELETE
  • Get Nested <host>:<port>/<table>/<id><field>/<id>... GET

Get List

url: http://127.0.0.1:8080/posts 
method: GET
body: empty

response: 
[
  {
    "author": "serayuzgur",
    "body": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec odio. Praesent libero.",
    "id": 1,
    "title": "Rust Rocks!"
  },
  {
    "author": "kamilbukum",
    "body": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec odio. Praesent libero.",
    "id": 2,
    "title": "TypeScript is Awesome"
  }
]

Get Record

url: http://127.0.0.1:8080/posts/1 
method: GET
body: empty

response: 
{
    "author": {
        "name": "seray",
        "surname": "uzgur"
    },
    "body": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec odio. Praesent libero.",
    "id": 1,
    "tags": [
        {
            "id": 1,
            "name": "tech"
        },
        {
            "id": 2,
            "name": "web"
        }
    ],
    "title": "Rust Rocks!"
}

Insert Record

url: http://127.0.0.1:8080/posts
method: POST
body:
{
  "author": {
    "name": "hasan",
    "surname": "mumin"
  },
  "body": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec odio. Praesent libero.",
  "id": 3,
  "tags": [
    {
      "id": 1,
      "name": "tech"
    },
    {
      "id": 2,
      "name": "web"
    }
  ],
  "title": "KendoUI Rocks!"
}

response: 
{
  "author": {
    "name": "hasan",
    "surname": "mumin"
  },
  "body": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec odio. Praesent libero.",
  "id": 3,
  "tags": [
    {
      "id": 1,
      "name": "tech"
    },
    {
      "id": 2,
      "name": "web"
    }
  ],
  "title": "KendoUI Rocks!"
}

Update Record

url: http://127.0.0.1:8080/posts/3
method: PUT
body:
{
  "author": {
    "name": "hasan",
    "surname": "mumin"
  },
  "body": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec odio. Praesent libero.",
  "id": 3,
  "tags": [
    {
      "id": 1,
      "name": "tech"
    },
    {
      "id": 2,
      "name": "web"
    }
  ],
  "title": "KendoUI Rocks!"
}

response: 
{
  "author": {
    "name": "hasan",
    "surname": "mumin"
  },
  "body": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec odio. Praesent libero.",
  "id": 3,
  "tags": [
    {
      "id": 1,
      "name": "tech"
    },
    {
      "id": 2,
      "name": "web"
    }
  ],
  "title": "Angular Rocks!"
}

Delete Record

url: http://127.0.0.1:8080/posts/3
method: DELETE
body: empty

response: 
{
  "author": {
    "name": "hasan",
    "surname": "mumin"
  },
  "body": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec odio. Praesent libero.",
  "id": 3,
  "tags": [
    {
      "id": 1,
      "name": "tech"
    },
    {
      "id": 2,
      "name": "web"
    }
  ],
  "title": "KendoUI Rocks!"
}

Get Nested

url: http://127.0.0.1:8080/posts/1/author
method: GET
body: empty

response:
{
    "name": "seray",
    "surname": "uzgur"
}
url: http://127.0.0.1:8080/posts/1/author/name
method: GET
body: empty

response:
"seray"
url: http://127.0.0.1:8080/posts/1/tags/1
method: GET
body: empty

response:
{
    "id": 1,
    "name": "tech"
}

Query API

Field selection

Give the API consumer the ability to choose returned fields. This will also reduce the network traffic and speed up the usage of the API.

GET /cars?fields=manufacturer,model,id,color
Paging
GET /cars?_offset=10&_limit=5
  • Add _offset and _limit (an X-Total-Count header is included in the response).

  • To send the total entries back to the user use the custom HTTP header: X-Total-Count.

  • Content-Range offset – limit / count.

    • offset: Index of the first element returned by the request.

    • limit: Index of the last element returned by the request.

    • count: Total number of elements in the collection.

  • Accept-Range resource max.

  • resource: The type of pagination. Must remind of the resource in use, e.g: client, order, restaurant, …

  • max : Maximum number of elements that can be returned in a single request.

Sorting
  • Allow ascending and descending sorting over multiple fields.
  • Use sort with underscore as _sort.
  • In code, descending describe as -, ascending describe as +.

GET /cars?_sort=-manufactorer,+model

Operators
  • Add _filter query parameter and continue with field names,operations and values separated by ,.
  • Pattern _filter=<fieldname><operation><value>.
  • Supported operations.
    • = equal
    • != not equal
    • < less
    • <= less or equals
    • > greater
    • >= greater or equals
    • ~= like
    • |= in (values must be separated with |

GET http://127.0.0.1:8080/robe/users?_filter=name=seray,active=true

Full-text search
  • Add _q.

GET /cars?_q=nissan

License

The MIT License (MIT) Copyright (c) 2017 Seray Uzgur

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].