Skip to Content
šŸš€ Alpha Release - Yama JS is currently in alpha. APIs may change without notice.
DocumentationAPI ReferenceConfiguration Reference

Configuration Reference

Complete reference for all yama.yaml configuration options.

Top-Level Structure

name: string # Project name (required) version: string # API version (required) database: object # Database configuration server: object # Server settings auth: object # Authentication settings schemas: object # Schema definitions endpoints: object # API endpoints plugins: array # Plugin configuration

Project Info

name: my-api version: 1.0.0 description: My Yama API
FieldTypeRequiredDescription
namestringYesProject name
versionstringYesSemantic version
descriptionstringNoProject description

Database

database: url: ${DATABASE_URL} pool: min: 2 max: 10 ssl: true
FieldTypeDefaultDescription
urlstring-Connection string (required)
pool.minnumber2Minimum pool connections
pool.maxnumber10Maximum pool connections
sslbooleanfalseEnable SSL connection

Server

server: port: ${PORT:-4000} host: 0.0.0.0 cors: origin: "*" methods: - GET - POST - PUT - DELETE credentials: true logging: level: info format: json
FieldTypeDefaultDescription
portnumber4000Server port
hoststringlocalhostServer host
cors.originstring/array*Allowed origins
cors.methodsarrayallAllowed HTTP methods
cors.credentialsbooleanfalseAllow credentials
logging.levelstringinfoLog level: debug, info, warn, error
logging.formatstringtextLog format: text, json

Authentication

auth: providers: - type: jwt secret: ${JWT_SECRET} expiresIn: 7d algorithm: HS256

JWT Provider

FieldTypeDefaultDescription
typestring-Provider type: jwt
secretstring-JWT secret key (required)
expiresInstring7dToken expiration
algorithmstringHS256Signing algorithm

Schemas

Define data models using JSON Schema:

schemas: User: type: object required: - email - name properties: id: type: string format: uuid email: type: string format: email name: type: string minLength: 1 maxLength: 100 age: type: integer minimum: 0 role: type: string enum: - user - admin createdAt: type: string format: date-time

Supported Types

TypeDescription
stringText values
numberFloating point numbers
integerWhole numbers
booleantrue/false
arrayArrays
objectNested objects

String Formats

FormatDescription
uuidUUID v4
emailEmail address
dateISO date (YYYY-MM-DD)
date-timeISO datetime
uriURL/URI
passwordPassword (masked in docs)

Validation Keywords

KeywordApplies ToDescription
minLengthstringMinimum length
maxLengthstringMaximum length
patternstringRegex pattern
minimumnumberMinimum value
maximumnumberMaximum value
minItemsarrayMinimum items
maxItemsarrayMaximum items
enumanyAllowed values

References

Use $ref to reference other schemas:

schemas: Address: type: object properties: street: type: string city: type: string User: type: object properties: address: $ref: "#/schemas/Address"

Endpoints

endpoints: /users: get: handler: handlers/listUsers summary: List all users auth: required parameters: - name: limit in: query type: integer default: 10 response: type: array items: $ref: "#/schemas/User" post: handler: handlers/createUser auth: required request: $ref: "#/schemas/CreateUserInput" response: $ref: "#/schemas/User" /users/{id}: get: handler: handlers/getUser response: $ref: "#/schemas/User"

Endpoint Options

FieldTypeDescription
handlerstringPath to handler function (required)
summarystringBrief description
descriptionstringDetailed description
authstring/objectAuthentication rule
parametersarrayQuery/path parameters
requestobjectRequest body schema
responseobjectResponse schema
tagsarrayOpenAPI tags

Auth Rules

# Public endpoint auth: public # Requires authentication auth: required # Optional authentication auth: optional # Role-based auth: role: admin # Multiple roles auth: role: - admin - moderator

Parameters

parameters: - name: limit in: query type: integer default: 10 description: Maximum results - name: id in: path type: string required: true
FieldTypeDescription
namestringParameter name
instringLocation: query, path, header
typestringData type
requiredbooleanIs required
defaultanyDefault value
descriptionstringDescription

Plugins

plugins: - name: "@betagors/yama-redis" config: url: ${REDIS_URL} - name: "@betagors/yama-s3" config: bucket: my-bucket region: us-east-1
FieldTypeDescription
namestringPlugin package name
configobjectPlugin-specific configuration

Environment Variables

Use ${VAR_NAME} syntax to reference environment variables:

database: url: ${DATABASE_URL} server: port: ${PORT:-4000} # With default value

Default Values

# ${VAR:-default} - Use default if VAR is unset or empty port: ${PORT:-4000} # ${VAR-default} - Use default only if VAR is unset host: ${HOST-localhost}
Last updated on