Thanks to visit codestin.com
Credit goes to github.com

Skip to content

SunnysideAaron/wetesa-1

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

wetesa-1

An example CRUD API. Uses Go as the language and PostgreSQL as a datastore. Web and mobile front ends.

Website is specifically designed to be run with with or without javascript and css.

As of 2025-05 this is just a stub while I work on the api part of what will eventually be here. I needed a place to start putting decision records on this project which will be far more opinionated and have far more dependencies.

Fork me, please! I know I will! :-)

TODO The rest of this is all from wetesa-0 will need to adjust later

Wetesa

Wetasa-0 is the very first example of a Wetesa! To learn more about the Wetesa concept see the wiki. The rest of this readme is about Wetesa-0.

Wetesa-0

The decisions going into making this example are documented in docs\Decision Records. For the TLDR see TSDR-000 and ADR-000.

Since Go 1.22 (2024-FEB) many recommend using the standard library instead of a framework. Most frameworks in Go were developed before Go 1.22 added better routing.

Found myself unable to find good, complete, and working examples of how to use the standard library to build an API. Specifically, around routing. Built the example I wanted! Leaned heavily on the information from How I write HTTP services in Go after 13 years by Mat Ryer

Wetesa-0 is not a framework! It is a fully working example of how to use the standard library to build an api. Is this how I would build an api? Possibly. If the project was small enough or if I was very concerned about having too many dependencies. TSDR-008 Possible Future Dependencies.md covers some ideas that might make sense to add / change depending on the project.

Ways to use Wetesa-0:

  • Example code for api routing using the standard library.
  • A base line for evaluating packages. How they would change code? What specific benefits do they bring.
  • The decision records as a starting point for any new project. Any api / project has to answer the same questions. Going through them and finding your own answers is a good way to start a new api / project.

Requirements

  • Docker
  • Make
    • There are several different ways to get Make installed. Google for your operating system.

Usage

Quick start

  • Install Requirements

  • Clone the Wetesa-0 repo to your computer

  • In your command prompt change your working directory to where you cloned Wetesa-0

  • This example uses 2 docker containers. "datastore" for PostreSQL and "api" for the api. The following command should bring them both up.

    make all-up
    
  • http://localhost:8080/healthz, http://localhost:8080/healthdbz, and http://localhost:8080/api/v0.1/clients Should all give responses.

  • make all-up will launch air on the api code. Air rebuilds the binary when ever it detects code changes.

  • To end the running services press ctrl-c. Then

    make all-down
    

Detailed usage

Additional make commands are provided for running the containers independently. This could be helpful depending on what one is trying to accomplish. For example:

in command prompt 1:

make ds-up

in command prompt 2:

make api-bash

Will launch the datastore service and leave you on the command line in the api service. Once inside the api service you can run go commands on the code as needed. For example:

make watch

will get you where make all-up got you.

Note there are two Make files. See ./Makefile and ./api/Makefile for additional commands.

Credits

This project borrows heavily from many sources. While it has traveled a bit from them we would like to thank them. Please check them out.

About

Example crud app with postgresql datastore. web and mobile front ends.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages