An open API service indexing awesome lists of open source software.

https://github.com/rorycombe/anyapi

A simple, zero config RESTful api that takes whatever you want to throw at it
https://github.com/rorycombe/anyapi

mongodb-database restify typescript

Last synced: 8 months ago
JSON representation

A simple, zero config RESTful api that takes whatever you want to throw at it

Awesome Lists containing this project

README

          


any API 🤖


A simple, zero config RESTful api that takes whatever you want to throw at it


---

![GitHub Workflow Status](https://img.shields.io/github/workflow/status/rorycombe/anyapi/validate?logo=github&style=flat-square)
[![codecov](https://codecov.io/gh/RoryCombe/anyapi/branch/master/graph/badge.svg?token=S462N7D27B)](https://codecov.io/gh/RoryCombe/anyapi)

## Getting Started

```
npx @anyapi/anyapi
```

or

```
npm i @anyapi/anyapi -g
anyapi
```

This will start the server on the default port of `2000`. Using any HTTP client you can now `GET`, `POST`, `PUT`, `DELETE` with a collection type that is completely variable and up to you.

For example `hamburgers`:

```
fetch('http://localhost:2000/hamburgers', {
method: 'POST',
body: JSON.stringify({ name: 'Cheese Burger', ingredients: ['beef', 'tomato', 'lettuce', 'cheese'] }),
headers: new Headers({'Content-Type': 'application/json'})
})
```

Then GET on `http://localhost:2000/hamburgers` to see your new collection

## Methods

- `GETALL` on `:collection`
- `GET` on `:collection` with `:id`
- `CREATE` on `:collection` with `:data`
- `UPDATE` on `:collection` with `:id` and `:data`
- `DESTROY` on `:collection` with `:id`