go-bun-webserver

module
v0.0.0-...-1d3a159 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 22, 2023 License: BSD-2-Clause

README

Go bunrouter + bun application example

build workflow PkgGoDev

Introduction

This project implements RealWorld JSON API as specified in the spec. It was created to demonstrate how to use:

Project structure

The project uses Bun starter kit and consists of the following packages:

  • bunapp package parses configs, establishes DB connections etc.
  • org package manages users and sessions.
  • blog package manages articles and comments.
  • cmd/bun provides CLI commands to run HTTP server and work with DB.
  • cmd/bun/migrations contains database migrations.

The most interesting part for Bun users is probably article filter.

Project bootstrap

Project comes with a Makefile that contains following recipes:

  • make start start docker containers, run migrations and run HTTP server.
  • make db_reset drops existing database and creates a new one.
  • make test runs unit tests.
  • make api_test runs API tests provided by RealWorld.

After checking that tests are passing you can run HTTP server:

go run cmd/bun/main.go -env=dev api

Directories

Path Synopsis
cmd
bun

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL