KScript документация
RU

Язык

Переведено автоматически с английского; оригинал на английском.

Маршруты и API

Настройки: kscript.json

Раздел http в kscript.json содержит настройки маршрутов и их промежуточного ПО. Все они необязательны:

JSON
{
  "http": {
    "routes": ["routes.kscript", { "file": "api/v1.kscript", "prefix": "/api/v1", "api": true }],  // default: routes/web.*, routes/api.*, routes.* and api.*
    "middleware": ["log"],                      // for every route
    "groups": { "api": ["cors", "throttle"] },  // names for lists of middleware
    "views": "views",                           // where @view() looks first; never served
    "api_prefix": "/api",                       // the prefix of api.* files
    "write_files": true,                        // false: controllers and their live actions can only read files
    "cors": { "origins": ["*"], "methods": ["GET", "POST"], "headers": ["Content-Type", "Authorization"], "credentials": false },
    "auth": { "token_env": "API_TOKEN", "login": "/login", "lifetime": "2h" },  // and the KScript.Auth settings in auth.md
    "throttle": { "limit": 60, "seconds": 60, "store": "memory" },  // store: memory, file or database (shared by every server)
    "upload_limit": "8MB",                      // the most a request's uploaded files may be, in all
    "openapi": { "routes": "auto", "title": "People API", "version": "1.2.0", "file": "openapi.json" }  // or false
  }
}

Каждый параметр также описан в справочнике kscript.json.