go-serverus

command module
v0.0.0-...-06572e6 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2024 License: MIT Imports: 13 Imported by: 0

README

GoServerus logo

GoServerus

A flexible and up-to-standard boilerplate code for golang backends intended for mobile applications.

Features

Feature Status
Basic Authentication
PostgreSQL Database Handler
Redis Caching
Ratelimiter
Categorized Directories
Easy Error Handling
Log System
Documentations TODO

Getting Started

Before starting, please read Database and Caching to know how the database and caching systems are supposed to be handled.

Development

For development purposes, it is recommended to start a seperate redis and PostgreSQL server in localhost, (and set up the .env files) and then run with:

$ go run .

Production

For production, use docker-compose, so that the program is dockerized and redis starts in the same server as the API.

Start docker-compose with:

$ docker compose up

Authentication

GoServerus uses a JWT basic authentication without refresh tokens.

[!NOTE] Refresh tokens are not used because it is intended for users (in their mobile apps) to store username and password, and that will be used to "refresh" the token.

[!WARNING] If you think this is not secure, it is recommended to tweak the authentication system.

Authentication features include:

  • Email confirmations (can use any SMTP server)
  • Basic Login/Register
  • OAuth2 Sign In
  • Forgot Password

Database

GoServerus uses PostgreSQL for its database. Configurations are recommended to be included in the .env file.

It is intended that the database server is seperate from the API server, Caching is used to speed up requests.

Current .env configurations:

POSTGRES_URI = "postgres://postgres:password@localhost:5432/serverus_db"

please customize as needed.

Caching

Caching uses redis that is in the same server as the API, it is NOT recommended to use redis seperate from the API server, because the network latency will nullify caching speed-up effects.

To make it easier, there is a docker-compose.yml file that has been customized to dockerize the API, and also start redis in the same server.

Ratelimiter

A ratelimiter is used so that a user cannot spam the API (and take down the server, such as DDOS attacks).

Its configurations can be changed in the env/env.go file, NOT in the .env file

Directories

To make GoServerus as flexible and as friendly to developers as possible

Documentations

Currently, documentations are not available. Some functions might have a bit of documentations, but they are currently not formatted neatly.

Important or dangerous functions always have notes of when to use them and how.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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