Skip to content

Repository files navigation

Backend

This is a backend implementation of Sharpic.

The sharpic server manages user account information and provides login logout API. And by providing album and image api, it serves as a relay so that users can upload images to the database and super resolution processing can operate.

To use full sharpic service, see sharpic

Run test Backend

docker compose -f ./docker-compose-test.yml up --build -d

Structure

Screenshot from 2023-05-31 16-36-46

The overall process of sharpic server is as above. Below are the modules of sharpic server.

main.go : API paths are defined and appropriate handlers are called.

/handler : Parse the json data and do whatever you need. If you need to call the DB, call the database module.

/database : Connects the database and provides necessary functionality.

/type: Data types used in sharpic server are defined.

APIs

This is a format of the request and response of the Sharpic server.

Authentication API

To make a request to sharpic-server, you must first log in.
Below are the APIs related to login.

/signup - POST

Request

{
"username": "username",
"password": "password",
"email": "email@email.com",
}

Response

{
"status": "signup success",
}

/login - POST

Request

{
"username": "username",
"password": "password",
"email": "",
}

Response

{
"status": "login success",
}

/logout - POST

Response

{
"status": "logout success",
}

User API

Provides functions related to user information.

/user - GET

Request

Check userId in cookie.

Response
{
"username": "username",
"email": "email@email.com",
}

Album API

/album/list - GET

Request

Check userId in cookie.

Response
{
"list": [
{
"id": "int",
"username": "username",
"title": "title",
"imageIds": "[]int",
}
],
}

/album/:albumId - GET

Request

Check userId in cookie.

Response
{
"username": "username",
"title": "title",
"imageIds": "[]int",
}

/album/new - POST

Request

{
"username": "username",
"title": "title",
}

Response

{
"status": "new album success",
}

Image API

/image/:imageId - GET

Requset

Check userId in cookie.

Response

Content-Type: image/png

/image/processed/:imageId - GET

Requset

Check userId in cookie.

Response

Content-Type: image/png

/image/info/:imageId - GET

Requset

Check userId in cookie.

Response

{
"fileName": "string",
"size": "int64",
"added_date": "time.Time",
"up": "int",
"status": "bool",
}

/image/new/:albumId - POST

Request

Form-data format

"images": image_file,"images": image_file,"images": image_file,...

Response

{
"status": "images uploaded!"
}

/image/up/:imageId/:newUp - PATCH

Request

Just check the cookie.

Response

{
"status": "up changed"
}

About

This is a backend implementation of Sharpic project.

Resources

Stars

0 stars

Watchers

4 watching

Forks

Releases

Packages

Used by

Contributors

Languages