https://github.com/style77/memfis
Lightweight database written in Go
https://github.com/style77/memfis
database golang lightweight redis
Last synced: about 1 year ago
JSON representation
Lightweight database written in Go
- Host: GitHub
- URL: https://github.com/style77/memfis
- Owner: style77
- Created: 2022-08-05T23:24:26.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2022-08-06T01:03:49.000Z (almost 4 years ago)
- Last Synced: 2025-02-10T08:29:53.371Z (over 1 year ago)
- Topics: database, golang, lightweight, redis
- Language: Go
- Homepage:
- Size: 25.4 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Memfis
Wannabe Redis database, that saves all the data only in it's memory. Fully encrypted data, everything is removed after closing the server.
## Setup
To get executable simply run `go build -o ./builds`
## Endpoints
#### Request
`POST /authorize`
```
{
"username": "root",
"password": "root"
}
```
#### Response
```
{
"token": "eDF5UrXadWYDvVtwTtN9"
}
```
#### Description
`username` and `password` should be set in config.env. This token is only used to obtain API key
---------
#### Request
`POST /token`
```
{
"token":"eDF5UrXadWYDvVtwTtN9"
}
```
#### Response
```
{
"expiring": 1659762047,
"token": "BoBHapHb.1659762047.c3R5bGU=",
"user": "style"
}
```
#### Description
`Expiring` is timestamp, when api key is going to stop working, the time depends on config `API_TOKEN_EXPIRE_TIME` option.
`token` is API Key that is needed to use to send requests to API
`user` is user that generated that key in `/authorize` endpoint
---------
#### Request
`GET /data`
```
{
"token": "BoBHapHb.1659762047.c3R5bGU=",
"name": "var"
}
```
#### Response
```
{
"formatted": "string;var1;pol",
"name": "var",
"type": "int",
"value": 123
}
```
#### Description
`formatted` is just every field formatted to one string
`name` variable name that is saved in `Memfis`
`type` type of variable, right now it's detected by `Memfis` itself. \
It needs tests, because sometimes it's detecting wrong type.
`ALL TYPES: string, int, float, array, json`
`value` value of variable
---------
#### Request
`POST /data`
```
{
"token": "BoBHapHb.1659762047.c3R5bGU=",
"name": "var",
"value": 123
}
```
#### Response
```
{
"formatted": "string;var1;pol",
"name": "var",
"type": "int",
"value": 123
}
```
#### Description
Same description as in `GET /data`
---------
#### Request
`DELETE /data`
```
{
"token": "BoBHapHb.1659762047.c3R5bGU=",
"name": "var"
}
```
#### Response
```
{
"formatted": ";;",
"name": "",
"type": "",
"updated": 1659741404,
"value": null
}
```
#### Description
`formatted` formatted string is a little bugged but at least shows what should show
`updated` timestamp of when data were deleted
everything else is same as in `GET /data`
---------
#### Request
`PATCH /data`
```
{
"token": "BoBHapHb.1659762047.c3R5bGU=",
"name": "var",
"value": "123"
}
```
#### Response
```
{
"formatted": "int;var;123",
"name": "var",
"type": "int",
"updated": 1659741641,
"value": 123
}
```
#### Description
`updated` timestamp of when data were updated
everything else is same as in `GET /data`
data's type is chaning automatically
---------
## Errors
Status codes used:
```200, 400, 401, 404```
#### messages
```
400 - "Wrong parameters passed."
401 - "Wrong credentials." or "Wrong token passed." or "Wrong token passed or token has expired."
404 - "Couldn't find data..."
```
## Executables
You can find all releases [here](https://github.com/Style77/Memfis/releases)