Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
134 changes: 83 additions & 51 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,17 @@ A containerized API service for interacting with Akave's decentralized storage n
## Quick Start

### 1. Pull the Akavelink docker image
```bash

```bash
docker pull akave/akavelink:latest
```

### 2. Get Node Address

Contact Akave team to receive your dedicated node address.

### 3. Run the container to serve a personal api

```bash
docker run -d \
-p 8000:3000 \
Expand All @@ -23,12 +26,11 @@ akave/akavelink:latest

### Environment Variables

| Variable | Description | Required | Default |
|----------|-------------|----------|---------|
| NODE_ADDRESS | Akave node address | Yes | "" |
| PRIVATE_KEY | Your Akave private key | Yes | "" |
| PORT | API server port | No | 3000 |

| Variable | Description | Required | Default |
| ------------ | ---------------------- | -------- | ------- |
| NODE_ADDRESS | Akave node address | Yes | "" |
| PRIVATE_KEY | Your Akave private key | Yes | "" |
| PORT | API server port | No | 3000 |

### 4. Deployment

Expand All @@ -39,6 +41,7 @@ Expose the spawned api to the web **(Note: This will make your data public and a
Install [Ngrok](https://download.ngrok.com/)

Run the following command to expose the api to the web

```bash
ngrok http 8000
```
Expand All @@ -48,6 +51,7 @@ ngrok http 8000
Install [Cloudflare Tunnel](https://developers.cloudflare.com/cloudflare-one/connections/connect-apps/install-and-setup/tunnel-guide/)

Run the following command to expose the api to the web

```bash
cloudflared tunnel --url http://localhost:8000
```
Expand All @@ -57,11 +61,13 @@ cloudflared tunnel --url http://localhost:8000
**Step 1:** Install Docker on your VPS

**Step 2:** Pull the Akavelink docker image

```bash
docker pull akave/akavelink:latest
```

**Step 3:** Run the following command to expose the api to the web

```bash
docker run -d \
-p 8000:3000 \
Expand All @@ -74,131 +80,145 @@ akave/akavelink:latest

**Step 5:** Access the api using the public url `http://your_public_ip:8000`


# API Documentation

## Bucket Operations

### Create Bucket

`POST /buckets`

Create a new bucket for file storage.

**Request Body:**

```json
{
"bucketName": "string"
"bucketName": "string"
}
```

**Response:**

```json
{
"success": true,
"data": {
"Name": "string",
"Created": "timestamp"
}
"success": true,
"data": {
"Name": "string",
"Created": "timestamp"
}
}
```

### List Buckets

`GET /buckets`

Retrieve a list of all buckets.

**Response:**

```json
{
"success": true,
"data": [
{
"Name": "string",
"Created": "timestamp"
}
]
"success": true,
"data": [
{
"Name": "string",
"Created": "timestamp"
}
]
}
```

### View Bucket

`GET /buckets/:bucketName`

Get details of a specific bucket.

**Response:**

```json
{
"success": true,
"data": {
"Name": "string",
"Created": "timestamp"
}
"success": true,
"data": {
"Name": "string",
"Created": "timestamp"
}
}
```

## File Operations

### List Files

`GET /buckets/:bucketName/files`

List all files in a specific bucket.

**Response:**

```json
{
"success": true,
"data": [
{
"Name": "string",
"Size": "number",
"Created": "timestamp"
}
]
"success": true,
"data": [
{
"Name": "string",
"Size": "number",
"Created": "timestamp"
}
]
}
```

### Get File Info

`GET /buckets/:bucketName/files/:fileName`

Get metadata about a specific file.

**Response:**

```json
{
"success": true,
"data": {
"Name": "string",
"Size": "number",
"Created": "timestamp"
}
"success": true,
"data": {
"Name": "string",
"Size": "number",
"Created": "timestamp"
}
}
```

### Upload File

`POST /buckets/:bucketName/files`

Upload a file to a specific bucket.

**Request:**

- Content-Type: `multipart/form-data`
- Body:
- `file` or `file1`: File to upload
OR
OR
- `filePath`: Path to file on server

**Response:**

```json
{
"success": true,
"data": {
"Name": "string",
"Size": "number",
"Hash": "string"
}
"success": true,
"data": {
"Name": "string",
"Size": "number",
"Hash": "string"
}
}
```

### Download File

`GET /buckets/:bucketName/files/:fileName/download`

Download a file from a specific bucket.
Expand All @@ -207,21 +227,33 @@ Download a file from a specific bucket.
Access this URL directly in your browser to download the file. The file will be automatically downloaded with its original filename.

**Response:**

- Success: File download will begin automatically
- Error:

```json
{
"success": false,
"error": "error message"
"success": false,
"error": "error message"
}
```

## Error Responses

All endpoints will return the following format for errors:

```json
{
"success": false,
"error": "error message"
"success": false,
"error": "error message"
}
```

## Swagger UI

- Endpoint: `/api-docs`
- Access the interactive API documentation by navigating to `http://localhost:3000/api-docs`
- Allows you to:
- View all available endpoints
- Test API calls directly from the browser
- See request/response schemas
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@
"server.js"
],
"dependencies": {
"cors": "^2.8.5",
"dotenv": "^16.4.5",
"express": "^4.18.2",
"multer": "^1.4.5-lts.1",
"viem": "^2.21.42",
"cors": "^2.8.5"
"swagger-jsdoc": "^6.2.8",
"swagger-ui-express": "^5.0.1",
"viem": "^2.21.42"
},
"devDependencies": {
"nodemon": "^3.0.3"
Expand Down
Loading