Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
SentryMan committed Sep 3, 2024
0 parents commit a22c9d2
Show file tree
Hide file tree
Showing 43 changed files with 2,722 additions and 0 deletions.
29 changes: 29 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
version: 2
updates:
- package-ecosystem: "maven"
directory: "/"
schedule:
interval: weekly
open-pull-requests-limit: 10
groups:
dependencies:
patterns:
- "*"
labels:
- "dependencies"
target-branch: "master"

- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
open-pull-requests-limit: 5
commit-message:
prefix: "[workflow]"
labels:
- "dependencies"
target-branch: "master"
groups:
dependencies:
patterns:
- "*"
38 changes: 38 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Build

on: [push, pull_request, workflow_dispatch]

jobs:
build:

runs-on: ${{ matrix.os }}
permissions:
contents: read
packages: write
strategy:
fail-fast: false
matrix:
java_version: [11,17,21]
os: [ubuntu-latest]

steps:
- uses: actions/checkout@v4
- name: Set up Java
uses: actions/setup-java@v4
with:
java-version: ${{ matrix.java_version }}
distribution: 'zulu'
- name: Maven cache
uses: actions/cache@v4
env:
cache-name: maven-cache
with:
path:
~/.m2
key: build-${{ env.cache-name }}
- name: Maven version
run: mvn --version
- name: Build with Maven
run: mvn clean test
- name: Build with Maven (javax)
run: ./jakarta-to-javax.sh && mvn clean test && ./javax-to-jakarta.sh
28 changes: 28 additions & 0 deletions .github/workflows/dependabot-merge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Dependabot auto-merge
on: pull_request

permissions:
contents: write
pull-requests: write

jobs:
dependabot:
runs-on: ubuntu-latest
if: ${{ github.actor == 'dependabot[bot]' }}
steps:
- name: Dependabot metadata
id: metadata
uses: dependabot/fetch-metadata@v2
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
- name: Approve a PR
run: gh pr review --approve "$PR_URL"
env:
PR_URL: ${{github.event.pull_request.html_url}}
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
# Enable for automerge
- name: Enable auto-merge for Dependabot PRs
run: gh pr merge --auto --merge "$PR_URL"
env:
PR_URL: ${{github.event.pull_request.html_url}}
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
12 changes: 12 additions & 0 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Google Format

on: [push, workflow_dispatch]

jobs:
formatting:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4 # v2 minimum required
- uses: axel-op/googlejavaformat-action@v3
with:
args: "--skip-sorting-imports --replace"
39 changes: 39 additions & 0 deletions .github/workflows/jdk-ea-stable.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@

name: avaje-sigma EA stable

on:
push:
pull_request:
workflow_dispatch:
schedule:
- cron: '39 1 * * 1,3,5'

jobs:
build:

runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- uses: actions/checkout@v4
- name: Set up Java
uses: oracle-actions/setup-java@v1
with:
website: jdk.java.net
release: ea
version: stable
- name: Maven cache
uses: actions/cache@v4
env:
cache-name: maven-cache
with:
path:
~/.m2
key: build-${{ env.cache-name }}
- name: Maven version
run: mvn --version
- name: Build with Maven
run: mvn package

43 changes: 43 additions & 0 deletions .github/workflows/jdk-ea.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@

name: avaje-sigma EA

on:
push:
pull_request:
workflow_dispatch:
schedule:
- cron: '39 1 * * 1,3,5'

jobs:
build:

runs-on: ${{ matrix.os }}
permissions:
contents: read
packages: write
strategy:
fail-fast: false
matrix:
java_version: [GA,EA] ## valhalla (fails javadoc)
os: [ubuntu-latest]

steps:
- uses: actions/checkout@v4
- name: Set up Java
uses: oracle-actions/setup-java@v1
with:
website: jdk.java.net
release: ${{ matrix.java_version }}
- name: Maven cache
uses: actions/cache@v4
env:
cache-name: maven-cache
with:
path:
~/.m2
key: build-${{ env.cache-name }}
- name: Maven version
run: mvn --version
- name: Build with Maven
run: mvn package

15 changes: 15 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
target/
build/
.idea/
*.iml
.gradle
*.prefs
*.class*
*.factorypath
*.project
*.processors
*/bin/

inject-generator/avaje-inject
inject-generator/avaje-inject-generator
inject-generator/avaje-processors.txt
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Avaje Sigma (Final Name TBD)

Provides javalin/jex style request handling for AWS lambda http requests.


```java
public class LambdaRequestHandler
implements RequestHandler<APIGatewayV2HttpEvent, AWSHttpResponse> {

AWSHttpHandler handler =
Sigma.create()
.routing(
r ->
r.get("/lambda", ctx -> ctx.text("Hello World"))
.get("/route2/{param}", ctx -> ctx.text(ctx.pathParam("param"))))
.createAWSHandler();

@Override
public AWSHttpResponse handleRequest(APIGatewayV2HttpEvent event, Context context) {

return handler.handle(event, context);
}
}
```
61 changes: 61 additions & 0 deletions avaje-sigma/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>io.avaje</groupId>
<artifactId>avaje-sigma-parent</artifactId>
<version>0.1-SNAPSHOT</version>
</parent>
<packaging>jar</packaging>
<artifactId>avaje-sigma</artifactId>
<scm>
<developerConnection>scm:git:git@github.com:avaje/avaje-sigma.git</developerConnection>
</scm>

<properties>
<maven.compiler.release>17</maven.compiler.release>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-lambda-java-core</artifactId>
<version>1.2.3</version>
</dependency>

<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.17.2</version>
<optional>true</optional>
</dependency>

<dependency>
<groupId>io.avaje</groupId>
<artifactId>avaje-jsonb</artifactId>
<version>2.1</version>
<optional>true</optional>
</dependency>

<dependency>
<groupId>io.avaje</groupId>
<artifactId>junit</artifactId>
<version>1.5</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<forkCount>0</forkCount>
</configuration>
</plugin>
</plugins>
</build>
</project>
14 changes: 14 additions & 0 deletions avaje-sigma/src/main/java/io/avaje/sigma/AWSHttpHandler.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package io.avaje.sigma;

import com.amazonaws.services.lambda.runtime.Context;

import io.avaje.sigma.aws.events.AWSHttpResponse;
import io.avaje.sigma.aws.events.AWSRequest;

/**
* The configured handler that takes AWS HTTP Requests, routes the request to the correct function
* and performs error handling
*/
public interface AWSHttpHandler {
<T extends AWSRequest> AWSHttpResponse handle(T request, Context ctx);
}
17 changes: 17 additions & 0 deletions avaje-sigma/src/main/java/io/avaje/sigma/ExceptionHandler.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package io.avaje.sigma;

/**
* Defines an interface for handling exceptions in a given HTTP context.
*
* @param <T> The specific type of exception to handle.
*/
public interface ExceptionHandler<T extends Exception> {

/**
* Handles the given exception.
*
* @param exception The exception to handle.
* @param ctx The HTTP context of the invocation.
*/
void handle(T exception, HttpContext ctx);
}
17 changes: 17 additions & 0 deletions avaje-sigma/src/main/java/io/avaje/sigma/Handler.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package io.avaje.sigma;

/**
* Functional interface for handling HTTP requests.
*
* @see HttpContext
*/
@FunctionalInterface
public interface Handler {

/**
* Handles the given HTTP request context.
*
* @param req The HTTP request context.
*/
void handle(HttpContext req);
}
Loading

0 comments on commit a22c9d2

Please sign in to comment.