Git Product home page Git Product logo

articles-complex's Introduction

articles-complex

I use existing libs :

  • Echo Framework
  • Viper, for config management
  • Sqlx, for database connection
  • Redis, for caching

I'am build a service to manage data articles using golang, using postgresql for database, and redis for caching. service has database migration. I created 5 endpoints :

  1. [POST] /articles to post a new article
  2. [GET] /articles to get the list of articles. Sort the articles by newest first with optional query parameters:
    • a. query: to search keywords in the article title and body
    • b. author: filter by author name.
  3. [GET] /articles/:id to get a specific article by :id
  4. [PUT] /articles/:id to update an article by :id
  5. [DELETE] /articles/:id to delete an article by :id

Setup after cloning the repo:

Run this command on your terminal to prepare dependencies:

  • $ cd articles-complex
  • $ go get
  • $ go mod tidy

connfiguration environment

Do this following actions for set up your configuration :

  • copy config/config-dev.yaml.example ke config/config-dev.yaml
  • complete the necessary credentials such as postgre and redis databases according to the existing format

Database migration :

I use PostgreSQL for Database. you can create database tables by migration, but before that you have to create a new database on your RDBMS.

  • $ migrate -database "postgres://userDB:passwordDB@hostDB:portDB/yourDB?sslmode=disable" -path pkg/database/migrations up

Run service :

You can run the service by using the following command, after that the service is ready to use.

  • $ go run main.go

Run with docker

You can run service in docker with this command:

  • $ docker-compose -f docker-compose.yml up -d

Use the service

You can deploy a service with consumption to an already created API endpoint, you can use the postman tool. To make it easier to use, I've created a workspace for it, and it's ready to go. don't forget to use postman with desktop agent if the service is running on localhost. Postman Link: https://api.postman.com/collections/18402968-801dd7d7-279b-424e-9c14-75fc4ac465e6?access_key=PMAT-01GJRV8GG1M6SQVNPRGD1F1RA7

Thank You

If there are problems or want to know more information about me, please contact via linkedin via the following link https://www.linkedin.com/in/adi-khoiron-hasan or by sending an email to [email protected]. Thank You :)

articles-complex's People

Contributors

adikhoironhasan avatar

Watchers

 avatar

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.