Public service API litminka.ru.
Clone project repository
git clone https://github.com/Litminka/LitminkaApi
Download dependencies
npm install
Build typescript code to javascript
npm run build
Rename .env.example
to .env
and configure server
Start database migrations and seeding
prisma migrate deploy && node dist/prisma/seed.js
Run main process and workers (in single thread mode)
node dist/src/index.js
Pull docker package
docker pull ghcr.io/litminka/litminka-api:latest
Copy and configure .env
from example in repo
Run container
docker run --name litminka-api --env-file .env ghcr.io/litminka/litminka-api:latest
Container requires instances of PostgreSQL and Redis databases (configured in
.env
)
Copy docker-compose.yaml
from repo
Copy and configure .env
from example in repo
Run compose
docker-compose up
To work with the shikimori API, a valid certificate is required.
If you will be using the API behind a proxy, you can disable SSL in the application and configure TLS on Nginx.
For disabling SSL set SSL=0
.
Nginx configuration example:
events {}
http {
server {
listen 80;
# Disable http without TLS
location / {
return 301 https://$server_name$request_uri;
}
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name api.litminka.ru;
ssl_certificate certificate.pem;
ssl_certificate_key private.key;
location / {
proxy_pass http://localhost:8001;
# Simple requests
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' *;
add_header 'Access-Control-Allow-Credentials' 'true';
add_header 'Access-Control-Allow-Headers' 'Authorization,Accept,Origin,DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range';
add_header 'Access-Control-Allow-Methods' 'GET,POST,OPTIONS,PUT,DELETE,PATCH';
add_header 'Access-Control-Max-Age' 1728000;
add_header 'Content-Type' 'text/plain charset=UTF-8';
add_header 'Content-Length' 0;
return 204;
}
add_header 'Access-Control-Allow-Origin' * always;
add_header 'Access-Control-Allow-Credentials' 'true';
add_header 'Access-Control-Allow-Headers' 'Authorization,Accept,Origin,DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range';
add_header 'Access-Control-Allow-Methods' 'GET,POST,OPTIONS,PUT,DELETE,PATCH';
}
}
}
Clone project repository
git clone https://github.com/Litminka/LitminkaApi
Download dependencies
npm install
Copy .env.example
to .env
and configure
Run application
npm run dev
For running queries you can read package.json scripts section
Run only query scripts:
- autocheck
- relation-update
- rating-update
- watchlist-importer
- shikimori-watchlist-sync
Also you can run some server workers in multithreading mode (NodeJS cluster is not ready at the moment, use at your own risk):
npm run server
ornode dist/src/server.js
Right now the website is in development, documentation will be available later