Files
nginx-serve/conf/sqlite_serve.conf
Edward Langley a4a838ad3b Consolidate examples into unified production config with static CSS
- New sqlite_serve.conf: all features on single port 8080
- New zenburn.css: hex color palette, all styles in one cacheable file
- New Zenburn templates: header/footer/card partials
- New start.sh: unified launcher with all endpoint docs
- Removed 3 separate example configs and start scripts

15 files changed, 980 insertions(+), 258 deletions(-)
2025-11-15 16:42:05 -08:00

115 lines
3.7 KiB
Plaintext

# sqlite-serve - Unified Production Example
# Demonstrates all features: static queries, positional params, named params, templates
load_module target/debug/libsqlite_serve.dylib;
worker_processes auto;
events {
worker_connections 1024;
}
error_log logs/error.log warn;
http {
# Global templates for shared components
sqlite_global_templates "server_root/global_templates";
# MIME types
types {
text/html html htm;
text/css css;
application/javascript js;
}
default_type text/html;
# Performance optimizations
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
gzip on;
server {
listen 8080;
server_name localhost;
root "server_root";
charset utf-8;
# Serve static CSS file
location /static/ {
add_header "Content-Type" "text/css; charset=utf-8";
add_header "Cache-Control" "public, max-age=31536000";
}
# Homepage - Redirect to catalog
location = / {
return 302 /books;
}
# Browse all books
location = /books {
add_header "Content-Type" "text/html; charset=utf-8";
add_header "Cache-Control" "public, max-age=300";
sqlite_db "book_catalog.db";
sqlite_query "SELECT * FROM books ORDER BY rating DESC, title";
sqlite_template "catalog.hbs";
}
# Book detail by ID (named parameter)
location = /book {
add_header "Content-Type" "text/html; charset=utf-8";
add_header "Cache-Control" "public, max-age=300";
sqlite_db "book_catalog.db";
sqlite_query "SELECT * FROM books WHERE id = :book_id";
sqlite_param :book_id $arg_id;
sqlite_template "detail.hbs";
}
# Filter by genre (named parameter)
location = /genre {
add_header "Content-Type" "text/html; charset=utf-8";
add_header "Cache-Control" "public, max-age=300";
sqlite_db "book_catalog.db";
sqlite_query "SELECT * FROM books WHERE genre = :genre ORDER BY rating DESC, title";
sqlite_param :genre $arg_genre;
sqlite_template "catalog.hbs";
}
# Search by title (named parameter with LIKE)
location = /search {
add_header "Content-Type" "text/html; charset=utf-8";
sqlite_db "book_catalog.db";
sqlite_query "SELECT * FROM books WHERE title LIKE '%' || :q || '%' ORDER BY rating DESC";
sqlite_param :q $arg_q;
sqlite_template "catalog.hbs";
}
# Filter by minimum rating (named parameter)
location = /top {
add_header "Content-Type" "text/html; charset=utf-8";
sqlite_db "book_catalog.db";
sqlite_query "SELECT * FROM books WHERE rating >= :min_rating ORDER BY rating DESC, title";
sqlite_param :min_rating $arg_min;
sqlite_template "catalog.hbs";
}
# Year range filter (multiple named parameters)
location = /era {
add_header "Content-Type" "text/html; charset=utf-8";
sqlite_db "book_catalog.db";
sqlite_query "SELECT * FROM books WHERE year >= :from AND year <= :to ORDER BY year DESC, title";
sqlite_param :from $arg_from;
sqlite_param :to $arg_to;
sqlite_template "catalog.hbs";
}
# 404 handler
location @notfound {
add_header "Content-Type" "text/html; charset=utf-8";
return 404 "<html><body><h1>404 Not Found</h1><p><a href='/books'>Back to catalog</a></p></body></html>";
}
}
}