{"id":19848707,"url":"https://github.com/polterguy/magic.library","last_synced_at":"2026-06-11T00:31:15.020Z","repository":{"id":44558959,"uuid":"213155797","full_name":"polterguy/magic.library","owner":"polterguy","description":"Helper project to wire up Magic","archived":false,"fork":false,"pushed_at":"2024-02-19T05:18:00.000Z","size":377,"stargazers_count":1,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-12-11T13:26:06.907Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://ainiro.io","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/polterguy.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}},"created_at":"2019-10-06T11:26:02.000Z","updated_at":"2023-09-03T08:24:38.000Z","dependencies_parsed_at":"2023-09-24T09:49:32.568Z","dependency_job_id":"e12f9f0d-e41f-49f6-ab19-a9f7f103b89a","html_url":"https://github.com/polterguy/magic.library","commit_stats":null,"previous_names":[],"tags_count":76,"template":false,"template_full_name":null,"purl":"pkg:github/polterguy/magic.library","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/polterguy%2Fmagic.library","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/polterguy%2Fmagic.library/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/polterguy%2Fmagic.library/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/polterguy%2Fmagic.library/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/polterguy","download_url":"https://codeload.github.com/polterguy/magic.library/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/polterguy%2Fmagic.library/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34177445,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-10T02:00:07.152Z","response_time":89,"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":[],"created_at":"2024-11-12T13:18:04.743Z","updated_at":"2026-06-11T00:31:15.004Z","avatar_url":"https://github.com/polterguy.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# magic.library - Tying Magic together\n\nThis project helps you to wire up everything related to Magic. Normally you'd use it simply like the following from\nyour startup class in your .Net 8 Web API project.\n\n```csharp\nusing Microsoft.AspNetCore.Builder;\nusing Microsoft.Extensions.Configuration;\nusing Microsoft.Extensions.DependencyInjection;\nusing magic.library;\n\nnamespace magic.backend\n{\n    public class Startup\n    {\n        public Startup(IConfiguration configuration)\n        {\n            Configuration = configuration;\n        }\n\n        IConfiguration Configuration { get; }\n\n        public void ConfigureServices(IServiceCollection services)\n        {\n            // Initializing Magic.\n            services.AddMagic(Configuration);\n        }\n\n        public void Configure(IApplicationBuilder app)\n        {\n            // Initializing Magic.\n            app.UseMagic(Configuration);\n        }\n    }\n}\n```\n\nHowever, you can also take more control over how things are actually wired up, by instead of using the\n_\"do all methods\"_ called `AddMagic` and `UseMagic`, invoke some of the specialized initialization methods,\nyou can find below.\n\n* `IServiceCollection.AddMagicCaching`\n* `IServiceCollection.AddMagicHttp`\n* `IServiceCollection.AddMagicLogging`\n* `IServiceCollection.AddMagicSignals`\n* `IServiceCollection.AddMagicExceptions`\n* `IServiceCollection.AddMagicEndpoints`\n* `IServiceCollection.AddMagicAuthorization`\n* `IServiceCollection.AddMagicFileServices`\n* `IServiceCollection.AddMagicFileServices`\n* `IServiceCollection.AddMagicConfiguration`\n* `IServiceCollection.AddMagicScheduler`\n* `IServiceCollection.AddMagicMail`\n* `IServiceCollection.AddMagicLambda`\n* `IServiceCollection.AddMagicSockets`\n\nThe above methods is basically what the `AddMagic` method actually does, and they're extension methods of\n`IServiceCollection`, that can be found in the `magic.library` namespace. Similar alternatives to `UseMagic` can\nbe found below.\n\n* `IApplicationBuilder.UseMagicExceptions`\n* `IApplicationBuilder.UseMagicStartupFiles`\n* `IApplicationBuilder.UseMagicScheduler`\n* `IApplicationBuilder.UseMagicCors`\n\nIf you use these methods instead of the _\"do all methods\"_, your motivation would probably\nbe to _replace_ one of these methods with your own implementation, to exchange the default wiring, by (for instance)\nusing a _\"virtual database based file system\"_ by creating your own service implementation of for instance `IFileService`\nfrom _\"magic.lambda.io\"_, or use a different logging provider than the default, etc. If you wish\nto do this, you'd probably benefit from looking at what the default implementation of your method does, to understand the\nrequirements from your method. Doing this is very powerful, and allows you to change the way the system behaves by default -\nBut is also definitely considered an _\"advanced exercise\"_.\n\n## Exceptions handlers\n\nMagic allows you to provide a custom exceptions handler on a per folder level. This overrides the\ndefault exception logic with a custom exception handler expected to be named _\"exceptions.hl\"_ and found within\nthe folder hierarchy where an HTTP invocation is resolved. For instance, if you wish to create your own exception\nhandler for a specific module called _\"foo\"_, you can create an exception handler file\ncalled _\"/files/modules/foo/exceptions.hl\"_, and expect this file to be invoked every time an unhandled exception\noccurs, anywhere inside of your _\"foo\"_ folder.\nThis allows you to transform an unhandled exception, such as for instance localising it or customising it\nin any ways. Your custom exception handler will be invoked with the following arguments.\n\n* __[message]__ - The exception error message\n* __[path]__ - The URL that triggered the exception\n* __[field]__ - If the exception that was thrown declared a field, this argument will contain the name of the field\n* __[status]__ - If the exception that was thrown declared a status code, this argument will contain the status code\n* __[public]__ - If the exception that was thrown wants to propagate to the client this will be true\n\nYou can return a _\"transformed\"_ exception from your exception handler, returning the following arguments, that will\nend up becoming the response object returned to the client.\n\n* __[message]__ - Message to return as JSON to client\n* __[field]__ - Field to return as JSON to client\n* __[status]__ - Status code to decorate your HTTP response with\n\nThe default exception handler can be found in _\"/files/exceptions.hl\"_, which will be invoked if no custom exception\nhandler is declared further down in your folder hierarchy.\n\n## Magic's GitHub project page\n\nMagic is 100% Open Source and you can find the primary project GitHub page [here](https://github.com/polterguy/magic).\n\n## Project website for magic.lambda.library\n\nThe source code for this repository can be found at [github.com/polterguy/magic.library](https://github.com/polterguy/magic.library), and you can provide feedback, provide bug reports, etc at the same place.\n\n- ![Build status](https://github.com/polterguy/magic.library/actions/workflows/build.yaml/badge.svg)\n- [![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=polterguy_magic.library\u0026metric=alert_status)](https://sonarcloud.io/dashboard?id=polterguy_magic.library)\n- [![Bugs](https://sonarcloud.io/api/project_badges/measure?project=polterguy_magic.library\u0026metric=bugs)](https://sonarcloud.io/dashboard?id=polterguy_magic.library)\n- [![Code Smells](https://sonarcloud.io/api/project_badges/measure?project=polterguy_magic.library\u0026metric=code_smells)](https://sonarcloud.io/dashboard?id=polterguy_magic.library)\n- [![Duplicated Lines (%)](https://sonarcloud.io/api/project_badges/measure?project=polterguy_magic.library\u0026metric=duplicated_lines_density)](https://sonarcloud.io/dashboard?id=polterguy_magic.library)\n- [![Lines of Code](https://sonarcloud.io/api/project_badges/measure?project=polterguy_magic.library\u0026metric=ncloc)](https://sonarcloud.io/dashboard?id=polterguy_magic.library)\n- [![Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=polterguy_magic.library\u0026metric=sqale_rating)](https://sonarcloud.io/dashboard?id=polterguy_magic.library)\n- [![Reliability Rating](https://sonarcloud.io/api/project_badges/measure?project=polterguy_magic.library\u0026metric=reliability_rating)](https://sonarcloud.io/dashboard?id=polterguy_magic.library)\n- [![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=polterguy_magic.library\u0026metric=security_rating)](https://sonarcloud.io/dashboard?id=polterguy_magic.library)\n- [![Technical Debt](https://sonarcloud.io/api/project_badges/measure?project=polterguy_magic.library\u0026metric=sqale_index)](https://sonarcloud.io/dashboard?id=polterguy_magic.library)\n- [![Vulnerabilities](https://sonarcloud.io/api/project_badges/measure?project=polterguy_magic.library\u0026metric=vulnerabilities)](https://sonarcloud.io/dashboard?id=polterguy_magic.library)\n\n## Copyright and maintenance\n\nThe projects is copyright Thomas Hansen 2023 - 2024, and professionally maintained by [AINIRO.IO](https://ainiro.io).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpolterguy%2Fmagic.library","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpolterguy%2Fmagic.library","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpolterguy%2Fmagic.library/lists"}