{"id":24416732,"url":"https://github.com/sha1n/fungus","last_synced_at":"2026-04-02T17:51:17.442Z","repository":{"id":41965698,"uuid":"415431154","full_name":"sha1n/fungus","owner":"sha1n","description":"An experimental library for starting and stopping multi-service environments correctly and efficiently based on declared dependencies between them","archived":false,"fork":false,"pushed_at":"2026-03-29T06:34:51.000Z","size":8586,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-03-29T09:16:26.572Z","etag":null,"topics":["bfs-algorithm","dependencies","dfs-algorithm","directed-acyclic-graph","nodejs","testing-tool","topological-sort","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sha1n.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2021-10-09T22:03:50.000Z","updated_at":"2026-03-29T06:34:25.000Z","dependencies_parsed_at":"2023-02-18T14:45:23.620Z","dependency_job_id":"a60e36e3-c8e4-4f2c-b952-f7bb86b8c5c3","html_url":"https://github.com/sha1n/fungus","commit_stats":{"total_commits":106,"total_committers":2,"mean_commits":53.0,"dds":"0.37735849056603776","last_synced_commit":"acba61c6119669cf33905de32e6074a1e960e31b"},"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"purl":"pkg:github/sha1n/fungus","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sha1n%2Ffungus","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sha1n%2Ffungus/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sha1n%2Ffungus/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sha1n%2Ffungus/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sha1n","download_url":"https://codeload.github.com/sha1n/fungus/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sha1n%2Ffungus/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31312744,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-02T12:59:32.332Z","status":"ssl_error","status_checked_at":"2026-04-02T12:54:48.875Z","response_time":89,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["bfs-algorithm","dependencies","dfs-algorithm","directed-acyclic-graph","nodejs","testing-tool","topological-sort","typescript"],"created_at":"2025-01-20T08:14:11.179Z","updated_at":"2026-04-02T17:51:17.423Z","avatar_url":"https://github.com/sha1n.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![CI](https://github.com/sha1n/fungus/actions/workflows/ci.yml/badge.svg)](https://github.com/sha1n/fungus/actions/workflows/ci.yml)\n[![Coverage](https://github.com/sha1n/fungus/actions/workflows/coverage.yml/badge.svg)](https://github.com/sha1n/fungus/actions/workflows/coverage.yml)\n![GitHub](https://img.shields.io/github/license/sha1n/fungus)\n![npm type definitions](https://img.shields.io/npm/types/@sha1n/fungus)\n![npm](https://img.shields.io/npm/v/@sha1n/fungus)\n\n\n```\n                       .-'~~~-.\n                     .'o  oOOOo`.\n                    :~~~-.oOo   o`.\n                     `. \\ ~-.  oOOo.\n                       `.; / ~.  OO:\n                       .'  ;-- `.o.'\n                      ,'  ; ~~--'~\n                      ;  ;\n_______\\|/__________\\\\;_\\\\//___\\|/________\n\n```\n\n# Fungus 🍄\nDesigned to harness backend integration testing environments, `Fungus` is a simple controller for starting and stopping multiple stateful services of virtually any kind, as long as they have `start` and `stop` semantics. A `Fungus` environment allows you to declare dependencies between services, so they can start up in the correct order and shut down in the correct order. It uses graph algorithms to minimize startup time and ensure clean shutdown.\n\n- [Fungus 🍄](#fungus-)\n  - [Features](#features)\n  - [Usage](#usage)\n    - [Docker Services Demo](#docker-services-demo)\n    - [In-Memory Services Demo](#in-memory-services-demo)\n  - [Install](#install)\n\n## Features\n- Simple and lean API surface. Very easy to adopt or experiment with. The [`Service`](./lib/types.ts) interface is all you really have to implement.\n- Easy to extend. The [`Docker`](./examples/docker/docker.ts) example shows how easy it is to create a generic docker based service and use it to control containers.\n- A `RuntimeContext` API gives you access to metadata that is provided by any service in your environment. This is handy when you need to configure a service based on its dependencies. For example, you use a random database port and you want your app to get it before it starts up. The same context object is passed to all the services on startup and returned by the environment start method, so you can use it from the application or test.\n\n## Usage\nHere is a simple examples of how you create an environment and interact with it. For full working examples, see the demos [here](./examples).\n\n```ts\n// create services (implement the Service interface)\nconst storageService = createConfigService('my-config-service-id');\nconst mqService = ...;\nconst configService = ...;\nconst authService = ...;\nconst appService = ...;\n\n// create an environment from a list of services and dependencies between them\nconst env = createEnvironment(\n  [\n    {\n      service: configService,\n      dependsOn: [storageService, mqService]\n    },\n    {\n      service: appService,\n      dependsOn: [configService, authService]\n    },\n    {\n      service: authService,\n      dependsOn: [configService]\n    }\n  ],\n  { name: 'my-env' }\n);\n\n// start all the services. Services start according to their level in the dependency graph and in parallel where possible (topological)\nconst context = await env.start();\n\n// query the context for metadata returned by your services\nconst yourConfigServiceMetadata = context.catalog.get('my-config-service-id') as YourConfigServiceMetadata;\nconst configServiceUrl = yourConfigServiceMetadata.url;\n\n  ...\n\n// finally - stop all service in reverse order\nawait env.stop();\n\n```\n\n### Docker Services Demo\n- A demo that uses Docker based services can be found [here](examples/docker/index.ts). This implementation relies on your shell environment and requires a Docker client and an available Docker daemon.\n  \n```\npnpm install \u0026\u0026 pnpm run docker-demo\n```\n\n### In-Memory Services Demo\n- An in-memory services demo code can be found [here](examples/in-memory/index.ts).\n\n```\npnpm install \u0026\u0026 pnpm run simple-demo\n```\n\n\u003chr\u003e\n\u003cimg src=\"docs/images/demo_800.gif\" width=\"100%\"\u003e\n\n## Install\n```\npnpm add @sha1n/fungus\n```\nor \n```\nnpm i @sha1n/fungus\n```\nor\n```\nyarn add @sha1n/fungus\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsha1n%2Ffungus","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsha1n%2Ffungus","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsha1n%2Ffungus/lists"}