stk

command module
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2023 License: MIT Imports: 1 Imported by: 3

README

STK

Server toolkit - minimal and simple framework for developing server in golang

Build and Test codecov Go Release Workflow

STK provides a suite of tools tailored for building and managing server applications.

Features:

  • GSK (library): Ideal for constructing servers.
  • STK CLI:
    • Quickly scaffold your project and add modules with ease. It uses gsk package to run the server.
    • Migrator: Generate migration files, perform migration on your sql database.

Installation

with go install

go install github.com/adharshmk96/stk@latest

If installation fails, check the GOPATH and GOBIN environment variables. Make sure that GOBIN is added to your PATH.


echo export PATH=$PATH:$GOBIN >> ~/.bashrc
source ~/.bashrc

Get started ( with CLI )

  1. Setup and initialize a project scaffolded using gsk and clean arch format. Read more about the project structure here
stk init
  1. Start the server
make run

it will run go run . serve -p 8080 command

  1. Test the server
curl http://localhost:8080/api/ping

Checkout the library documentation here

Add Modules to project

To add a new module "auth" to the project run the following command

stk add -m auth

you can use it by adding setupAuthRoutes to the routing/initRoutes.go file

example:

package routing

import (
	"github.com/adharshmk96/stk/gsk"
)

func SetupRoutes(server *gsk.Server) {
	setupPingRoutes(server)
	setupAuthRoutes(server)
}

To remove a module "auth" from the project run the following command

stk rm -m auth

you can remove the module by removing setupAuthRoutes from the routing/initRoutes.go file

example:

package routing

import (
	"github.com/adharshmk96/stk/gsk"
)

func SetupRoutes(server *gsk.Server) {
	setupPingRoutes(server)
}

Migrator

  • CLI tool for generating migration files and running migrations
  • Supports sqlite3 (default)
Get started

Generate migration files ( optinally name it and fill )

stk migrator generate -n "initial migration" --fill

migrate up ( applies all migrations, or specified number of steps )

stk migrator up

migrate down ( applies all down migrations, or specified number of steps )

stk migrator down

History - Shows history of applied migrations

stk migrator history

Development

refer development docs

Documentation

Overview

Copyright © 2023 Adharsh M dev@adharsh.in

Jump to

Keyboard shortcuts

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