Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
103 changes: 103 additions & 0 deletions .github/workflows/astro.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
# Sample workflow for building and deploying an Astro site to GitHub Pages
#
# To get started with Astro see: https://docs.astro.build/en/getting-started/
#
name: Deploy Astro site to Pages

on:
# Runs on pushes targeting the default branch
push:
branches: ["main", "epic/v0.2.1"]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "pages"
cancel-in-progress: false

env:
BUILD_PATH: "docs/" # default value when not using subfolders
# BUILD_PATH: subfolder

jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Detect package manager
id: detect-package-manager
run: |
if [ -f "${{ github.workspace }}/${{ env.BUILD_PATH }}/pnpm-lock.yaml" ]; then
echo "manager=pnpm" >> $GITHUB_OUTPUT
echo "command=install --frozen-lockfile" >> $GITHUB_OUTPUT
echo "runner=pnpm" >> $GITHUB_OUTPUT
echo "lockfile=pnpm-lock.yaml" >> $GITHUB_OUTPUT
exit 0
elif [ -f "${{ github.workspace }}/${{ env.BUILD_PATH }}/yarn.lock" ]; then
echo "manager=yarn" >> $GITHUB_OUTPUT
echo "command=install" >> $GITHUB_OUTPUT
echo "runner=yarn" >> $GITHUB_OUTPUT
echo "lockfile=yarn.lock" >> $GITHUB_OUTPUT
exit 0
elif [ -f "${{ github.workspace }}/${{ env.BUILD_PATH }}/package.json" ]; then
echo "manager=npm" >> $GITHUB_OUTPUT
echo "command=ci" >> $GITHUB_OUTPUT
echo "runner=npx --no-install" >> $GITHUB_OUTPUT
echo "lockfile=package-lock.json" >> $GITHUB_OUTPUT
exit 0
else
echo "Unable to determine package manager"
exit 1
fi
- name: Install pnpm
if: steps.detect-package-manager.outputs.manager == 'pnpm'
uses: pnpm/action-setup@v4
with:
version: 11
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: "24"
cache: ${{ steps.detect-package-manager.outputs.manager }}
cache-dependency-path: ${{ env.BUILD_PATH }}/${{ steps.detect-package-manager.outputs.lockfile }}
- name: Setup Pages
id: pages
uses: actions/configure-pages@v5
- name: Install dependencies
run: ${{ steps.detect-package-manager.outputs.manager }} ${{ steps.detect-package-manager.outputs.command }}
working-directory: ${{ env.BUILD_PATH }}
- name: Build with Astro
run: |
${{ steps.detect-package-manager.outputs.runner }} astro build \
--site "${{ steps.pages.outputs.origin }}" \
--base "${{ steps.pages.outputs.base_path }}"
working-directory: ${{ env.BUILD_PATH }}
env:
NODE_OPTIONS: "--max-old-space-size=8192"
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: ${{ env.BUILD_PATH }}/dist

deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
needs: build
runs-on: ubuntu-latest
name: Deploy
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v5
65 changes: 32 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
![License](https://img.shields.io/github/license/Bernardusz/levtus)
![Maven Release](https://img.shields.io/github/actions/workflow/status/Bernardusz/levtus/release.yml?label=maven%20release)

**Levtus** (Latin: *Levis Conatus* - "Light Effort") is a high-performance, zero-dependency HTTP/1.1 engine built from the ground up for the modern JVM. It is designed to be lightweight, secure, and incredibly fast by leveraging the power of **Java 21+ Virtual Threads (Project Loom)**.
**Levtus** (Latin: *Levis Conatus* - "Light Effort") is a high-performance, zero-dependency HTTP/1.1 engine built from the ground up for the modern JVM. It is designed to be lightweight, secure, and incredibly fast by leveraging the power of **Java 21+ Virtual Threads (Project Loom)** and **Java 25+ Unnamed Instances**.

> "Infrastructure should be simple, transparent, and built to last."

Expand All @@ -18,6 +18,7 @@
- 📦 Zero External Dependencies: No runtime overhead, no third-party version conflicts, and tiny deployment binaries.
- 🌳 Trie-Based Router: Route matching speed is proportional only to the depth of your URL segments (O(L)), making it consistently fast even as you add hundreds of endpoints.
- 🔒 Built-In Security Guards: Configurable hardware safeguards prevent denial-of-service (DoS) attempts by enforcing strict size boundaries on headers during stream consumption.
- 🌟Top focus on DX and Explicitness: Levtus focused on giving the best of Developer Experience, Explicitness, and Performance.
- 🎯 Native Java Performance: Optimized for Java 25+, taking full advantage of modern platform innovations.

---
Expand All @@ -27,7 +28,7 @@
- **Loom-Native Concurrency:** Uses a `newVirtualThreadPerTaskExecutor` to handle thousands of concurrent connections with minimal memory footprint.
- **Trie-Based Routing:** Features a high-performance Prefix Tree (Trie) router for $O(K)$ route matching (where $K$ is the path length).
- **Zero Dependencies:** Pure Java. No external libraries, no "DLL hell," and ultra-small JAR size.
- **Hardened Security:** Built-in protection against:
- **Configureable and Hardened Security:** Built-in protection against:
- **Path Traversal:** Secure `render()` logic with path normalization.
- **Memory Exhaustion:** Configurable limits for headers, body size, and line lengths.
- **Connection Overload:** Semaphore-based throttling to protect system resources.
Expand All @@ -41,34 +42,32 @@
```java
import io.github.bernardusz.levtus.Levtus;

public class Main {
public static void main(String[] args) {
Levtus app = Levtus.create();

// Middleware support
app.use((ctx, next) -> {
System.out.println("Request received: " + ctx.req().path());
next.run();
});

// Simple GET route
app.get("/hello", ctx -> {
ctx.text("Hello from the Levtus Engine!");
});

// Dynamic routing with path params
app.get("/user/{id}", ctx -> {
String userId = ctx.param("id");
ctx.json("{\"id\": \"" + userId + "\"}");
});

// Secure static file rendering
app.get("/", ctx -> {
ctx.render("index.html");
});

app.listen(8080);
}
void main() { // Java 25 Unnamed Instances!
Levtus app = Levtus.create();

// Middleware support
app.use((ctx, next) -> {
System.out.println("Request received: " + ctx.req().path());
next.run();
});

// Simple GET route
app.get("/hello", ctx -> {
ctx.text("Hello from the Levtus Engine!");
});

// Dynamic routing with path params
app.get("/user/{id}", ctx -> {
String userId = ctx.param("id");
ctx.json("{\"id\": \"" + userId + "\"}");
});

// Secure static file rendering
app.get("/", ctx -> {
ctx.render("index.html");
});

app.listen(8080);
}
```

Expand All @@ -86,9 +85,9 @@ public class Main {
### Security Configurations
Levtus gives you fine-grained control over your server's surface area:
```java
app.setMaxBodySize(10 * 1024 * 1024); // 10MB limit
app.setMaxHeaderCount(100);
app.setMaxLineSize(8192); // Prevent Slowloris attacks
app.maxBodySize(10 * 1024 * 1024); // 10MB limit
app.maxHeaderCount(100);
app.maxLineSize(8192); // Prevent Slowloris attacks
```

---
Expand Down
21 changes: 21 additions & 0 deletions docs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# build output
dist/
# generated types
.astro/

# dependencies
node_modules/

# logs
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*


# environment variables
.env
.env.production

# macOS-specific files
.DS_Store
22 changes: 22 additions & 0 deletions docs/AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
## Development

When starting the dev server, use background mode:

```
astro dev --background
```

Manage the background server with `astro dev stop`, `astro dev status`, and `astro dev logs`.

## Documentation

Full documentation: https://docs.astro.build

Consult these guides before working on related tasks:

- [Adding pages, dynamic routes, or middleware](https://docs.astro.build/en/guides/routing/)
- [Working with Astro components](https://docs.astro.build/en/basics/astro-components/)
- [Using React, Vue, Svelte, or other framework components](https://docs.astro.build/en/guides/framework-components/)
- [Adding or managing content](https://docs.astro.build/en/guides/content-collections/)
- [Adding styles or using Tailwind](https://docs.astro.build/en/guides/styling/)
- [Supporting multiple languages](https://docs.astro.build/en/guides/internationalization/)
1 change: 1 addition & 0 deletions docs/CLAUDE.md
49 changes: 49 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Starlight Starter Kit: Basics

[![Built with Starlight](https://astro.badg.es/v2/built-with-starlight/tiny.svg)](https://starlight.astro.build)

```
pnpm create astro@latest -- --template starlight
```

> 🧑‍🚀 **Seasoned astronaut?** Delete this file. Have fun!

## 🚀 Project Structure

Inside of your Astro + Starlight project, you'll see the following folders and files:

```
.
├── public/
├── src/
│ ├── assets/
│ ├── content/
│ │ └── docs/
│ └── content.config.ts
├── astro.config.mjs
├── package.json
└── tsconfig.json
```

Starlight looks for `.md` or `.mdx` files in the `src/content/docs/` directory. Each file is exposed as a route based on its file name.

Images can be added to `src/assets/` and embedded in Markdown with a relative link.

Static assets, like favicons, can be placed in the `public/` directory.

## 🧞 Commands

All commands are run from the root of the project, from a terminal:

| Command | Action |
| :------------------------ | :----------------------------------------------- |
| `pnpm install` | Installs dependencies |
| `pnpm dev` | Starts local dev server at `localhost:4321` |
| `pnpm build` | Build your production site to `./dist/` |
| `pnpm preview` | Preview your build locally, before deploying |
| `pnpm astro ...` | Run CLI commands like `astro add`, `astro check` |
| `pnpm astro -- --help` | Get help using the Astro CLI |

## 👀 Want to learn more?

Check out [Starlight’s docs](https://starlight.astro.build/), read [the Astro documentation](https://docs.astro.build), or jump into the [Astro Discord server](https://astro.build/chat).
52 changes: 52 additions & 0 deletions docs/astro.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// @ts-check
import { defineConfig } from 'astro/config';
import starlight from '@astrojs/starlight';

// https://astro.build/config
export default defineConfig({
site: 'https://bernardusz.github.io',
base: '/levtus/', // Ensures all internal links use the repository prefix
integrations: [
starlight({
title: 'Levtus',
favicon: './src/assets/Levtus_Logo-Dark_Mode.svg',
social: [{ icon: 'github', label: 'GitHub', href: 'https://github.com/Bernardusz/Levtus' }],
sidebar: [
{
label: 'Docs',
items: [
// Each item here is one entry in the navigation menu.
{ label: 'Introduction', slug: 'docs' },
{ label: 'Getting Started', slug: 'docs/getting-started' },
{
label: 'API',
collapsed: true,
items: [
{ label: 'Application Creation', slug: 'docs/api/application-creation' },
{ label: 'Creating a Route', slug: 'docs/api/routing-parameters' },
{ label: 'Request API', slug: 'docs/api/request-api' },
{ label: 'Response API', slug: 'docs/api/response-api' },
{ label: 'Levtus Context API', slug: 'docs/api/levtus-context-api' },
{ label: 'Levtus Configuration', slug: 'docs/api/levtus-configuration' },
{ label: 'SSL/TLS Configuration', slug: 'docs/api/ssl-tsl-setup' },
{ label: 'Middleware Configuration', slug: 'docs/api/middleware' }
]
}
],
},
{
label: 'Contributing',
slug: 'contributing-and-support',
},
],
logo: {
light: "./src/assets/Levtus_Logo-Light_Mode.svg",
dark: "./src/assets/Levtus_Logo-Dark_Mode.svg",
replacesTitle: true,
},
customCss: [
'./src/styles/style.css',
],
}),
],
});
17 changes: 17 additions & 0 deletions docs/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "",
"type": "module",
"version": "0.0.1",
"scripts": {
"dev": "astro dev",
"start": "astro dev",
"build": "astro build",
"preview": "astro preview",
"astro": "astro"
},
"dependencies": {
"@astrojs/starlight": "^0.41.4",
"astro": "^7.0.2",
"sharp": "^0.34.5"
}
}
Loading
Loading