Skip to content

Commit 2d48820

Browse files
committed
Add OpenAPI and Feature Links
1 parent f4f8856 commit 2d48820

File tree

6 files changed

+83
-21
lines changed

6 files changed

+83
-21
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { TextLink } from "@servicestack/react"
2+
3+
export default () => {
4+
5+
const navClass = (path: string) => [
6+
"text-sm leading-6 text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-gray-50",
7+
location.pathname.startsWith(path) ? "font-bold" : "",
8+
].join(" ")
9+
10+
return (
11+
<nav className="pt-8 columns-2 sm:flex sm:justify-center sm:space-x-12" aria-label="Footer">
12+
<div className="pb-6">
13+
<TextLink href="/chat" className={navClass("/chat")}>AI Chat</TextLink>
14+
</div>
15+
<div className="pb-6">
16+
<TextLink href="/swagger" className={navClass("/swagger")}>Swagger UI</TextLink>
17+
</div>
18+
<div className="pb-6">
19+
<TextLink href="/ui" className={navClass("/ui")}>API Explorer</TextLink>
20+
</div>
21+
<div className="pb-6">
22+
<TextLink href="/about" className={navClass("/about")}>About</TextLink>
23+
</div>
24+
<div className="pb-6">
25+
<TextLink href="/posts" className={navClass("/posts")}>Archive</TextLink>
26+
</div>
27+
<div className="pb-6">
28+
<TextLink href="/privacy" className={navClass("/privacy")}>Privacy</TextLink>
29+
</div>
30+
</nav>
31+
)
32+
}

MyApp.Client/src/components/Footer.tsx

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,11 @@
1-
import { NavLink } from "react-router-dom"
1+
import FeatureLinks from "./FeatureLinks"
22

33
export default () => {
4-
5-
const navClass = ({isActive}: any) => [
6-
"text-sm leading-6 text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-gray-50",
7-
isActive ? "font-bold" : "",
8-
].join(" ")
9-
104
return (
115
<footer className="bg-slate-50 dark:bg-slate-900 border-t border-slate-200 dark:border-slate-800">
12-
13-
<nav className="pt-8 columns-2 sm:flex sm:justify-center sm:space-x-12" aria-label="Footer">
14-
<div className="pb-6">
15-
<NavLink to="/about" className={navClass}>About</NavLink>
16-
</div>
17-
<div className="pb-6">
18-
<NavLink to="/posts" className={navClass}>Archive</NavLink>
19-
</div>
20-
<div className="pb-6">
21-
<NavLink to="/privacy" className={navClass}>Privacy</NavLink>
22-
</div>
23-
</nav>
24-
6+
7+
<FeatureLinks />
8+
259
<div className="container mx-auto px-5">
2610
<div className="py-28 flex flex-col lg:flex-row items-center">
2711
<h3 className="text-4xl lg:text-6xl font-bold tracking-tighter leading-tight text-center lg:text-left mb-10 lg:mb-0 lg:pr-4 lg:w-1/2">

MyApp.Client/src/lib/gateway.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,17 @@ import { appendQueryString, nameOf, IReturn, JsonServiceClient } from "@services
33
import useSWR from "swr"
44
import { Authenticate } from "@/lib/dtos"
55

6+
const serverRoutePaths = [
7+
'/Identity',
8+
'/api',
9+
'/ui',
10+
'/chat',
11+
'/admin-ui',
12+
'/swagger',
13+
]
14+
615
export function isServerRoute(path:string) {
7-
return path.startsWith('/Identity')
16+
return serverRoutePaths.some(x => path.startsWith(x))
817
}
918

1019
export const Routes = {

MyApp.Client/src/pages/index.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import SrcPage from "@/components/SrcPage"
99
import { generateSlug, dateLabel, dateTimestamp } from "@/lib/utils"
1010
import { PressContext } from "@/contexts"
1111
import { useContext } from "react"
12+
import FeatureLinks from "@/components/FeatureLinks"
1213

1314
const Index = () => {
1415
const press = useContext(PressContext)
@@ -69,6 +70,8 @@ const Index = () => {
6970

7071
<AutoUis className="mt-40 max-w-7xl mx-auto" />
7172

73+
<FeatureLinks />
74+
7275
<div className="container mx-auto px-5 mb-24">
7376
{!primaryPost ? null : <section>
7477
<div className="mb-8 md:mb-16">

MyApp/Configure.OpenApi.cs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
using ServiceStack;
2+
3+
[assembly: HostingStartup(typeof(MyApp.ConfigureOpenApi))]
4+
5+
namespace MyApp;
6+
7+
public class ConfigureOpenApi : IHostingStartup
8+
{
9+
public void Configure(IWebHostBuilder builder) => builder
10+
.ConfigureServices((context, services) => {
11+
if (context.HostingEnvironment.IsDevelopment())
12+
{
13+
services.AddEndpointsApiExplorer();
14+
services.AddSwaggerGen();
15+
services.AddServiceStackSwagger();
16+
// services.AddBasicAuth<Data.ApplicationUser>();
17+
// services.AddApiKeys();
18+
// services.AddJwtAuth();
19+
20+
services.AddTransient<IStartupFilter,StartupFilter>();
21+
}
22+
});
23+
24+
public class StartupFilter : IStartupFilter
25+
{
26+
public Action<IApplicationBuilder> Configure(Action<IApplicationBuilder> next) => app =>
27+
{
28+
app.UseSwagger();
29+
app.UseSwaggerUI();
30+
next(app);
31+
};
32+
}
33+
}

MyApp/MyApp.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="10.*" />
2626
<PackageReference Include="ServiceStack" Version="8.*" />
2727
<PackageReference Include="ServiceStack.Mvc" Version="8.*" />
28+
<PackageReference Include="ServiceStack.OpenApi.Swashbuckle" Version="8.10.1" />
2829
<PackageReference Include="ServiceStack.Server" Version="8.*" />
2930
<PackageReference Include="ServiceStack.Extensions" Version="8.*" />
3031
<PackageReference Include="ServiceStack.Ormlite.Sqlite.Data" Version="8.*" />

0 commit comments

Comments
 (0)