Skip to content
This repository was archived by the owner on Oct 19, 2025. It is now read-only.

Commit 49e75e0

Browse files
authored
Update README.md
1 parent de127a0 commit 49e75e0

File tree

1 file changed

+80
-0
lines changed

1 file changed

+80
-0
lines changed

README.md

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,81 @@
11
# RestfulMap
2+
Simple Redis-like database with REST routes, written with json header and Pistache C++ framework, as PoC.
3+
4+
**Warning! Under no circumstances use this code in production, i am unsure of it's safety.**
5+
# Usage
6+
[![Demo](http://img.youtube.com/vi/GX4QJlEgEFw/0.jpg)](http://www.youtube.com/watch?v=GX4QJlEgEFw)
7+
8+
## Routes
9+
As written in **server.h**
10+
```cpp
11+
Routes::Get(router, "/key/:key", Routes::bind(&KeyValueApi::getKeyValue, this));
12+
Routes::Get(router, "/all", Routes::bind(&KeyValueApi::getAllKeyValue, this));
13+
Routes::Post(router, "/add/:key", Routes::bind(&KeyValueApi::addKey, this));
14+
Routes::Post(router, "/add/:key/:value", Routes::bind(&KeyValueApi::addKeyValue, this));
15+
Routes::Put(router, "/update/:key/:value", Routes::bind(&KeyValueApi::updateKeyValue, this));
16+
Routes::Delete(router, "/purge/:key", Routes::bind(&KeyValueApi::deleteKey, this));
17+
```
18+
You can use it, for example, in a React component with the fetch() function or with curl.
19+
20+
### Curl
21+
```
22+
curl -X GET http://localhost:9080/all
23+
#returns all keys and values
24+
curl -X GET http://localhost:9080/key/<key>
25+
#returns key an val
26+
curl -X POST http://localhost:9080/add/<key>/
27+
#adds single key
28+
curl -X POST http://localhost:9080/add/<key>/<val>/
29+
#adds key and value
30+
curl -X PUT http://localhost:9080/update/<key>/<new_val>/
31+
#updates value asociated to key
32+
curl -X DELETE http://localhost:9080/purge/<key>/
33+
#deletes key and value
34+
```
35+
36+
37+
# Instalation
38+
At this moment, only Ubuntu 22.04 is tested natively. To run on other platforms, use the Docker instructions below.
39+
## Ubuntu 22.04
40+
### Compiled
41+
[Add pistache PPA](https://launchpad.net/~pistache+team/+archive/ubuntu/unstable)
42+
```bash
43+
sudo add-apt-repository ppa:pistache+team/unstable
44+
sudo apt update
45+
```
46+
download from releses then change path in config.json
47+
then execute
48+
```bash
49+
./RestfulMap
50+
```
51+
to run
52+
### Compile yourself
53+
[Add pistache PPA](https://launchpad.net/~pistache+team/+archive/ubuntu/unstable)
54+
```bash
55+
sudo add-apt-repository ppa:pistache+team/unstable
56+
sudo apt update
57+
```
58+
Then, pull this repository and rebuild the CMake cache. After making your desired changes, generate the Makefile using CMake.
59+
```bash
60+
cd /chosen/CMake/path/
61+
make
62+
./RestfulMap
63+
```
64+
## Docker
65+
### Using docker desktop
66+
After installing Docker Desktop, pull the Docker image from the Docker [Hub](https://hub.docker.com/r/szymonstanek/restfulmap).
67+
To create a container from the image, type the following command into the terminal/cmd:
68+
```bash
69+
docker run -it -p 9080:9080 szymonstanek/restfulmap
70+
```
71+
To run the same container as previously, use this command:
72+
```
73+
docker start -i <cointainer_name_from_docker_desktop>
74+
```
75+
### Making your own docker image
76+
To create your own Docker image after modifications, use the Dockerfile from the repository. Ensure to open the desired port or address and make it **interactive**. Without these settings, you won't be able to connect or close the program properly.
77+
# Credits
78+
[pistacheio](https://github.com/pistacheio)
79+
[nlohmann](https://github.com/nlohmann/json)
80+
# Licence
81+
MIT 2024 Szymon Stanek

0 commit comments

Comments
 (0)