mirror of
https://github.com/collinbarrett/FilterLists.git
synced 2026-03-11 09:04:27 +00:00
refactor(web): ♻️ change directory api url
This commit is contained in:
parent
484a8a9a87
commit
05da0f26cf
14 changed files with 32 additions and 18 deletions
4
.github/workflows/directory.yml
vendored
4
.github/workflows/directory.yml
vendored
|
|
@ -89,8 +89,8 @@ jobs:
|
|||
AZURE_WEBAPP_NAME: app-filterlists-directory-prod
|
||||
|
||||
environment:
|
||||
name: production
|
||||
url: https://api.filterlists.com/swagger/index.html
|
||||
name: production-directory-api
|
||||
url: https://api.filterlists.com
|
||||
|
||||
steps:
|
||||
- name: Deploy to Azure
|
||||
|
|
|
|||
2
.github/workflows/web.yml
vendored
2
.github/workflows/web.yml
vendored
|
|
@ -26,7 +26,7 @@ jobs:
|
|||
if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed')
|
||||
|
||||
environment:
|
||||
name: production
|
||||
name: production-web
|
||||
url: https://aspire.filterlists.com # TODO: change to root when merging aspire to main
|
||||
|
||||
steps:
|
||||
|
|
|
|||
|
|
@ -38,4 +38,14 @@ internal static void AddOpenApiGen(this IServiceCollection services)
|
|||
options.CustomSchemaIds(s => s.FullName?.Replace("+", "."));
|
||||
});
|
||||
}
|
||||
|
||||
internal static void UseSwaggerCustom(this IApplicationBuilder app)
|
||||
{
|
||||
app.UseSwagger();
|
||||
app.UseSwaggerUI(options =>
|
||||
{
|
||||
options.SwaggerEndpoint("/swagger/v1/swagger.json", "FilterLists Directory API v1");
|
||||
options.RoutePrefix = string.Empty;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -4,6 +4,10 @@
|
|||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
builder.Services.AddCors(options => options.AddDefaultPolicy(policy =>
|
||||
policy.WithOrigins("https://filterlists.com", "https://aspire.filterlists.com") // TODO: rm 'aspire.' when merging aspire to main
|
||||
.WithMethods("GET")
|
||||
.AllowAnyHeader()));
|
||||
builder.WebHost.ConfigureKestrel(serverOptions => serverOptions.AddServerHeader = false);
|
||||
builder.AddServiceDefaults();
|
||||
builder.Services.AddProblemDetails();
|
||||
|
|
@ -13,9 +17,9 @@
|
|||
var app = builder.Build();
|
||||
|
||||
app.UseExceptionHandler();
|
||||
app.UseCors();
|
||||
app.MapEndpoints();
|
||||
app.MapDefaultEndpoints();
|
||||
app.UseSwagger();
|
||||
app.UseSwaggerUI();
|
||||
app.UseSwaggerCustom();
|
||||
|
||||
app.Run();
|
||||
|
|
@ -115,7 +115,7 @@ const GitHub = () => (
|
|||
const Api = () => (
|
||||
<Tag>
|
||||
<a
|
||||
href="/api"
|
||||
href="https://api.filterlists.com"
|
||||
title="FilterLists API"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
|
|
|
|||
|
|
@ -2,6 +2,6 @@ import { Language } from "../interfaces/Language";
|
|||
import { useApiData } from "./useApiData";
|
||||
|
||||
export const useLanguages = () =>
|
||||
(useApiData<Language[]>("/api/directory/languages") || []).sort(
|
||||
(useApiData<Language[]>("https://api.filterlists.com/languages") || []).sort(
|
||||
(a: Language, b: Language) => a.name.localeCompare(b.name)
|
||||
);
|
||||
|
|
|
|||
|
|
@ -2,6 +2,6 @@ import { License } from "../interfaces/License";
|
|||
import { useApiData } from "./useApiData";
|
||||
|
||||
export const useLicenses = () =>
|
||||
(useApiData<License[]>("/api/directory/licenses") || []).sort(
|
||||
(useApiData<License[]>("https://api.filterlists.com/licenses") || []).sort(
|
||||
(a: License, b: License) => a.name.localeCompare(b.name)
|
||||
);
|
||||
|
|
|
|||
|
|
@ -2,5 +2,5 @@ import { ListDetails } from "../interfaces/ListDetails";
|
|||
import { useApiData } from "./useApiData";
|
||||
|
||||
export const useListDetails = (id: number) => {
|
||||
return useApiData<ListDetails>("/api/directory/lists/" + id);
|
||||
return useApiData<ListDetails>("https://api.filterlists.com/lists/" + id);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import { List } from "../interfaces/List";
|
|||
import { useApiData } from "./useApiData";
|
||||
|
||||
export const useLists = () => {
|
||||
const lists = useApiData<List[]>("/api/directory/lists");
|
||||
const lists = useApiData<List[]>("https://api.filterlists.com/lists");
|
||||
lists && lists.forEach((l) => (l.slug = slugify(l.name, SlugifyOptions)));
|
||||
return (lists || []).sort((a: List, b: List) => a.name.localeCompare(b.name));
|
||||
};
|
||||
|
|
|
|||
|
|
@ -2,6 +2,6 @@ import { Maintainer } from "../interfaces/Maintainer";
|
|||
import { useApiData } from "./useApiData";
|
||||
|
||||
export const useMaintainers = () =>
|
||||
(useApiData<Maintainer[]>("/api/directory/maintainers") || []).sort(
|
||||
(a: Maintainer, b: Maintainer) => a.name.localeCompare(b.name)
|
||||
);
|
||||
(
|
||||
useApiData<Maintainer[]>("https://api.filterlists.com/maintainers") || []
|
||||
).sort((a: Maintainer, b: Maintainer) => a.name.localeCompare(b.name));
|
||||
|
|
|
|||
|
|
@ -2,6 +2,6 @@ import { Software } from "../interfaces/Software";
|
|||
import { useApiData } from "./useApiData";
|
||||
|
||||
export const useSoftware = () =>
|
||||
(useApiData<Software[]>("/api/directory/software") || []).sort(
|
||||
(useApiData<Software[]>("https://api.filterlists.com/software") || []).sort(
|
||||
(a: Software, b: Software) => a.name.localeCompare(b.name)
|
||||
);
|
||||
|
|
|
|||
|
|
@ -2,6 +2,6 @@ import { Syntax } from "../interfaces/Syntax";
|
|||
import { useApiData } from "./useApiData";
|
||||
|
||||
export const useSyntaxes = () =>
|
||||
(useApiData<Syntax[]>("/api/directory/syntaxes") || []).sort(
|
||||
(useApiData<Syntax[]>("https://api.filterlists.com/syntaxes") || []).sort(
|
||||
(a: Syntax, b: Syntax) => a.name.localeCompare(b.name)
|
||||
);
|
||||
|
|
|
|||
|
|
@ -2,6 +2,6 @@ import { Tag } from "../interfaces/Tag";
|
|||
import { useApiData } from "./useApiData";
|
||||
|
||||
export const useTags = () =>
|
||||
(useApiData<Tag[]>("/api/directory/tags") || []).sort((a: Tag, b: Tag) =>
|
||||
a.name.localeCompare(b.name)
|
||||
(useApiData<Tag[]>("https://api.filterlists.com/tags") || []).sort(
|
||||
(a: Tag, b: Tag) => a.name.localeCompare(b.name)
|
||||
);
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ const { createProxyMiddleware } = require("http-proxy-middleware");
|
|||
|
||||
module.exports = function (app) {
|
||||
app.use(
|
||||
"/api",
|
||||
"https://api.filterlists.com",
|
||||
createProxyMiddleware({
|
||||
target: "http://localhost:8080",
|
||||
changeOrigin: true,
|
||||
|
|
|
|||
Loading…
Reference in a new issue