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

https://github.com/kunalsin9h/tiddi

⌘Tiddi⌘ is self hosted object store server written in go
https://github.com/kunalsin9h/tiddi

golang images imageserver sqlite

Last synced: 5 months ago
JSON representation

⌘Tiddi⌘ is self hosted object store server written in go

Awesome Lists containing this project

README

          


Powered by




TursoDB Logo

 
 

MeltCD Logo


Supports: all type of files

## Demo

Go to https://tiddi.kunalsin9h.com to see a demo of the project.

## Features (API)

- [x] Upload files
- [x] View files
- [x] Delete files
- [x] Update files
- [x] Get image details

## Setup Locally

> [!IMPORTANT]
> If you want to run the server inside a docker container, you can follow these [Docker Instructions](https://github.com/kunalsin9h/tiddi/blob/main/Docker.md)

> [!IMPORTANT]
> If you want to run the server using [Meltcd](https://github.com/meltred/meltcd) then you can follow these [Meltcd Instructions](https://github.com/kunalsin9h/tiddi/blob/main/Meltcd.md)

### Prerequisites

- [Go](https://golang.org/dl/) (latest version recommended)
- [SQLite](https://www.sqlite.org/download.html) (latest version recommended)
- [LibSQL](https://github.com/tursodatabase/libsql) An SQLite3 Fork

### Steps

1. Clone the repo

```bash
git clone https://github.com/kunalsin9h/tiddi.git
```

2. Change the working directory

```bash
cd tiddi
```

4. Run the server

```bash
go run cmd/main.go
```

7. Open http://localhost:5656 in your browser

## Environment Variables

You can set the following environment variables to change the default settings of the server.

| Environment Variable | Default Value | Description |
| :------------------- | :----------------------- | :-------------------------------- |
| `PORT` | `5656` | Port on which the server will run |
| `DB` | `file:./database/dev.db` | URL to the database file |
| `HOST` | `localhost` | Host on which the server will run |

#### Example

```bash
export PORT=8080

# DB can be sqlite file or libsql url
export DB=file:./database/prod.db
# alternatively for libsql
export DB=libsql://my-db.tarso.io?authToken=autotoken

export HOST=https://tiddi.kunalsin9h.com

go run cmd/main.go
```

> The `HOST` environment variable is used to generate the `unique image id` of the image, it is recommended to set it to the domain name of the server. `HOST` is also used in the sample frontend to fetch the image from the server.

## API Docs

### Sample Client

#### The Sample Frontend is available at `./cmd/frontend` directory, it is served by the server at `/` route.

```http
GET /
```

### Upload Image

```http
POST /image/
```

Request:

```json
{
"image": [23, 112, 2,...34],
"title": "Image Title"
}
```

| Parameter | Type | Description |
| :-------- | :------- | :---------------------------------- |
| `image` | `[]byte` | **Required**. Image bytes to upload |
| `title` | `string` | **Optional**. Title of the image |

Response:

```json
{
"url": "Unique URL of the image"
}
```

### View Image

```http
GET /{uiid}
```

> Image with `uiid` is served at this route

### Get Image Details

```http
GET /get-image/{uuid}
```

| Parameter | Type | Description |
| :-------- | :------- | :------------------------------ |
| `uiid` | `string` | **Required**. UIID of the image |

Response:

```json
{
"title": "Image Title",
"image": "Base64 Encoded Image"
}
```

> UIID is the `unique image id` of the image, it is generated by the server and is returned when the image is uploaded.

### Delete Image

```http
DELETE /delete-image/
```

| Parameter | Type | Description |
| :-------- | :------- | :------------------------------ |
| `uiid` | `string` | **Required**. UIID of the image |

### Update Image

```http
PUT /update-image/
```

| Parameter | Type | Description |
| :-------- | :------- | :---------------------------------- |
| `uiid` | `string` | **Required**. UIID of the image |
| `image` | `[]byte` | **Optional**. Image bytes to upload |
| `title` | `string` | **Optional**. Title of the image |

## Tech Stack

**Client:** HTML, CSS, JavaScript

**Server:** Go, SQLite

## Authors

- [@KunalSin9h](https://github.com/KunalSin9h)

## License

[MIT](https://choosealicense.com/licenses/mit/)

## Acknowledgements

- [Mattn's SQLite3 driver for Go](https://github.com/mattn/go-sqlite3)
- [matoous's go-nanoid](https://github.com/matoous/go-nanoid)

## Support

For support, email `kunal@kunalsin9h.com`

## Feedback

If you have any feedback, please reach out to us at `kunal@kunalsin9h.com`

## Contributing

Contributions are always welcome!

Enjoy! 🚀