No As A Service
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> |
||
---|---|---|
debian | ||
src | ||
Cargo.lock | ||
Cargo.toml | ||
CLAUDE.md | ||
Containerfile | ||
LICENSE | ||
naas.service | ||
README.md |
No as a Service (NaaS)
A lightweight, production-ready HTTP service that always says "no" in various formats.
Features
- Minimal dependencies (pure Rust, standard library only)
- Multiple response formats (text, JSON, XML, YAML, boolean)
- Mobile-responsive web frontend
- CORS support
- Health check endpoint
- Optimized for small binary size (~1MB)
- Container-ready with health checks
API Endpoints
GET /
- Minimalist web page displaying "No"GET /playground
- Interactive API testing playgroundGET /api/no
- Returns plain text "no"GET /api/no?format=json
- Returns{"answer": "no"}
GET /api/no?format=bool
- Returnsfalse
GET /api/no?format=xml
- Returns XML responseGET /api/no?format=yaml
- Returns YAML responseGET /health
- Health check endpoint
Quick Start
Local Development
# Build and run locally
cd naas
cargo build --release
PORT=8080 ./target/release/naas
Visit http://localhost:8080
Container Deployment with Podman
# Build container
cd naas
BUILDAH_FORMAT=docker podman build -t naas:latest -f Containerfile .
# Run container
podman run -d \
--name naas \
-p 8080:8080 \
--restart=always \
naas:latest
# Check health
curl http://localhost:8080/health
Systemd Service Deployment
- Setup user and directory:
# Create service user
sudo useradd -r -s /bin/false naas
# Copy application files
sudo mkdir -p /opt/naas
sudo cp -r naas/* /opt/naas/
sudo chown -R naas:naas /opt/naas
- Install systemd service:
# Copy service file
sudo cp naas/naas.service /etc/systemd/system/
# Reload systemd and start service
sudo systemctl daemon-reload
sudo systemctl enable naas
sudo systemctl start naas
# Check status
sudo systemctl status naas
- View logs:
sudo journalctl -u naas -f
Production Deployment to no.donothireus.com
Caddy Reverse Proxy Configuration
no.donothireus.com {
reverse_proxy localhost:8080 {
header_up Host {host}
header_up X-Real-IP {remote_host}
header_up X-Forwarded-For {remote_host}
header_up X-Forwarded-Proto {scheme}
}
}
Full Production Setup
-
Deploy application using systemd service (see above)
-
Configure Caddy with the above Caddyfile configuration (SSL certificates are automatic with Caddy)
-
Restart services:
sudo systemctl restart caddy
sudo systemctl restart naas
Performance
- Binary size: ~1MB (release build with optimizations)
- Memory usage: <10MB
- Startup time: <100ms
- Request latency: <1ms
Development
Building from Source
# Debug build
cargo build
# Release build with optimizations
cargo build --release
# Run tests
cargo test
Container Build Options
# Multi-platform build (if needed)
podman build --platform linux/amd64,linux/arm64 -t naas:latest .
# Build with specific Rust version
podman build --build-arg RUST_VERSION=1.75 -t naas:latest .
Security
- Runs as non-root user (UID 1000)
- Read-only container filesystem
- No new privileges
- All capabilities dropped except NET_BIND_SERVICE
- Memory and CPU limits enforced
- CORS headers properly configured
License
This project is licensed under the MIT License - see the LICENSE file for details.
The MIT License is a permissive license that allows you to do almost anything with this code, including using it in commercial projects, modifying it, and distributing it, as long as you include the original copyright notice.