An implementation of the backend for the eLibrary project
The easiest way to deploy the API from the ground up is to use:
docker-compose up
body -
{
"email": "username@example.co.id",
"password": "P4sswordꦏꦤ꧀"
}
response - 200 OK
{
"token": "a.b.c",
"scheme": "Bearer",
"expires_at": "2010-07-28T12:54:27+09:00"
}
response - 400 Bad Request; 401 Unauthorized Request; 422 Validation Failed
{
"error_type": "Bad Request",
"message": "error-message"
}
body -
{
"token": "aa.bb.cc",
}
response - 200 OK
{
"token": "a.b.c",
"scheme": "Bearer",
"expires_at": "2010-07-28T12:54:27+09:00"
}
response - 400 Bad Request; 401 Unauthorized Request; 422 Validation Failed
{
"error_type": "Bad Request",
"message": "error-message"
}
body -
{
"email": "username@example.co.id",
"name": "Joko",
"password": "P4sswordꦏꦤ꧀"
}
response - 200 OK
{
"new_id": "username@example.co.id"
}
response - 400 Bad Request
{
"error_type": "Bad Request",
"message": "error-message"
}
body -
{
"token": "aa.bb.cc",
}
response - 200 OK
{
"new_id": "username@example.co.id"
}
response - 400 Bad Request; 422 Validation Failed
{
"error_type": "Bad Request",
"message": "error-message"
}
header -
Authorization: Bearer ...
response - 200 OK
{
"data": [
{
"id": "01234567-89ab-cdef-0123-456789abcdef",
"title": "Chäos;HEĀd",
"author": "Hayashi Naotaka",
"cover_url": "https://s2.vndb.org/cv/59/49759.jpg",
"readers": 0,
"rating": 3.5,
"is_favorite": false
},
]
}
response - 422 Validation Failed
{
"error_type": "Validation Failed",
"message": "error-message"
}
header -
Authorization: Bearer ...
response - 200 OK
{
"data": [
{
"id": "01234567-89ab-cdef-0123-456789abcdef",
"title": "Chäos;HEĀd",
"author": "Hayashi Naotaka",
"cover_url": "https://s2.vndb.org/cv/59/49759.jpg",
"readers": 0,
"rating": 3.5,
"is_favorite": false
},
]
}
response - 422 Validation Failed
{
"error_type": "Validation Failed",
"message": "error-message"
}
header -
Authorization: Bearer ...
response - 200 OK
{
"data": [
{
"id": "01234567-89ab-cdef-0123-456789abcdef",
"title": "Chäos;HEĀd",
"author": "Hayashi Naotaka",
"cover_url": "https://s2.vndb.org/cv/59/49759.jpg",
"readers": 0,
"rating": 3.5,
"is_favorite": false
},
]
}
response - 422 Validation Failed
{
"error_type": "Validation Failed",
"message": "error-message"
}
header -
Authorization: Bearer ...
response - 200 OK
{
"data": [
{
"id": "01234567-89ab-cdef-0123-456789abcdef",
"title": "Chäos;HEĀd",
"author": "Hayashi Naotaka",
"cover_url": "https://s2.vndb.org/cv/59/49759.jpg",
"readers": 0,
"rating": 3.5,
"is_favorite": false
},
]
}
response - 422 Validation Failed
{
"error_type": "Validation Failed",
"message": "error-message"
}
header -
Authorization: Bearer ...
query -
query= text
response - 200 OK
{
"data": [
{
"id": "01234567-89ab-cdef-0123-456789abcdef",
"title": "Chäos;HEĀd",
"author": "Hayashi Naotaka",
"cover_url": "https://s2.vndb.org/cv/59/49759.jpg",
"readers": 0,
"rating": 3.5,
"is_favorite": false
},
]
}
response - 400 Bad Request; 422 Validation Failed
{
"error_type": "Bad Request",
"message": "error-message"
}
chi/render
, for parsing HTTP request and response bodies
chi/jwtauth
module, for authentication via JWT tokens
crypto
, for password hashing via bcrypt
godotenv
, for enviroment variable loading
gomail
, for sending account activation email
google/apo
, for validating google sign-in's token
google/uuid
, for session id's uuid generator
pq
, for connecting to PostgreSQL server
sethvargo/go-envconfig
, for structured env vars
zerolog
, for JSON structured logger