Giter Site home page Giter Site logo

nyhetsjeger's Introduction

Nyhetsjeger

Bachelor Project for SMP

Dev environment setup

In order to run and develop this project, you will need a set of tools.

  • Visual Studio Code - editor recommanded for this project, tools and plugins listed below transform it into an IDE.

  • WSL - We use it for consistant developer experience, as well as development in similar environment to production. Allows us to use Linux-specific toolchains. This simplifies development of scripts.

All tooling below must be accessible in WSL (Except if you are using all tools native to your OS)

  • Go - the project is primarily written in GO
    Remember to add go and go's binaries to your path!
    file: ~/.bashrc (or other shell's configuration file), add the following lines at the end of it
    export PATH=$PATH:/usr/local/go/bin
    export PATH=$PATH:$HOME/go/bin
  • Templ - HTML templating language for Go
    you need it installed in order to generate go files from templates
    • You will also need templ-vscode extension, for improved developer experience.
    • For better IDE support, Tailwind completions etc, check out Templ's guide.
    • For HTMX suggestions in Templ files, you may want to use HTMX Attributes extension.
  • Air - Live reload for Go apps
    improved developer experience
  • Node to run Tailwind CSS.
  • Docker - for running the database locally and deploying the app
    • WSL will need Docker Desktop for Windows anyway, usually works out the box. For troubleshooting see Docker's and Microsoft's documentation
  • migrate CLI - SQL migration tool simplest way to install
    go install -tags 'postgres' github.com/golang-migrate/migrate/v4/cmd/migrate@latest

Building and running locally

Use Make to run targets (build, run, etc.) specified in the Makefile. Make is included in most Linux distributions(as well as WSL). If it isnt included by default, use your distros package manager to install it.
Example:

make run

Alternatively, you can check out the commands in the Makefile and run them manually.

Initial setup

Before you can get started running the application you need to get a few things sorted.

Copy the .env.example file to .env.

cp .env.example .env

Change the default passwords and secrets to your own!

Standup the services in docker-compose.

make initialize-docker

And then migrate the database, either

make reset-db

Alternatively, if you don't want dummy/test data

make migrate-up
./scripts/add-db-usr.sh
./scripts/add-nickname-words.sh

Setup a Google Cloud project, generate client ID and secret, update the .env file. This is needed for the OAuth2 login.

Setup MinIO (dashboard can be accessed at localhost:9001). Create a bucket called "images", set public read, generate access and secret keys for write. Set the secrets in the .env file.

Testing

The project has unit and integration tests, they live in separate files and are tagged with go build tags.

unit tests: filename_test.go, build tag unit
integration tests: filename_integration_test.go, build tag integration

Add the build tags to your LSP configuration so you get syntax highlighting and autocompletion in the test files.
VScode settings.json example:

{
    "go.buildFlags": [
        "-tags=integration,unit"
    ],
    "go.testTags": "integration,unit",
}

To run the tests, use specific Make targets

make test-unit
make test-integration

Note: Integration tests use Testcontainers, which requires Docker to be running.

API testing with Bruno

To run the Bruno tets, you need the application running locally.

make run

Then you can run the test suite

make run-bruno

The above uses bru CLI via npx, you may be asked to install it first time you run it.

nyhetsjeger's People

Contributors

nokacper24 avatar z-rayc avatar oransj avatar molnes avatar dependabot[bot] avatar

Stargazers

Dag-Arne Alnes 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.