+
Skip to content

Lord-Lava/bookstore

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BOOKSTORE CRUD API

This is a RESTful CRUD API for managing books in a bookstore, built in Golang using the Gin web framework and integrated with MongoDB using the mgm ODM package.

Features

  • Create, Read, Update, and Delete books using RESTful API endpoints
  • MongoDB integration using the mgm ODM package
  • Hooks for Creating and Updating books
  • Validation for the book model
  • Logging using the Zap package
  • Configurations using YAML files
  • Support for environment variables

Environment Variables

To run this project, you will need to add the following environment variables to your .env file

DB_NAME

MONGODB_URI

LOG_PATH

Run Locally

Clone the project

  git clone https://github.com/snehil-sinha/bookstore.git

Go to the project directory

  cd bookstore

Install dependencies

  go mod download

The service configuration needs to be specified as a YAML file

  env: development  # allowed values: development production
  port: 8080
  bind: 0.0.0.0

Start the server

  go run main.go

Note: You can alternatively build the project to generate a binary executable file called goBookStore and use it to start the server

  go build

API Reference

Link to the postman API doc: https://documenter.getpostman.com/view/25819993/2s93CLrtDN

Usage

The following endpoints are available:

  • GET /health: Health check endpoint.
  • GET /api/v1/books: Get all books.
  • GET /api/v1/books/:id: Get a specific book by ID.
  • POST /api/v1/books: Create a new book.
  • PUT /api/v1/books/:id: Update an existing book by ID.
  • DELETE /api/v1/books/:id: Delete an existing book by ID.

Authors

🚀 About Me

Exploring backend with Golang...

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载