Api backend for my personal website (kunalsin9h.com)
Features:
- Generate Dynamic OG images
- Maintain views count for blogs
- Clone and cd into the repo
git clone https://github.com/KunalSin9h/api
cd api- Run the local server
export HOST=127.0.0.1
export PORT=9999
export MONGODB_URL=mongodb://localhost:27017
export DB_TIMEOUT=5000
export MEILI_HOST=http://localhost:7700
export MEILI_MASTER_KEY="-meilisearch-master-key-"
go run cmd/api/*Note
The HOST is where the server servers, default value of HOST is 127.0.0.1.
The PORT is where the server listens, default value of PORT is 9999.
The MONGODB_URL is where the mongodb database is running, the default value is mongodb://localhost:27017.
The DB_TIMEOUT is the timeout time for each mongodb operation, the default value is 5000.
The MEILI_HOST is the host for meilisearch server.
The MEILI_MASTER_KEY is the master key (auth) for meilisearch server.
docker run \
--name api \
-d -p 9999:9999 \
-e HOST=0.0.0.0 \
-e PORT=9999 \
-e MONGODB_URL=mongodb://localhost:27017 \
-e DB_TIMEOUT=5000 \
-e MEILI_HOST=http://localhost:7700 \
-e MEILI_MASTER_KEY="-meilisearch-master-key-" \
ghcr.io/kunalsin9h/api:latestThis is for OpenGraph and twitter Card of SEO The background image and font are in
assetsfolder
GET /v1/image/:title
Returns a image, whose Content-Type is image/jpeg
This will not update the view count
GET /v1/views/:slug
Response
{
"data": [
"views": 0
],
"success": true
}This will update and return the updated view count
POST /v1/views/:slug
Response
{
"data": {
"views": 0
},
"success": true
}This will and or update the document in meilisearch at some index
POST /v1/search/:index
Request Payload
{
"data": {
// json data
}
}Response : 200 if ok
GET /v1/search/:index?text="how to search"
Response Payload
[
{// data},
{// data},
{// data},
]