task-for-dell

module
v0.0.0-...-3bf3187 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2024 License: MIT

README

Blog and News API

This project is a Golang-based API using the Echo framework and Postgres database for managing and serving Blogs and News content.

Swagger UI - http://135.181.88.180:8000/swagger/index.html

Table of Contents

Features

  • Create, read, update, and delete blogs and news articles.
  • Postgres yordamida doimiy saqlash.
  • Swagger UI.
  • Docker.
  • CI/CD by Github Actions.
  • Test coverage
    • 100% in repository
    • 100% in UseCases
    • 78.9% in Handlers

Prerequisites

Tool & Technologies

List of tools and technologies used:

  • echo - Web framework
  • swag - Swagger
  • sqlx - Extensions to database/sql.
  • pgx - PostgreSQL driver and toolkit for Go
  • viper - Go configuration with fangs
  • zap - Logger
  • validator - Go Struct and Field validation
  • migrate - Database migrations. CLI and Golang library.
  • gomock - Mocking framework
  • testing - Testing
  • require - Checking test result
  • Docker - Docker
  • Database - PostgreSQL

Installation

1. Clone the repository:
git clone https://github.com/realtemirov/task-for-dell.git
cd task-for-dell
2. Install dependencies:
go mod download

Configuration

Before running the application, configure the necessary environment variables. Enter the configuration folder and configure the environment you want.

cd config
nano config-local.yml

Usage

1. Run the application with docker-compose:
docker compose up -d            // run containers with docker-compose
2. Run the application with container:
make start                      // run postgres container and migration-up
make run                        // run app
3. Run Local app:
go run cmd/main.go              // equal -> make run
4. Run Test:
make test
5. Swagger UI

http://localhost:8000/swagger/index.html

API Endpoints

  • Create a Blog/News Content

    POST /v1/blogs

    {
      "title": "Sample Title",
      "content": "Lorem ipsum dolor sit amet, consectetur adipiscing elit."
    }
    

    POST /v1/news

    {
      "title": "Sample Title",
      "content": "Lorem ipsum dolor sit amet, consectetur adipiscing elit."
    }
    
  • Update Content by ID

    PUT /v1/blogs/:id

    {
      "title": "Sample Title",
      "content": "Lorem ipsum dolor sit amet, consectetur adipiscing elit."
    }
    

    PUT /v1/news/:id

    {
      "title": "Sample Title",
      "content": "Lorem ipsum dolor sit amet, consectetur adipiscing elit."
    }
    
    
  • Delete Content by ID

    DELETE /v1/blogs/:id

    DELETE /v1/news/:id

  • Get Content by ID

    GET /v1/blogs/:id

    GET /v1/news/:id

  • GetAll Contents

    GET /v1/blogs

    GET /v1/news

License

This project is licensed under the MIT License.

Feedback and Support

For any issues, feedback, or support, please open an issue on GitHub.

Directories

Path Synopsis
Package docs GENERATED BY THE COMMAND ABOVE; DO NOT EDIT This file was generated by swaggo/swag
Package docs GENERATED BY THE COMMAND ABOVE; DO NOT EDIT This file was generated by swaggo/swag
internal
blogs/mock
Package mock is a generated GoMock package.
Package mock is a generated GoMock package.
news/mock
Package mock is a generated GoMock package.
Package mock is a generated GoMock package.
pkg

Jump to

Keyboard shortcuts

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