Skip to content

avaje/avaje-httpserver-realworld

 
 

Repository files navigation

RealWorld Example App

Avaje + Ebean + JDK HTTP Server codebase containing real world examples (CRUD, JWT auth, advanced patterns, etc) that adheres to the RealWorld spec and API.

This codebase was created to demonstrate a lightweight fully modular backend application built with the JDK HTTP Server including CRUD operations, authentication, routing, pagination, and more.

For more information on how this works with other frontends/backends, head to the RealWorld repo.

It is deployed to https://avaje-httpserver-realworld.onrender.com

How it works

This is built up of a few components. Primarily:

  • The jdk.httpserver module as the HTTP Server implementation.
  • Avaje Jex to configure and provide routing abstraction over the jdk.httpserver. This is the API programmed against
  • Ebean ORM for the Connection Pooling and ORM
  • Postgresql as the database
  • RainbowGum for logging

Then, serving specific tasks:

Getting started

Prerequisites

  • Java 24 or above
  • MyBatis (can be installed with SDKMAN)
  • Docker

Usage

1. Start up postgres container

$ docker compose up -d

2. Apply the migrations to the database

$ cd migrations
$ migrate up
$ cd ..

3. Run the server

You can either

  • open the project in your editor
  • run it through terminal (./run.sh")
  • run it through docker
$ docker build -t real .
$ docker run real

You can then use the provided postman collection to send requests.

The .env file for this project is committed to the repo. Note that in general this is a bad idea/practice, but the only secrets here are for the local database connection so it's fine.

About

avaje jdk http server example

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 82.7%
  • HTML 8.0%
  • PLpgSQL 7.1%
  • Dockerfile 2.1%
  • Shell 0.1%