Skip to content

Commit

Permalink
daily backup
Browse files Browse the repository at this point in the history
  • Loading branch information
Recep Güneş committed Sep 4, 2023
1 parent 468dda9 commit 1952ce7
Show file tree
Hide file tree
Showing 11 changed files with 86 additions and 50 deletions.
1 change: 0 additions & 1 deletion internal-services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,3 @@ services:
- apigateway
networks:
- fronted

4 changes: 2 additions & 2 deletions src/Buffer/Infrastructure/Buffer.Infrastructure.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
Expand All @@ -15,7 +15,7 @@
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="7.0.4" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
<PackageReference Include="Npgsql" Version="7.0.4" />
<PackageReference Include="Npgsql" Version="7.0.4" />
</ItemGroup>

<ItemGroup>
Expand Down
18 changes: 13 additions & 5 deletions src/Buffer/WebAPI/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,29 @@

builder.Services.AddSwaggerGen();

var app = builder.Build();
builder.Services.AddCors();

var app = builder.Build();

if (app.Environment.IsDevelopment())
{
app.UseSwagger();

app.UseSwaggerUI();
}

app.Use(async (context, next) =>
{
context.Request.EnableBuffering();
await next();
});

app.UseRouting();

app.Use((context, next) =>
app.UseCors(p =>
{
context.Request.EnableBuffering();
return next();
p.AllowAnyOrigin()
.AllowAnyMethod()
.AllowAnyHeader();
});

app.MapControllers();
Expand Down
15 changes: 15 additions & 0 deletions src/ExpiryChecker/WebAPI/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,23 @@

builder.Services.LoadInfrastructureLayer(builder.Configuration);

builder.Services.AddCors();

var app = builder.Build();

app.Use(async (context, next) =>
{
context.Request.EnableBuffering();
await next();
});

app.UseRouting();

app.UseCors(p =>
{
p.AllowAnyOrigin()
.AllowAnyMethod()
.AllowAnyHeader();
});

app.Run();
2 changes: 1 addition & 1 deletion src/Fronted/webui/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ FROM nginx:1.25-alpine

# Copy the built Vue application from the build-stage
COPY --from=build-stage /app/dist /usr/share/nginx/html

COPY production_nginx.conf /etc/nginx/conf.d/default.conf
# Expose port 80
EXPOSE 80

Expand Down
31 changes: 31 additions & 0 deletions src/Fronted/webui/production_nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
server {
listen 80;
server_name _;

location / {
root /usr/share/nginx/html;
index index.html;
try_files $uri $uri/ /index.html;

# Preflight request
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' '*';
add_header 'Access-Control-Allow-Headers' '*';
add_header 'Access-Control-Max-Age' 1728000;
add_header 'Content-Type' 'text/plain; charset=utf-8';
add_header 'Content-Length' 0;
return 204;
}

# Regular requests
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' '*';
add_header 'Access-Control-Allow-Headers' '*';
}

error_page 404 /404.html;
location = /404.html {
root /usr/share/nginx/html;
}
}
7 changes: 1 addition & 6 deletions src/Fronted/webui/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,7 @@ export default defineComponent({
const urls = ref([]);
axios
.get(`${process.env.VUE_APP_API_GATEWAY_URL}/get_all_urls`, {
headers: {
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Credentials": true,
},
})
.get(`${process.env.VUE_APP_API_GATEWAY_URL}/get_all_urls`)
.then((response) => {
urls.value = response.data;
});
Expand Down
20 changes: 2 additions & 18 deletions src/Fronted/webui/src/components/SearchBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -51,24 +51,14 @@ export default defineComponent({
.get(
`${process.env.VUE_APP_API_GATEWAY_URL}/get_url/${encodeURIComponent(
input
)}`,
{
headers: {
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Credentials": true,
},
}
)}`
)
.then((response) => {
this.url = response.data;
if (this.url && this.url.longUrl == null) {
return axios.post(
`${process.env.VUE_APP_API_GATEWAY_URL}/publish_url`,
{
headers: {
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Credentials": true,
},
Url: input,
ExpireDate: this.$store.state.number,
IsPublic: this.$store.state.isPublic,
Expand All @@ -85,13 +75,7 @@ export default defineComponent({
.get(
`${
process.env.VUE_APP_API_GATEWAY_URL
}/get_url/${encodeURIComponent(input)}`,
{
headers: {
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Credentials": true,
},
}
}/get_url/${encodeURIComponent(input)}`
)
.then((final_response) => {
this.url = final_response.data;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,6 @@ public static class InfrastructureLayerExtensions
{
public static IServiceCollection LoadInfrastructreLayer(this IServiceCollection service, IConfiguration configuration)
{
service.AddCors(options =>
{
options.AddPolicy("VueCorsPolicy", builder =>
{
builder
.AllowAnyOrigin()
.AllowAnyMethod()
.AllowAnyHeader()
.AllowCredentials();
});
});

var tempConfiguration = new ConfigurationBuilder()
.AddConfiguration(configuration)
Expand All @@ -28,7 +17,7 @@ public static IServiceCollection LoadInfrastructreLayer(this IServiceCollection
.Build();

service.AddOcelot(tempConfiguration);

return service;
}
}
Expand Down
9 changes: 8 additions & 1 deletion src/Gateway/Gateway.WebAPI/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,16 @@

builder.Services.LoadInfrastructreLayer(builder.Configuration);

builder.Services.AddCors();

var app = builder.Build();

app.UseCors("VueCorsPolicy");
app.UseCors(p =>
{
p.AllowAnyOrigin()
.AllowAnyMethod()
.AllowAnyHeader();
});

await app.UseOcelot();

Expand Down
16 changes: 12 additions & 4 deletions src/Shortener/WebAPI/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,29 @@

builder.Services.AddSwaggerGen();

builder.Services.AddCors();

var app = builder.Build();

if (app.Environment.IsDevelopment())
{
app.UseSwagger();

app.UseSwaggerUI();
}

app.Use(async (context, next) =>
{
context.Request.EnableBuffering();
await next();
});

app.UseRouting();

app.Use((context, next) =>
app.UseCors(p =>
{
context.Request.EnableBuffering();
return next();
p.AllowAnyOrigin()
.AllowAnyMethod()
.AllowAnyHeader();
});

app.MapControllers();
Expand Down

0 comments on commit 1952ce7

Please sign in to comment.