Git Product home page Git Product logo

notes-api's Introduction

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.