mirror of
https://github.com/Lissy93/awesome-privacy.git
synced 2026-03-11 08:55:33 +00:00
Linting for API
This commit is contained in:
parent
6a59c9d1f1
commit
49c77d8d49
2 changed files with 6 additions and 6 deletions
|
|
@ -56,7 +56,6 @@ app.get('/search/:searchTerm', async (c) => {
|
||||||
return c.json(mappedResults);
|
return c.json(mappedResults);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
/* Returns an array of all section IDs within a given category */
|
/* Returns an array of all section IDs within a given category */
|
||||||
app.get('/:category', async (c) => {
|
app.get('/:category', async (c) => {
|
||||||
const { categories } = await fetchAwesomePrivacyData();
|
const { categories } = await fetchAwesomePrivacyData();
|
||||||
|
|
|
||||||
|
|
@ -2,13 +2,15 @@ import * as yaml from 'js-yaml';
|
||||||
|
|
||||||
import type { AwesomePrivacy, Service } from './types';
|
import type { AwesomePrivacy, Service } from './types';
|
||||||
|
|
||||||
|
|
||||||
/* Given a category/section/listing title, return it's slug/ID */
|
/* Given a category/section/listing title, return it's slug/ID */
|
||||||
export const slugify = (title: string): string => title.toLowerCase().replace(/\s+/g, '-');
|
export const slugify = (title: string): string => title.toLowerCase().replace(/\s+/g, '-');
|
||||||
|
|
||||||
|
/* Base path, for fetching static files from GitHub CDN */
|
||||||
|
const ghCdnRoot = 'https://raw.githubusercontent.com/Lissy93/awesome-privacy';
|
||||||
|
|
||||||
/* Fetches and parses Awesome Privacy source data from GitHub CDN */
|
/* Fetches and parses Awesome Privacy source data from GitHub CDN */
|
||||||
export const fetchAwesomePrivacyData = async (): Promise<AwesomePrivacy> => {
|
export const fetchAwesomePrivacyData = async (): Promise<AwesomePrivacy> => {
|
||||||
const res = await fetch('https://raw.githubusercontent.com/Lissy93/awesome-privacy/main/awesome-privacy.yml');
|
const res = await fetch(`${ghCdnRoot}/main/awesome-privacy.yml`);
|
||||||
const text = await res.text();
|
const text = await res.text();
|
||||||
return yaml.load(text) as AwesomePrivacy;
|
return yaml.load(text) as AwesomePrivacy;
|
||||||
};
|
};
|
||||||
|
|
@ -23,10 +25,9 @@ export const fetchAllServices = async (): Promise<Service[]> => {
|
||||||
export const findBySlug = <T extends { name: string }>(collection: T[], slug: string): T | undefined =>
|
export const findBySlug = <T extends { name: string }>(collection: T[], slug: string): T | undefined =>
|
||||||
collection.find(item => slugify(item.name) === slug);
|
collection.find(item => slugify(item.name) === slug);
|
||||||
|
|
||||||
|
/* For the homepage root, fetch and render the Swagger docs */
|
||||||
export const renderRemoteIndex = async (ctx) => {
|
export const renderRemoteIndex = async (ctx) => {
|
||||||
const indexHtmlUrl = 'https://raw.githubusercontent.com/Lissy93/awesome-privacy/main/api/public/index.html';
|
const response = await fetch(`${ghCdnRoot}/main/api/public/index.html`);
|
||||||
const response = await fetch(indexHtmlUrl);
|
|
||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
const htmlContent = await response.text();
|
const htmlContent = await response.text();
|
||||||
return ctx.html(htmlContent);
|
return ctx.html(htmlContent);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue