{"id":23567114,"url":"https://github.com/godeltech/godeltech.microservices.sharedservices","last_synced_at":"2026-02-13T14:44:06.648Z","repository":{"id":40860538,"uuid":"263423474","full_name":"GodelTech/GodelTech.Microservices.SharedServices","owner":"GodelTech","description":null,"archived":false,"fork":false,"pushed_at":"2024-12-23T16:56:17.000Z","size":39,"stargazers_count":1,"open_issues_count":2,"forks_count":1,"subscribers_count":11,"default_branch":"master","last_synced_at":"2025-03-30T19:22:00.159Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C#","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/GodelTech.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-05-12T18:51:14.000Z","updated_at":"2022-12-02T13:10:50.000Z","dependencies_parsed_at":"2024-12-23T17:37:47.792Z","dependency_job_id":"21d09af1-e87d-4c0a-a3d3-b25daec07517","html_url":"https://github.com/GodelTech/GodelTech.Microservices.SharedServices","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GodelTech%2FGodelTech.Microservices.SharedServices","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GodelTech%2FGodelTech.Microservices.SharedServices/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GodelTech%2FGodelTech.Microservices.SharedServices/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GodelTech%2FGodelTech.Microservices.SharedServices/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/GodelTech","download_url":"https://codeload.github.com/GodelTech/GodelTech.Microservices.SharedServices/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251770930,"owners_count":21641176,"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-12-26T18:19:03.048Z","updated_at":"2026-02-13T14:44:01.594Z","avatar_url":"https://github.com/GodelTech.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# GodeTech.Microservices.SharedServices\n\n`GodeTech.Microservices.SharedServices` is a collection of services which are used in particularly every project and typically copy\\pasted from project to project.\n\n## Quick Start\n\nIn order to use microservice few simple steps are required:\n1. Create ASP.NET Website application using **Visual Studio** or **dotnet cli**.\n2. Reference latest version of `Godel.Microservice.Core` and ``Godel.Microservice.SharedServices` nuget packages.\n3. Add `Godel.Microservice.SharedServices` initializer to your `Startup.cs` file to create initializers used to configure pipeline:\n```c#\nyield return new SharedServicesInitializer(Configuration);\n```\n\n### REST API configuration\nPlease use the following snippet to configure service which uses REST API only:\n\n```c#\n    public class Startup : MicroserviceStartup\n    {\n        public Startup(IConfiguration configuration)\n            : base(configuration)\n        {\n        }\n\n        protected override IEnumerable\u003cIMicroserviceInitializer\u003e CreateInitializers()\n        {\n            yield return new DeveloperExceptionPageInitializer(Configuration);\n            yield return new HttpsInitializer(Configuration);\n\n            yield return new GenericInitializer((app, env) =\u003e app.UseRouting());\n\n            yield return new ApiInitializer(Configuration);\n\n            yield return new SharedServicesInitializer(Configuration);\n        }\n    }\n```\n\n# Resolvers\n\n## ContentType Resolver\n`IContentTypeResolver` method `GetByFilePath(string filePath)` defines a mime type from extension of passing file path.\n\n### Advanced usage\n```c#\n    public class ValuesController : ControllerBase\n    {\n        private readonly IContentTypeResolver _contentTypeResolver;\n\n        public ValuesController(IContentTypeResolver contentTypeResolver)\n        {\n            _contentTypeResolver = contentTypeResolver;\n        }\n\n        [HttpGet]\n        public IActionResult GetContentType(string filePath)\n        {\n            string contentType = _contentTypeResolver.GetByFilePath(filePath);\n\n            return Ok(contentType);\n        }\n    }\n```\n\n```\nTEST VALUE: filePath = \"test.json\"\nRESULT VALUE: application/json\n```\n# Providers\n\n## DateTime Provider\n`IDateTimeProvider` method `GetUtcNow()` returns current UTC date and time.\n\n### Advanced usage\n```c#\n    public class ValuesController : ControllerBase\n    {\n        private readonly IDateTimeProvider _dateTimeProvider;\n\n        public ValuesController(IDateTimeProvider dateTimeProvider)\n        {\n            _dateTimeProvider = dateTimeProvider;\n        }\n\n        [HttpGet]\n        public IActionResult GetUTCDateTimeNow()\n        {\n            DateTime dateTimeNow = _dateTimeProvider.GetUtcNow();\n\n            return Ok(dateTimeNow);\n        }\n    }\n```\n\n```\nRESULT VALUE: \"2020-10-18T20:34:10.7520426Z\"\n```\n\n# Services\n\n## Directory Service\n`IDirectoryService` methods work with directories on disk.\n\n\n### Advanced usage\n```c#\n    public class ValuesController : ControllerBase\n    {\n        private readonly IDirectoryService _directoryService;\n\n        public ValuesController(IDirectoryService directoryService)\n        {\n            _directoryService = directoryService;\n        }\n\n        [HttpGet]\n        public IActionResult DirectoryExists(string path)\n        {\n            bool directoryExists = _directoryService.Exists(path);\n\n            return Ok(directoryExists);\n        }\n    }\n```\n\n```\nTEST VALUE: path = \"C:\\Windows\"\nRESULT VALUE: true\n```\n\n## File Service\n`IFileService` methods work with files on disk.\n\n### Advanced usage\n```c#\n    public class ValuesController : ControllerBase\n    {\n        private readonly IFileService _fileService;\n\n        public ValuesController(IFileService fileService)\n        {\n            _fileService = fileService;\n        }\n\n        [HttpGet]\n        public IActionResult FindAll(string path, string mask)\n        {\n            IEnumerable\u003cstring\u003e files = _fileService.FindAll(path, mask);\n\n            return Ok(files);\n        }\n    }\n```\n```\nTEST VALUE: path = \"d:\\test\\\", mask = \"*.exe\"\nRESULT VALUE: [\"d:\\\\Test\\\\test1.exe\", \"d:\\\\Test\\\\test2.exe\"]\n```\n\n\n## Path Service\n`IPathService` methods work with path on disk.\n\n# Factories\n\n## Guid Factory\n`IGuidFactory` methods create Guid type objects.\n\n### Advanced usage\n```c#\n    public class ValuesController : ControllerBase\n    {\n        private readonly IGuidFactory _guidFactory;\n\n        public ValuesController(IGuidFactory guidFactory)\n        {\n            _guidFactory = guidFactory;\n        }\n\n        [HttpGet]\n        public IActionResult NewGuid()\n        {\n            string id = _guidFactory.NewAsString();\n\n            return Ok(id);\n        }\n    }\n```\n\n```\nRESULT VALUE: 258920d2-eb02-4c77-b636-d63c43b07390\n```\n\n## TempFile Factory\n`ITempFileFactory` with method `Create(string tempFolder)` creates an `ITempFile` type object for working with temporary files. `ITempFile` is a disposable and can be removed after using. `ITempFile` works with files.\n\n\n\n### Advanced usage\n```c#\n    public class ValuesController : ControllerBase\n    {\n        private readonly ITempFileFactory _tempFileFactory;\n\n        public ValuesController(ITempFileFactory tempFileFactory)\n        {\n            _tempFileFactory = tempFileFactory;\n        }\n\n        [HttpGet]\n        public IActionResult TempFile(string tempFolder)\n        {\n            ITempFile tempFile = _tempFileFactory.Create(tempFolder);\n\n            string path = tempFile.Path;\n\n            string test = \"Testing 1-2-3\";\n\n            byte[] byteArray = Encoding.ASCII.GetBytes(test);\n\n            MemoryStream stream = new MemoryStream(byteArray);\n\n            tempFile.WriteAsync(stream);\n\n            return Ok(path);\n        }\n    }\n```\n\n```\nRESULT: A file with name \"201e3212-f244-4f29-abd7-e1a799b6d855\" was created in the \"C:\\Downloads\" folder. The file contains a \"Testing 1-2-3\" row.\n```\n\n# Serializers\n\n## Json Serializer\n`IJsonSerializer` contains methods for Serialize and Deserialize object to json.\n\n```c#\n    public class ValuesController : ControllerBase\n    {\n\n        private readonly IJsonSerializer _jsonSerializer;\n\n        public ValuesController(IJsonSerializer jsonSerializer)\n        {\n            _jsonSerializer = jsonSerializer;\n        }\n\n        [HttpGet(\"json-deserialize\")]\n        public IActionResult JsonDeserialize(string objectInJsonFormat)\n        {\n            WeatherForecast model = _jsonSerializer.Deserialize\u003cWeatherForecast\u003e(objectInJsonFormat);\n\n            return Ok();\n        }\n\n        [HttpGet(\"json-serialize\")]\n        public IActionResult JsonSerialize(WeatherForecast model)\n        {\n            string json = _jsonSerializer.Serialize(model);\n\n            return Ok(json);\n        }\n    }\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgodeltech%2Fgodeltech.microservices.sharedservices","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgodeltech%2Fgodeltech.microservices.sharedservices","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgodeltech%2Fgodeltech.microservices.sharedservices/lists"}