{"id":18672413,"url":"https://github.com/alsolovyev/dummy-api","last_synced_at":"2025-10-13T12:10:11.398Z","repository":{"id":65698407,"uuid":"596036011","full_name":"alsolovyev/dummy-api","owner":"alsolovyev","description":"A REST API that facilitates the management of user data","archived":false,"fork":false,"pushed_at":"2023-02-05T05:08:51.000Z","size":29,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-13T12:05:53.851Z","etag":null,"topics":["clean-architecture","go-chi","golang","rest-api"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/alsolovyev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2023-02-01T10:30:25.000Z","updated_at":"2023-02-01T13:45:14.000Z","dependencies_parsed_at":"2023-02-18T21:46:11.856Z","dependency_job_id":null,"html_url":"https://github.com/alsolovyev/dummy-api","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/alsolovyev/dummy-api","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alsolovyev%2Fdummy-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alsolovyev%2Fdummy-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alsolovyev%2Fdummy-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alsolovyev%2Fdummy-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alsolovyev","download_url":"https://codeload.github.com/alsolovyev/dummy-api/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alsolovyev%2Fdummy-api/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279015039,"owners_count":26085643,"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","status":"online","status_checked_at":"2025-10-13T02:00:06.723Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["clean-architecture","go-chi","golang","rest-api"],"created_at":"2024-11-07T09:11:10.539Z","updated_at":"2025-10-13T12:10:11.373Z","avatar_url":"https://github.com/alsolovyev.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Dummy API\n\nThis Go application adheres to the clean architecture pattern and provides a straightforward implementation of a REST API that facilitates the management of user data, offering endpoints for adding and modifying information without requiring application restart.\n\n\n\u003cbr /\u003e\n\n## Getting Started\n\n### Prerequisites\nTo run this application, you will need to have [Go installed](https://go.dev/dl/) on your machine.\n\n### Installing\nClone the repository to your local machine using the following command:\n\n```shell\ngit clone https://github.com/alsolovyev/dummy-api.git\n```\n\nChange into the directory:\n\n```shell\ncd dummy-api\n```\n\nRun the application:\n```shell\nmake run\n```\n\n\n\u003cbr /\u003e\n\n## Usage\nCreate a file that includes the necessary data within the \"data\" directory:\n```shell\necho '[{\"name\": \"Jane\"}, {\"name\": \"Willa\"}]' \u003e ./data/users.json\necho 'Lorem ipsum dolor sit amet' \u003e ./data/text\n```\n\nSend a request to retrieve data from the file that you have created:\n```shell\ncurl 'http://localhost:8181/api/v1/file/users.json' | json_pp\ncurl 'http://localhost:8181/api/v1/file/text'\n```\n\nIt is now possible to modify, add, or delete files without the requirement of restarting the application.\n\n\n\u003cbr /\u003e\n\n## Endpoints\nThe following endpoints are available:\n\n### GET `/api/v1/file/{name}`\nRetrieves a specific file based on its name and parses its data based on its extension. Currently, it supports parsing of JSON formatted files with the \".json\" extension, as well as text files without an extension.\n\n\n\u003cbr /\u003e\n\n## Features\nThe following features are available:\n\n### Delay\nThe \"delayMiddleware\" allows you to add a delay to your HTTP requests. This is useful for testing purposes, or for simulating slow responses in a controlled environment. The middleware reads the value of the \"delay\" query parameter from the URL of the incoming request. If the \"delay\" parameter is present, the middleware parses the duration from its value and waits for the specified duration using the `time.Sleep` function. If the duration value is not valid, the middleware returns a \"400 Bad Request\" HTTP response with an error message.\n```shell\ncurl 'http://localhost:8181/api/v1/ping?delay=2s'\ncurl 'http://localhost:8181/api/v1/file/users.json?delay=5s' | json_pp\n```\n\n### Status Code\nThe \"statusCodeMiddleware\" provides a flexible solution for manipulating the HTTP response status code. This is useful for testing and simulation scenarios where custom error need to be generated. The middleware reads the \"status_code\" query parameter from the URL of the incoming request. If the parameter value is a valid HTTP status code within the range of 100 to 599, the middleware sets the HTTP response status code to the specified value. If the value of the \"status_code\" parameter is not a valid HTTP status code, the middleware will skip this step and proceed with serving the request normally.\n```shell\ncurl 'http://localhost:8181/api/v1/file/errors.json?status_code=501' | json_pp\n```\n\n\n\u003cbr /\u003e\n\n## This project uses the following directory structure to organize the codebase:\n\n* The `cmd` directory contains the main entry point of the application. The \u003cproject-name\u003e directory holds the `api/main.go` file that sets up and starts the application.\n* The `internal` directory holds the core logic of the application and is organized into four main subdirectories, each of which represents a layer in accordance with the clean architecture pattern:\n  * `entity`: the entity layer represents the core business entities of the application. It represents the objects that are used to model the domain and encapsulate the data and behavior of the application. These entities are independent of any framework, library, or external dependency and are therefore highly reusable and testable. They define the application's data model and the relationships between objects, and are the source of truth for the application's business logic. The Entity layer is isolated from other layers, such as the Presentation or Data Access layer, making it easy to change or replace these layers without affecting the Entity layer.\n\n  * `repository`: the repository layer represents the persistence logic of the application. It defines the interactions between the entities and the data storage, and it is responsible for loading and saving the entities. The repository layer is typically composed of several repositories, each one representing a specific type of entity.\n\n  * `usecase`: the use case layer represents the business logic of the application. It defines the interactions between the entities and the external systems, and it is responsible for performing the operations that the application needs to accomplish. The use case layer is typically composed of several use cases, each one representing a specific operation or set of operations.\n\n  * `controller`: the controller layer represents the interface of the application. It defines the interactions between the use cases and the external systems, such as the user interface or an API. The controller layer is typically composed of several controllers, each one representing a specific set of use cases. The controllers are responsible for receiving the requests from the external systems, validating the input data, and calling the appropriate use cases to handle the request.\n\n\n* The `pkg` directory holds code that is intended to be reused across multiple applications. It contains helper packages, such as an HTTP client or a custom error handling package.\n* The `README.md` file provides documentation and instructions for the project.\n\n\n\u003cbr /\u003e\n\n## Build With\n\n* [Golang](https://go.dev)\n* [Chi](https://github.com/go-chi/chi)\n\n\n\u003cbr /\u003e\n\n## License\nThis project is licensed under the MIT License\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falsolovyev%2Fdummy-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falsolovyev%2Fdummy-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falsolovyev%2Fdummy-api/lists"}