Skip to content

murattdogan/DocumentRepositoryApi

 
 

Repository files navigation

Document Repository Api

.Net Core 2.2, PostgreSql, Amazon S3, Xunit, Docker

Description

This project aims to create a document repository to save files on Amazon S3 or shared disk space or inmemory

Features

Framework
  • .Net Core
Storage
  • PostgreSql
Authentication
  • Jwt authentication
Integration testing
  • Xunit
  • Fluent Assertions
  • Moq
Test Coverage
  • MiniCover
Monitoring
  • ElasticSearch + Kibana

Requirements

  • .Net Core >= 2.2
  • Docker

Running the API

Development

To start the application in development mode, run:

dotnet build
cd src\DocumentRepositoryApi
dotnet run

Application will be served on route: http://localhost:5000

To start the application in docker container:

docker-compose up

Docker will spin up application, postgreSql container and PgAdmin to manage database

Swagger

Swagger documentation will be available on route:

http://localhost:5000/swagger

Testing

To run integration tests:

dotnet test ./tests/DocumentRepositoryApi.IntegrationTests/DocumentRepositoryApi.IntegrationTests.csproj

To run unit tests:

dotnet test ./tests/DocumentRepositoryApi.UnitTests/DocumentRepositoryApi.UnitTests.csproj

To run unit and integration tests with script:

scripts/tests.sh

Test Coverage

scripts/coverage.sh

Coverage file can be found in coverage-html/index.html file

Set up environment

Keys and the secrets are defined in user secret file. More information can be found .net core user secrets This application uses "8c43a081-db6b-43eb-8376-df1651b2d72a" as secret key id.

*To configure PostgreSql db:

Application uses PostgreSql to store user information and document metadata (name, title and version). Connection string needs to be defined in user secret

ConnectionStrings": {
    "PostgreSql": "Your connection string"
  },

To configure Amazon S3 as your file storage repository:

AmazonS3 should be selected as datasource in appsettings:

 "Repository": {
    "Provider": "amazons3storage"
  }

Amazon S3 credential informations should be defined in user secret

 "AWS": {
    "BucketName": "Your Bucket Name",
    "Region": "Region Name",
	"Credentials":{
	"AccessKey" :"XXXX",
	"SecretKey": "XXXX"
	}
  }

To configure InMemory storage:

 "Repository": {
    "Provider": "inmemorystorage"
  }

To configure Disk file storage:

appsettings:

 "Repository": {
    "Provider": "filestorage"
  }

user secret:

 "DocumentApi": {
    "ContentPath": "shared file storage path"
  }

*To configure Compression key hash:

user secret:

 "Encryption": {
    "Key": "Base64 key"
  }

*To configure Jwt secret:

user secret:

 "Jwt": {
    "Secret": "this is my custom Secret key for authnetication"
  }

To configure Logging:

To use default console logging appsettings.json:

  "Logging": {
    "LogLevel": {
      "Default": "Warning"
    },
    "Provider": {
      "Type": "0", //// 0:default,1:ELC+Kibana
      }
  },

To use elastic search + kibana

cmd > cd DocumentRepositoryApi
cmd > docker-compose -f docker-compose.elastic.yml up

appsettings.json:

  "Logging": {
    "LogLevel": {
      "Default": "Warning"
    },
    "Provider": {
      "Type": "1", //// 0:default,1:ELC+Kibana,
	  "Uri": "http://localhost:9200"
      }
  },

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 97.9%
  • Shell 1.4%
  • Dockerfile 0.7%