No As A Service
Find a file
Ole-Morten Duesund 9215a542f7 Update Cargo.lock and CLAUDE.md with release process notes
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-29 14:15:33 +02:00
debian Fix Debian package format to native 2025-09-29 14:14:04 +02:00
src Add Open Graph meta tags and source repository link 2025-09-29 14:08:13 +02:00
Cargo.lock Update Cargo.lock and CLAUDE.md with release process notes 2025-09-29 14:15:33 +02:00
Cargo.toml Bump version to 1.0.2 2025-09-29 14:10:51 +02:00
CLAUDE.md Update Cargo.lock and CLAUDE.md with release process notes 2025-09-29 14:15:33 +02:00
Containerfile Initial commit: Add NaaS (No as a Service) implementation 2025-09-27 16:42:47 +02:00
LICENSE Add MIT license and fix Debian packaging 2025-09-29 13:46:19 +02:00
naas.service Initial commit: Add NaaS (No as a Service) implementation 2025-09-27 16:42:47 +02:00
README.md Add MIT license and fix Debian packaging 2025-09-29 13:46:19 +02:00

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 playground
  • GET /api/no - Returns plain text "no"
  • GET /api/no?format=json - Returns {"answer": "no"}
  • GET /api/no?format=bool - Returns false
  • GET /api/no?format=xml - Returns XML response
  • GET /api/no?format=yaml - Returns YAML response
  • GET /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

  1. 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
  1. 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
  1. 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

  1. Deploy application using systemd service (see above)

  2. Configure Caddy with the above Caddyfile configuration (SSL certificates are automatic with Caddy)

  3. 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.