Skip to content

IanDarwin/bookmarks-backend

Repository files navigation

Bookmarks REST via quarkus and Java EE

This project displays one’s saved web bookmarks by category, for use by a REST client application. As distributed it provides access to a tiny sample of bookmarks, loaded from import.sql. The project uses Quarkus, "the Supersonic Subatomic Java Framework." Quarkus is a good way to build mini- and micro-services.

In production, a different application writes entries into a PostgreSQL relational database that this backend reads from (see https://github.com/IanDarwin/bookmark-swingui). And a third application displays lists for the user to review and open pages in the bookmarks. There’s a mobile version partly written, written in the Flutter cross-platform SDK.

Prerequisites:

You need a modern Java installed and on your PATH, and Apache Maven installed and on PATH.

BEFORE RUNNING

Since I don’t want to commit the config files with my live configuration information, you have to copy a couple of files:

  • In src/main/resources, copy the file application.properties.sample to application.properties

  • In the same place, copy META-INF/persistence.xml.sample to META-INF/persistence.xml

    • If you miss or mess these steps you will get "no datasource" or "missing database table" messages!

Sample commands for Unix/Linux:

cd src/main/resources
cp application.properties.sample application.properties
cp META-INF/persistence.xml.sample META-INF/persistence.xml
cd -

Startup:

  • Use make run or just run mvn quarkus:dev

  • Open a browser to http://localhost:8080/.

  • Make sure all the demos work.

  • The POST demo isn’t on the web page; run the script trypost in a shell window.

To use a real database, make the obvious changes in the two files you copied, application.properties and src/main/resources/META-INF/persistence.xml

TODO

"Consider adding security?" No. Do it, before you go live with this, now that this API has some write modes (no longer read-only). See, for example, https://quarkus.io/guides/security-basic-authentication-tutorial.

Packaging etc.

To run tests, or package, you may have to use the mvnw front-end to Maven. See README-quarkus.md for details.

Docker (completely untested)

I did this already: ./mvnw quarkus:add-extension -Dextensions="container-image-docker"

To build for docker, try ./mvnw clean package -Dquarkus.container-image.build=true

About Quarkus

A simplification layer for building microservices. Lots of tooling. Initial creation of this project, including a working "Hello, world" REST service, was created with just this:

mvn io.quarkus:quarkus-maven-plugin:1.12.1.Final:create \
   -DprojectGroupId=com.darwinsys \
   -DprojectArtifactId=bookmarks.backend \
   -DclassName="com.darwinsys.quarkus.BookmarksResource" \
   -Dpath="/hello"
cd bookmarks.backend

If you want to learn more about Quarkus, most of the original README is in README.quarkus.md

If you want to build a project with more capabilities than are used here (lots are supported), visit https://code.quarkus.io, check some boxes, and click Generate your application.

About

Quarkus-based deploy of a Java microservice for web bookmarks (read-only to keep it simple).

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published