talentgrowth-be

command module
v0.0.0-...-757f525 Latest Latest
Warning

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

Go to latest
Published: May 19, 2024 License: MIT Imports: 11 Imported by: 0

README

talentgrowth-be

Backend side

Getting Started with talentgrowth-be

This guide will help you get the backend side of the talentgrowth-be up and running on your local machine for development and testing purposes.

Prerequisites

Before you begin, ensure you have the following installed:

  • Docker
  • Docker Compose
  • Go (Golang)
Installation
  1. Clone the repository:

    git clone https://github.com/yourgithub/talentgrowth-be.git
    cd talentgrowth-be
    
  2. Set up the environment variables:

    • Copy the .envxample file to .env.
    • The dev .env file should look like this (modify the variables as needed):
         GO_PORT=7890
         GO_ENV=test
      
         MONGO_URI=mongodb://root:password123@mongodb:27017/?authSource=admin
         MONGO_DB=talentgrowth
      
         JWT_SECRET="SecreteJwt"
      
  3. Build and run the Docker containers:

    docker compose up --build
    
Running the tests

To run tests for the application, use the following command:

go test -v ./...
Setting Environment Variables for Testing

Before running the tests, ensure that the MongoDB server is up as the tests may interact with MongoDB collections. To set an environment variable temporarily for the duration of the test command, use the following syntax:

  • On Unix-like systems (Linux, macOS):

    You can set the environment variable inline just before the command without affecting the global environment:

    MONGO_URI="mongodb://your_uri_here" go test -v ./...
    
  • On Windows:

    You can use the set command before running go test:

    set MONGO_URI=mongodb://your_uri_here
    go test -v ./...
    
  • Alternatively, for a one-liner in Windows PowerShell:

    $env:MONGO_URI="mongodb://your_uri_here"; go test -v ./...
    

These commands set the environment variable temporarily for the duration of the test command. If you need the variable to persist, you would set it in your shell's configuration file or Windows environment settings.

Running the application

Once the Docker containers are up and running, the backend server should be accessible via http://localhost:7890. You can check the API documentation at:

http://localhost:7890/api/v1/documentation/index.html 

To generate updated API documentation after making changes, run the following command in your terminal:

swag init

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
controllers
Package docs Code generated by swaggo/swag.
Package docs Code generated by swaggo/swag.
handlers

Jump to

Keyboard shortcuts

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