{"id":20126447,"url":"https://github.com/sovereigncloudstack/gaiax-interconnect-api","last_synced_at":"2025-03-02T21:16:15.141Z","repository":{"id":241705898,"uuid":"806543422","full_name":"SovereignCloudStack/gaiax-interconnect-api","owner":"SovereignCloudStack","description":null,"archived":false,"fork":false,"pushed_at":"2024-12-19T00:27:57.000Z","size":78,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-01-13T08:12:40.690Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SovereignCloudStack.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-05-27T11:56:27.000Z","updated_at":"2024-08-09T19:17:29.000Z","dependencies_parsed_at":"2024-05-29T19:37:23.071Z","dependency_job_id":"4855a9e6-c902-4f9e-a4a7-cb8951b4a5be","html_url":"https://github.com/SovereignCloudStack/gaiax-interconnect-api","commit_stats":null,"previous_names":["sovereigncloudstack/gaiax-interconnect-api"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SovereignCloudStack%2Fgaiax-interconnect-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SovereignCloudStack%2Fgaiax-interconnect-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SovereignCloudStack%2Fgaiax-interconnect-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SovereignCloudStack%2Fgaiax-interconnect-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SovereignCloudStack","download_url":"https://codeload.github.com/SovereignCloudStack/gaiax-interconnect-api/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241570919,"owners_count":19984002,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-13T20:16:09.666Z","updated_at":"2025-03-02T21:16:15.108Z","avatar_url":"https://github.com/SovereignCloudStack.png","language":"Go","readme":"# Gaia-X Interconnect API\nThis is a RESTful API that allows the creation and management of VPNs for cloud interconnection. \n\n## Table of Contents\n\n- [Features](#Features)\n- [Directory Structure](#Directory-Structure)\n- [Description](#Description)\n- [Setup](#Setup)\n- [Directory Structure Explanation](#Directory-Structure-Explanation)\n- [License](#license)\n\n## Features\n\n- Standard responses for success and fail requests\n- Swagger API documentation\n- Sqlx DB with Postgres - but can be changed as needed.\n- Standard for custom errors\n- Logger for console and external file.\n- Migrations setup\n- Hot Reload\n- Docker setup\n- Intuitive, clean and scalabe structure\n---\n\n## Directory Structure\n```\n- /cmd --\u003e Contains the app's entry-points \n  |- /server\n     |- /docs\n     |- main.go\n     |- Makefile\n  |- /another_binary\n- /config --\u003e Contains the config structures that the server uses.\n- internal --\u003e Contains the app's code\n   |- /errors\n   |- /handlers\n   |- /middleware\n   |- /model\n   |- /storage\n   |- server.go\n- /logs --\u003e The folder's files are not in version control. Here you'll have the logs of the apps (the ones you specify to be external)\n- /migrations --\u003e Migrations to set up the database schema in your db.\n- /pkg --\u003e Packages used in /internal\n   |- /httputils\n   |- /logger\n- .air.toml\n- .env --\u003e Not in version control. Need to create your own - see below.\n- .gitignore\n- docker-compose.yml\n- Dockerfile\n- go.mod\n- go.sum\n- LICENSE\n- README.md\n```\n\n## Setup\n\nMake sure to first install the binaries that will generate the api docs and hot-reload the app.\n\n```\ngo install github.com/swaggo/swag/cmd/swag@latest\n```\nand\n```\ngo install github.com/cosmtrek/air@latest\n```\n\nDownload the libs\n```\ngo mod download\n```\n```\ngo mod tidy\n```\n\nCreate an `.env` file in the root folder and use this template:\n```\n# DEV, STAGE, PROD\nENV=DEV\nPORT=8080\nVERSION=0.0.1\n\nDB_HOST=localhost  #when running the app without docker\n# DB_HOST=postgres # when running the app in docker\nDB_USER=postgres\nDB_NAME=postgres\nDB_PASSWORD=postgres\nDB_PORT=5432\n```\n\nIf you start the app locally without docker make sure your Postgres DB is up.\nWrite `air` in terminal and the app will be up and running listening on whatever port you set in .env.\n\nDon't forget to rename the module and all the imports in the code from my github link to yours.\n\n## Setup with Docker\n\nTo run the app in docker, you need to have docker installed on your machine.\n\nCreate an `.env` file in the root folder and use this template:\n```\n# DEV, STAGE, PROD\nENV=DEV\nPORT=8080\nVERSION=0.0.1\n\n# DB_HOST=localhost  #when running the app without docker\nDB_HOST=postgres # when running the app in docker\nDB_USER=postgres\nDB_NAME=postgres\nDB_PASSWORD=postgres\nDB_PORT=5432\n```\n\nThen run the following command to build the image and start the container:\n```\ndocker-compose up --build\n```\n\n## Cleaning up\n\nTo stop the app running in docker, run the following command:\n```\ndocker-compose down\n```\n\n## Build API Docs\n\nNavigate to the `cmd/server` directory and run the following command:\n```\nmake swag\n```\n\n## Build the App\n\nNavigate to the `cmd/server` directory and run the following command:\n```\nmake build\n```\n\n## Testing\n\nTo run the tests, navigate to the `cmd/server` directory and run the following command:\n```\nmake test\n```\n\n## Accessing the API Docs\n\nAfter the app is up and running, you can access the API docs by going to `http://localhost:8080/api/docs/index.html`.\n\n## Directory Structure Explanation\n\n* /cmd\n   - The entry point of the server is in `main.go`, where the app loads environment variables and config from `/config`.\n   - The config is passed to the server and can be expanded as needed.\n   - A goroutine runs an `OnShutdown` function for server crashes or panics.\n   - A `Makefile` is included for building the app.\n\n* /internal\n   - Contains the main code.\n   - `server.go` defines the `AppServer` struct with db, handlers, and server setup.\n   - `Run` function configures the server, database, router, middlewares, handlers, and migrations.\n   - `Sender` and `Storage` are injected from `handlers.Handlers`.\n   - Functions: `OnShutdown`, `NotFoundHandler` (404), and `NotAllowedHandler` (405).\n\n* /errors\n   - Defines custom error structs for response handling.\n   - The `Sender` formats responses based on these errors.\n   - Accepts errors as strings, structs, or custom `Err` structs.\n\n* /handlers\n   - `handlers.go` sets up the handlers object with its dependencies.\n   - Specific handler groups (e.g., `books.go`, `users.go`) are added here.\n   - Functions in these files are received by the `Handlers` struct.\n\n* /middlewares\n   - Contains custom middlewares added to `negroni` in `server.go`.\n\n* /model\n   - `base_model.go` serves as the base for other models.\n   - Each file (e.g., `books.go`) defines database models and request/response structs.\n\n* /storage\n   - `storage.go` defines the storage interface for database switching.\n   - `postgres_db.go` creates a PostgreSQL storage instance.\n   - New databases can be added by implementing the `StorageInterface`.\n\n* /pkg\n   - `httputils` contains `http_response.go` for response standards.\n   - The `Sender` struct handles automated responses (e.g., JSON).\n   - `logger` provides logging to console or `/logs` directory, configurable to a different path (e.g., `/var/log/myapp` for Unix/Linux).\n\n\n# Sample API\n\nCreate a new VPN:\n```sh\ncurl -X 'POST'   'http://0.0.0.0:8080/api/vpn/add'   -H 'accept: application/json'   -H 'Content-Type: application/json'   -d '{\"type\": \"vpn\", \"local_as_number\": 65000, \"remote_as_number\": 65001, \"VNI\": 1000, \"name\": \"vpn1\"}'\n```\n\n## License\n\nThis project is licensed under the AGPLv3 License - see the [LICENSE](./LICENSE) file for details.\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsovereigncloudstack%2Fgaiax-interconnect-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsovereigncloudstack%2Fgaiax-interconnect-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsovereigncloudstack%2Fgaiax-interconnect-api/lists"}