Skip to content

DoGab/notes-api

Repository files navigation

notes-api

test workflow Go Report Card

Notes API written in Go using the Fiber web framework

Project setup

  1. Create the project
mkdir notes-api
cd notes-api
go mod init github.com/dogab/notes-api
# Open Editor in in the directory where the go.mod file is
go get github.com/gofiber/fiber/v2
touch main.go
go run main.go
  1. Used for the makefile to hot reload the server
go install github.com/cespare/reflex@latest
touch Makefile
make watch
  1. Setup env file for storing the config variables
touch .env
go get github.com/joho/godotenv
mkdir config
touch config/config.go
  1. Setup database
touch docker-compose.yaml
mkdir database
touch database/database.go

go get gorm.io/gorm
go get gorm.io/driver/postgres
  1. Create Models
mkdir model
touch model/model.go

go get github.com/google/uuid
  1. Create router
mkdir router
touch router/router.go
  1. Add routes
mkdir routes
mkdir routes/note
touch routes/note/note.go
  1. Add handlers
mkdir handlers
mkdir handlers/note
touch handlers/note/note.go
  1. Swagger Add comments to the handler functions. https://github.com/arsmn/fiber-swagger
# Add comments to the files
go get -u github.com/swaggo/swag/cmd/swag
swag init
go get -u github.com/arsmn/fiber-swagger/v2
import "github.com/arsmn/fiber-swagger/v2"
import "github.com/dogab/docs"
  1. Encrypt passwords Add encrypted passwords.
go get golang.org/x/crypto/bcrypt
  1. Use JWT Auth Use this in the package for the jwt function.
go get github.com/golang-jwt/jwt/v4

Use this in the package where the Middleware should be used for the routes.

go get  github.com/gofiber/jwt/v3

Todos

About

Notes API written in Go using the Fiber web framework

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published