Created Configuration (markdown)

Irfan 2021-12-30 18:43:14 +05:00
parent 1dd1c458a9
commit 25cca9be34

169
Configuration.md Normal file

@ -0,0 +1,169 @@
# Environemnt Variables
This is your `.env` file after [Installation](https://github.com/jikan-me/jikan-rest/wiki/Installation)
## APP_URL
Set your `APP_URL` right after installation.
- `APP_URL=http://localhost`
## Configuring MongoDB
If you installed a self-managed MongoDB server then be sure to fill out so Jikan can communicate with your MongoDB server
```
###
# Database Caching (MongoDB)
###
DB_CACHING=true
DB_CONNECTION=mongodb
DB_HOST=localhost
DB_PORT=27017
DB_DATABASE=jikan // MongoDB jikan database
DB_ADMIN=jikan // MongoDB admin database
DB_USERNAME=
DB_PASSWORD=
```
## MAX_RESULTS_PER_PAGE
Pages like Search or Top return a number of maximum entries per page. You can configure this to however you like.
```
MAX_RESULTS_PER_PAGE=30
```
## MyAnimeList Connection
This is where you can manage the connection configurations being made with MyAnimeList.
v4 is equipped with a feature called **MyAnimeList HeartBeat** which monitors successful requests. It can return this information at the root of your instance `localhost/v4`
e.g https://api.jikan.moe/v4
```json
"myanimelist_heartbeat": {
"status": "HEALTHY",
"score": 1.0204081632653061,
"down": false,
"last_downtime": 0
}
```
**SOURCE** here refers to where the data is fetched from.
When `SOURCE=local`, Jikan will attempt to query the MongoDB database for API calls like search. This is only supported for a limited number of API calls and the rest of the API calls are directly parsed from MyAnimeList.
`SOURCE=myanimelist` allows direct parsing of MyAnimeList search pages. This will return a different response than usual.
⚠ This feature is currently experimental. Not Recommended for use.
```
###
# Enable MyAnimeList Heartbeat
#
# Monitor bad requests to determine whether MyAnimeList is down
#
# Fallback once the following threshold is reached
###
SOURCE=local
SOURCE_BAD_HEALTH_THRESHOLD=10
# Recheck source availability (in seconds)
SOURCE_BAD_HEALTH_RECHECK=10
# Fail count only within specified time range (in seconds)
SOURCE_BAD_HEALTH_RANGE=30
# Max Fail stores
SOURCE_BAD_HEALTH_MAX_STORE=50
# Disable failover if the score reaches the following (0.0-1.0 values ONLY)
# e.g 0.9 means 90% successful requests to MyAnimeList
SOURCE_GOOD_HEALTH_SCORE=0.9
# Max time request is allowed to take
# https://curl.haxx.se/libcurl/c/CURLOPT_TIMEOUT.html
SOURCE_TIMEOUT=10
```
## Caching
An additional layer of caching can be added with `file`, `redis` or any other supported [Lumen Caching](https://lumen.laravel.com/docs/8.x/cache) methods.
```
###
# Caching (File, Redis, etc)
# Can be added over DB Caching
###
CACHING=false
CACHE_DRIVER=array
CACHE_METHOD=queue
```
You can configure Redis Caching as a Database here:
https://github.com/jikan-me/jikan-rest/blob/v4/config/database.php
You can configure any other caching method here:
https://github.com/jikan-me/jikan-rest/blob/v4/config/cache.php
Jikan REST API v4 currently supports Redis and File Caching. Implementing any other type of caching may require additional development on your end.
***
You can configure caching for specific API calls. The simple version of it is in `.env`
```
# Caching TTL (in seconds) on specific endpoints
CACHE_DEFAULT_EXPIRE=86400 # 1 day
CACHE_META_EXPIRE=300 # 5 minutes
CACHE_USER_EXPIRE=300 # 5 minutes
CACHE_USERLIST_EXPIRE=3600 # 1 hour
CACHE_404_EXPIRE=604800 # 7 days
CACHE_SEARCH_EXPIRE=432000 # 5 days
CACHE_PRODUCERS_EXPIRE=432000 # 5 days
CACHE_MAGAZINES_EXPIRE=432000 # 5 days
```
If you want a more extensive version for every API call, you can configure the following:
https://github.com/jikan-me/jikan-rest/blob/v4/config/controller.php
## Redis Caching
```
###
# Redis Caching Configuration
###
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
```
## MicroCaching
```
###
# Micro Caching
# Uses CACHE_DRIVER
###
MICROCACHING=false
MICROCACHING_EXPIRE=5 // 5 seconds
```
## Github Reporting
On parser-level errors, the JSON response may return a `error_url` which is an auto-generated Github issue with the details needed to debug it. You can toggle this for your instance and even change the repository information.
```
###
# GitHub generate report URL on fatal errors
###
GITHUB_REPORTING=true
GITHUB_REST="jikan-me/jikan-rest" // The REST API repo
GITHUB_API="jikan-me/jikan" // the Parser repo
```
## Error Reporting
Jikan REST API v4 currently supports error reporting with SENTRY. You can toggle or configure this as per your needs.
```
###
# Error reporting
###
REPORTING=true
REPORTING_DRIVER=sentry
SENTRY_LARAVEL_DSN="https://examplePublicKey@o0.ingest.sentry.io/0"
SENTRY_TRACES_SAMPLE_RATE=1
```