Skip to content
This repository has been archived by the owner on Jun 27, 2023. It is now read-only.

reno-router/blog-microservice

Repository files navigation

Blog Microservice

CI

Notice

⚠️ Reno has been sunset, and will thus no longer receive updates. The final version is v2.0.105, which supports Deno 1.34.3 and std 0.192.0.

It is recommended that you use an alternative routing library or HTTP framework, such as Oak or Opine.

Thank you to anyone who supported the project during its lifetime.

Reno: 2019-2023


An example Reno microservice for creating and fetching blog posts from a PostgreSQL database.

Running Locally

This repo includes a Docker Compose configuration and a dedicated Dockerfile for local development, which together will:

  • run a Postgres container, boostrapped with the provided SQL initialisation and seed scripts
  • create a local network that's shared by both the database and microservice containers
  • start the microservice via Denon, automatically restarting whenever the source code changes

If you haven't already, install Docker and Docker Compose, after which it's simply a case of running:

$ mv .env.sample .env
$ docker-compose up

The service will be available on port 8000, against which any of the requests under Operations can be made.

$ curl http://localhost:8000/posts

Developer Experience Protip

You can install the Deno dependencies and their accompanying TypeScript definitions onto your host machine by running deno cache deps.ts; this isn't a prerequisite to running the service, but will allow your TS-enabled editor to discover said definitions, vastly improving the local development experience.

Unit Tests

This project has extensive unit test coverage. The test suite can be invoked with deno test service.

Operations

GET /posts

Retrieves metadata for all of the posts in the database.

GET /posts/<UUID>

Retrieves the metadata and content of the post with the given UUID.

POST /posts

Adds a new post to the database.

Request body

{
  "title": "My new post",
  "contents": "Here's the content body of my post",
  "authorId": "<Author UUID>",
  "tagIds": ["<Tag UUID>", ..."<Tag UUID>"]
}

PATCH /posts/<UUID>

Replaces the contents property of the post with the given UUID.

Request body

{
  "contents": "Here's the updated content body of my post"
}