Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/services/OcelotGateway/OcelotGateway.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Ocelot" Version="18.0.0" />
<PackageReference Include="Swashbuckle.AspNetCore.Swagger" Version="6.3.0" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="6.3.0" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerUI" Version="6.3.0" />
</ItemGroup>

</Project>
25 changes: 25 additions & 0 deletions src/services/OcelotGateway/OcelotGateway.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.31919.166
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OcelotGateway", "OcelotGateway.csproj", "{A9BAB0AA-07EA-4A66-8BDE-8E4B5887B8E8}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{A9BAB0AA-07EA-4A66-8BDE-8E4B5887B8E8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A9BAB0AA-07EA-4A66-8BDE-8E4B5887B8E8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A9BAB0AA-07EA-4A66-8BDE-8E4B5887B8E8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A9BAB0AA-07EA-4A66-8BDE-8E4B5887B8E8}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {F57F9553-B530-4FD8-874D-5E6B1E78A780}
EndGlobalSection
EndGlobal
3 changes: 3 additions & 0 deletions src/services/OcelotGateway/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
using OcelotGateway;

Startup.RunApp(args);
28 changes: 28 additions & 0 deletions src/services/OcelotGateway/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:9932",
"sslPort": 44313
}
},
"profiles": {
"OcelotGateway": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "http://localhost:5041",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
83 changes: 83 additions & 0 deletions src/services/OcelotGateway/Startup.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
using Microsoft.OpenApi.Models;
using Ocelot.DependencyInjection;
using Ocelot.Middleware;

namespace OcelotGateway
{
public class Startup
{
private readonly IConfiguration _configuration;
private readonly IWebHostEnvironment _env;

public Startup(IConfiguration configuration, IWebHostEnvironment env)
{
_configuration = configuration;
_env = env;
}

public void ConfigureServices(IServiceCollection services)
{
services.AddControllersWithViews();
services.AddCors(opt =>
{
opt.AddDefaultPolicy(builder =>
{
builder
.AllowAnyOrigin()
.AllowAnyHeader()
.AllowAnyMethod();
});
});

services.AddOcelot();
}

public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}

app
.UseStaticFiles()
.UseRouting()
.UseCors()
.UseEndpoints(endpoints =>
{
endpoints.MapDefaultControllerRoute();
});

app.Map("/swagger/v1/swagger.json", b =>
{
b.Run(async x => {
var json = File.ReadAllText("swagger.json");
await x.Response.WriteAsync(json);
});
});
app.UseSwaggerUI(c =>
{
c.SwaggerEndpoint("/swagger/v1/swagger.json", "Ocelot");
});

app.UseOcelot().Wait();
}

public static IHostBuilder CreateHostBuilder(string[] args)
{
return Host
.CreateDefaultBuilder(args)
.ConfigureAppConfiguration((context, builder) => builder
.AddJsonFile("appsettings.json", false, true)
.AddJsonFile($"appsettings.{context.HostingEnvironment.EnvironmentName}.json", true)
.AddJsonFile("ocelot.json")
.AddEnvironmentVariables())
.ConfigureWebHostDefaults(webBuilder => { webBuilder.UseStartup<Startup>(); });
}

public static void RunApp(string[] args)
{
CreateHostBuilder(args).Build().Run();
}
}
}
8 changes: 8 additions & 0 deletions src/services/OcelotGateway/appsettings.Development.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Debug",
"Microsoft.AspNetCore": "Warning"
}
}
}
9 changes: 9 additions & 0 deletions src/services/OcelotGateway/appsettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Debug",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}
31 changes: 31 additions & 0 deletions src/services/OcelotGateway/ocelot.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"Routes": [
{
"DownstreamPathTemplate": "/ocelot",
"DownstreamScheme": "http",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": 5000
}
],
"UpstreamPathTemplate": "/api/example",
"UpstreamHttpMethod": [ "Get" ]
},
{
"DownstreamPathTemplate": "/",
"DownstreamScheme": "http",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": 3000
}
],
"UpstreamPathTemplate": "/api/nest",
"UpstreamHttpMethod": [ "Get" ]
}
],
"GlobalConfiguration": {
"BaseUrl": "http://localhost:5041"
}
}
34 changes: 34 additions & 0 deletions src/services/OcelotGateway/swagger.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"openapi": "3.0.1",
"info": {
"title": "ocelot example",
"version": "v1"
},
"paths": {
"/api/example": {
"get": {
"tags": [
"Ocelot"
],
"responses": {
"200": {
"description": "Success"
}
}
}
},
"/api/nest": {
"get": {
"tags": [
"Nest"
],
"responses": {
"200": {
"description": "Success"
}
}
}
}
},
"components": { }
}
5 changes: 4 additions & 1 deletion src/services/auth/Auth.Web/Auth.Web.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
Expand All @@ -21,6 +21,9 @@
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.3" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="6.0.3" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL.NodaTime" Version="6.0.3" />
<PackageReference Include="Swashbuckle.AspNetCore.Swagger" Version="6.3.0" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="6.3.0" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerUI" Version="6.3.0" />
</ItemGroup>

<ItemGroup>
Expand Down
8 changes: 6 additions & 2 deletions src/services/auth/Auth.Web/Controllers/ExampleController.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
using AuthorizationServer.Web.Domain;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using OpenIddict.Validation.AspNetCore;

namespace AuthorizationServer.Web.Controllers
{
Expand All @@ -12,5 +10,11 @@ public IActionResult Index()
{
return Ok("Hello, World!");
}

[HttpGet("/ocelot")]
public IActionResult GetOcelot()
{
return Ok("Hello, Ocelot!");
}
}
}
16 changes: 15 additions & 1 deletion src/services/auth/Auth.Web/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.OpenApi.Models;

namespace AuthorizationServer.Web
{
Expand Down Expand Up @@ -38,6 +39,11 @@ public void ConfigureServices(IServiceCollection services)
.AddIdentity()
.AddOpenIddictServer(_env);

services.AddSwaggerGen(c =>
{
c.SwaggerDoc("v1", new OpenApiInfo { Title = "auth", Version = "v1" });
});

services.AddHealthChecks().AddCheck<HealthCheck>("Default");
}

Expand All @@ -59,7 +65,15 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
endpoints.MapDefaultControllerRoute();
endpoints.MapHealthChecks("/health");
});


app.UseSwagger();
app.UseSwaggerUI(c =>
{
c.SwaggerEndpoint("/swagger/v1/swagger.json", "auth v1");
c.RoutePrefix = "api";
}
);

app.InitDbContext<IdentityDbContext>(dbContext => dbContext.Database.Migrate());
}

Expand Down
25 changes: 25 additions & 0 deletions src/services/nest-demo/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
module.exports = {
parser: '@typescript-eslint/parser',
parserOptions: {
project: 'tsconfig.json',
tsconfigRootDir : __dirname,
sourceType: 'module',
},
plugins: ['@typescript-eslint/eslint-plugin'],
extends: [
'plugin:@typescript-eslint/recommended',
'plugin:prettier/recommended',
],
root: true,
env: {
node: true,
jest: true,
},
ignorePatterns: ['.eslintrc.js'],
rules: {
'@typescript-eslint/interface-name-prefix': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-explicit-any': 'off',
},
};
35 changes: 35 additions & 0 deletions src/services/nest-demo/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# compiled output
/dist
/node_modules

# Logs
logs
*.log
npm-debug.log*
pnpm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# OS
.DS_Store

# Tests
/coverage
/.nyc_output

# IDEs and editors
/.idea
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace

# IDE - VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
4 changes: 4 additions & 0 deletions src/services/nest-demo/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"singleQuote": true,
"trailingComma": "all"
}
Loading