Skip to content
This repository has been archived by the owner on Jul 12, 2024. It is now read-only.

Commit

Permalink
refactor: config port binding
Browse files Browse the repository at this point in the history
  • Loading branch information
foxminchan committed May 13, 2024
1 parent 08fefe8 commit 8927d4e
Show file tree
Hide file tree
Showing 11 changed files with 40 additions and 51 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,10 @@ docker-compose --env-file .env up -d
**You can access the following services:**

1. `https://localhost:7080` for identity server
2. `https://localhost:7070` for all the REST API document
3. `https://localhost:7060` for user facing website
4. `https://localhost:7050` for admin facing website
1. `https://localhost:6000` for identity server
2. `https://localhost:5000` for all the REST API document
3. `https://localhost:4000` for user facing website
4. `https://localhost:3000` for admin facing website
5. `https://localhost:1888` for observability dashboard

### Running the application
Expand Down
4 changes: 2 additions & 2 deletions src/RookieShop.ApiService/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"OTEL_EXPORTER_OTLP_ENDPOINT": "http://localhost:4317"
},
"dotnetRunMessages": true,
"applicationUrl": "http://localhost:7071"
"applicationUrl": "http://localhost:5001"
},
"https": {
"commandName": "Project",
Expand All @@ -21,7 +21,7 @@
"OTEL_EXPORTER_OTLP_ENDPOINT": "http://localhost:4317"
},
"dotnetRunMessages": true,
"applicationUrl": "https://localhost:7070"
"applicationUrl": "https://localhost:5000"
},
"Container (.NET SDK)": {
"commandName": "SdkContainer",
Expand Down
18 changes: 16 additions & 2 deletions src/RookieShop.Domain/Entities/FeedbackAggregator/Feedback.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using RookieShop.Domain.Entities.CustomerAggregator;
using Ardalis.GuardClauses;
using RookieShop.Domain.Entities.CustomerAggregator;
using RookieShop.Domain.Entities.FeedbackAggregator.Primitives;
using RookieShop.Domain.Entities.ProductAggregator;
using RookieShop.Domain.SeedWork;
Expand All @@ -7,7 +8,20 @@ namespace RookieShop.Domain.Entities.FeedbackAggregator;

public sealed class Feedback : EntityBase, IAggregateRoot
{
public FeedbackId Id { get; set; }
/// <summary>
/// EF mapping constructor
/// </summary>
public Feedback()
{
}

public Feedback(string? content, int rating)
{
Content = content;
Rating = Guard.Against.OutOfRange(rating, nameof(rating), 1, 5);
}

public FeedbackId Id { get; set; } = new(Guid.NewGuid());
public string? Content { get; set; }
public int Rating { get; set; }
public Customer? Customer { get; set; }
Expand Down
4 changes: 2 additions & 2 deletions src/RookieShop.Domain/Entities/OrderAggregator/OrderDetail.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ public OrderDetail()

public OrderDetail(int quantity, decimal price)
{
Quantity = Guard.Against.NegativeOrZero(quantity);
Price = Guard.Against.Negative(price);
Quantity = Guard.Against.OutOfRange(quantity, nameof(quantity), 1, int.MaxValue);
Price = Guard.Against.OutOfRange(price, nameof(price), 0, decimal.MaxValue);
}

public ProductId ProductId { get; set; }
Expand Down
8 changes: 4 additions & 4 deletions src/RookieShop.Domain/Entities/ProductAggregator/Product.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public Product()
{
Name = Guard.Against.NullOrEmpty(name);
Description = description;
Quantity = Guard.Against.Negative(quantity);
Quantity = Guard.Against.OutOfRange(quantity, nameof(quantity), 0, int.MaxValue);
Status = quantity > 0 ? ProductStatus.InStock : ProductStatus.OutOfStock;
Price = ProductPrice.Create(price, priceSale);
}
Expand All @@ -47,8 +47,8 @@ public Product()
public static class Factory
{
public static Product Create(
string name,
string? description,
string name,
string? description,
int quantity,
decimal price,
decimal priceSale,
Expand All @@ -60,7 +60,7 @@ public static class Factory

if (categoryId != default) product.Category!.Id = categoryId;

if (productImages is null)
if (productImages is null)
return product;

foreach (var productImage in productImages)
Expand Down
7 changes: 4 additions & 3 deletions src/RookieShop.IdentityService/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,15 @@ public static class Config
ClientName = "Store Front",
ClientSecrets = { new("secret".Sha256()) },
AllowedGrantTypes = [GrantType.AuthorizationCode],
RedirectUris = { $"{configuration["Client:StoreFront"]}/api/auth/callback/duende-identityserver6" },
PostLogoutRedirectUris = { $"{configuration["Client:StoreFront"]}" },
RedirectUris = { $"{configuration["Client:StoreFront"]}/signin-oidc" },
PostLogoutRedirectUris = { $"{configuration["Client:StoreFront"]}/signout-callback-oidc" },
AllowedCorsOrigins = { $"{configuration["Client:StoreFront"]}" },
AllowedScopes =
{
IdentityServerConstants.StandardScopes.OpenId,
IdentityServerConstants.StandardScopes.Profile,
AuthScope.All
AuthScope.Read,
AuthScope.Write
}
},
new()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"ASPNETCORE_ENVIRONMENT": "Development",
"OTEL_EXPORTER_OTLP_ENDPOINT": "http://localhost:4317"
},
"applicationUrl": "https://localhost:7080"
"applicationUrl": "https://localhost:6000"
},
"Container (.NET SDK)": {
"commandName": "SdkContainer",
Expand Down
2 changes: 1 addition & 1 deletion ui/backoffice/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"node": ">=18.0.0"
},
"scripts": {
"dev": "cross-env NODE_TLS_REJECT_UNAUTHORIZED=0 NODE_OPTIONS=--max_old_space_size=4096 refine dev --port 7050",
"dev": "cross-env NODE_TLS_REJECT_UNAUTHORIZED=0 NODE_OPTIONS=--max_old_space_size=4096 refine dev",
"build": "refine build",
"start": "refine start",
"lint": "eslint '**/*.{js,jsx,ts,tsx}'",
Expand Down
2 changes: 1 addition & 1 deletion ui/backoffice/src/app/_refine_context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import routerProvider from "@refinedev/nextjs-router";
import { ColorModeContextProvider } from "@contexts/color-mode";
import { dataProvider } from "@providers/data-provider";
import { PropsWithChildren } from "react";
import { Alert } from "@mui/material";

type RefineContextProps = {
defaultMode?: string;
Expand Down Expand Up @@ -101,7 +102,6 @@ const App = (props: PropsWithChildren<AppProps>) => {

return (
<>
<GitHubBanner />
<RefineKbarProvider>
<ColorModeContextProvider defaultMode={defaultMode}>
<RefineSnackbarProvider>
Expand Down
15 changes: 2 additions & 13 deletions ui/backoffice/src/app/login/page.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
"use client";

import { useLogin } from "@refinedev/core";

import Box from "@mui/material/Box";
import Button from "@mui/material/Button";
import Container from "@mui/material/Container";
import Typography from "@mui/material/Typography";
import { useLogin } from "@refinedev/core";
import { ThemedTitleV2 } from "@refinedev/mui";
import Container from "@mui/material/Container";

import { AppIcon } from "@components/app-icon";

Expand Down Expand Up @@ -46,15 +44,6 @@ export default function Login() {
>
Sign in
</Button>
<Typography align="center" color={"text.secondary"} fontSize="12px">
Powered by
<img
style={{ padding: "0 5px" }}
alt="Auth0"
src="https://refine.ams3.cdn.digitaloceanspaces.com/superplate-auth-icons%2Fauth0-2.svg"
/>
Auth0
</Typography>
</Box>
</Container>
);
Expand Down
21 changes: 3 additions & 18 deletions ui/storefront/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"$schema": "http://json.schemastore.org/launchsettings.json",
"profiles": {
"http": {
"commandName": "Project",
Expand All @@ -7,7 +8,7 @@
"ASPNETCORE_ENVIRONMENT": "Development"
},
"dotnetRunMessages": true,
"applicationUrl": "http://localhost:5214"
"applicationUrl": "http://localhost:4001"
},
"https": {
"commandName": "Project",
Expand All @@ -16,14 +17,7 @@
"ASPNETCORE_ENVIRONMENT": "Development"
},
"dotnetRunMessages": true,
"applicationUrl": "https://localhost:7075;http://localhost:5214"
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
"applicationUrl": "https://localhost:4000"
},
"Container (.NET SDK)": {
"commandName": "SdkContainer",
Expand All @@ -36,14 +30,5 @@
"publishAllPorts": true,
"useSSL": true
}
},
"$schema": "http://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:13403",
"sslPort": 44316
}
}
}

0 comments on commit 8927d4e

Please sign in to comment.