Giter VIP home page Giter VIP logo

appdoki-be's Introduction

appdoki-be

This repository contains the RESTful API server used by our in-house built company application.

This project, besides having functional expectations, also aims at being a locomotive for technical experiments.

Technologies

For now the focus is Go and PostgreSQL.

Preferably the most recent versions.

Development

API

Aim for API-first development (find the contract in swaggerui/openapi.yml).

API contract follows OpenAPI v3.

Database

Database changes are achieved via migrations.

All migrations have up and down steps, are written in plain SQL and should respect a sequential order.

For convenience, golang-migrate can also be used to generate the required files.

You can find helper commands in the Makefile for this:

  • get-migrator: downloads the migrator bin into migrations/bin (this directory is gitignored)
  • create-migrations: receives an argument for migration name (ex.:make create-migration name=alter-users-add-superhero)
  • migrate-up: runs all migrations up
  • migrate-down: runs all migrations down

Setup

  • create a PostgreSQL database and user
  • create a .env file and change accordingly (there is a .env.sample)
  • run the project (a few options: go run .; use your debugger; make compose-dev...)

Integration tests

Integration tests are kept in ./tests and are developed using Go's testing library and guidelines.

These can be run against an existing application or on an isolated Docker environment. All necessary commands are available in the Makefile.

It's important that the running application has the environment variable TEST_MODE set to true.

The tests themselves need two variables: API_URL with the URl of where the API is running; DB_URI as in the application.

Executing make integration-tests-compose will create Docker containers for the API and database and run the tests.

It's also possible to prepare only the containers (make compose-integration) and leave test running for yourself to, for example, debug the tests in the IDE.

In-Test Authentication

This application uses Google's OpenID Connect Authentication. Since Google does not provide test users or similar feature, the application has a test mode that skips Bearer token validation but still injects properties in the request context. This should be adapted as the tests evolve.

An idea for future improvement is to support an extra OIDC and use it for tests only.

appdoki-be's People

Contributors

s1moe2 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.