lint
This commit is contained in:
parent
193ba6691d
commit
b382e8701b
@ -44,14 +44,22 @@ export const fetchAlbumURL = async (albumID: string): Promise<string> => {
|
|||||||
|
|
||||||
export const fetchAlbum = async (albumID: string): Promise<Comment[]> => {
|
export const fetchAlbum = async (albumID: string): Promise<Comment[]> => {
|
||||||
// https://api.imgur.com/post/v1/albums/zk7mdKH?client_id=${CLIENT_ID}&include=media%2Caccount
|
// https://api.imgur.com/post/v1/albums/zk7mdKH?client_id=${CLIENT_ID}&include=media%2Caccount
|
||||||
const response = await got(`https://api.imgur.com/post/v1/albums/${albumID}?client_id=${CONFIG.imgur_client_id}&include=media%2Caccount`, { agent });
|
const response = await got(
|
||||||
|
`https://api.imgur.com/post/v1/albums/${albumID}?client_id=${CONFIG.imgur_client_id}&include=media%2Caccount`,
|
||||||
|
{ agent }
|
||||||
|
);
|
||||||
return JSON.parse(response.body);
|
return JSON.parse(response.body);
|
||||||
}
|
}
|
||||||
|
|
||||||
export const fetchComments = async (galleryID: string): Promise<Comment[]> => {
|
export const fetchComments = async (galleryID: string): Promise<Comment[]> => {
|
||||||
|
/* eslint-disable max-len */
|
||||||
// https://api.imgur.com/comment/v1/comments?client_id=${CLIENT_ID}%5Bpost%5D=eq%3Ag1bk7CB&include=account%2Cadconfig&per_page=30&sort=best
|
// https://api.imgur.com/comment/v1/comments?client_id=${CLIENT_ID}%5Bpost%5D=eq%3Ag1bk7CB&include=account%2Cadconfig&per_page=30&sort=best
|
||||||
const response = await got(`https://api.imgur.com/comment/v1/comments?client_id=${CONFIG.imgur_client_id}&filter%5Bpost%5D=eq%3A${galleryID}&include=account%2Cadconfig&per_page=30&sort=best`, { agent });
|
const response = await got(
|
||||||
|
`https://api.imgur.com/comment/v1/comments?client_id=${CONFIG.imgur_client_id}&filter%5Bpost%5D=eq%3A${galleryID}&include=account%2Cadconfig&per_page=30&sort=best`,
|
||||||
|
{ agent }
|
||||||
|
);
|
||||||
return JSON.parse(response.body).data;
|
return JSON.parse(response.body).data;
|
||||||
|
/* eslint-enable max-len */
|
||||||
}
|
}
|
||||||
|
|
||||||
export const fetchGallery = async (galleryID: string): Promise<Gallery> => {
|
export const fetchGallery = async (galleryID: string): Promise<Gallery> => {
|
||||||
|
@ -26,14 +26,14 @@ export const handleAlbum = async (request: Hapi.Request, h: Hapi.ResponseToolkit
|
|||||||
pageTitle: CONFIG.page_title,
|
pageTitle: CONFIG.page_title,
|
||||||
util,
|
util,
|
||||||
});
|
});
|
||||||
} else {
|
}
|
||||||
const url = await fetchAlbumURL(albumID);
|
const url = await fetchAlbumURL(albumID);
|
||||||
return h.view('bare-album', {
|
return h.view('bare-album', {
|
||||||
url,
|
url,
|
||||||
pageTitle: CONFIG.page_title,
|
pageTitle: CONFIG.page_title,
|
||||||
util,
|
util,
|
||||||
});
|
});
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const handleUser = (request: Hapi.Request, h: Hapi.ResponseToolkit) => {
|
export const handleUser = (request: Hapi.Request, h: Hapi.ResponseToolkit) => {
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
'use strict';
|
|
||||||
|
|
||||||
import Hapi = require('@hapi/hapi');
|
import Hapi = require('@hapi/hapi');
|
||||||
|
/* eslint-disable @typescript-eslint/no-var-requires */
|
||||||
const Exiting = require('exiting');
|
const Exiting = require('exiting');
|
||||||
import Path = require('path');
|
import Path = require('path');
|
||||||
import { handleAlbum, handleGallery, handleMedia, handleTag, handleUser } from './handlers';
|
import { handleAlbum, handleGallery, handleMedia, handleTag, handleUser } from './handlers';
|
||||||
@ -34,7 +33,7 @@ const init = async () => {
|
|||||||
directory: {
|
directory: {
|
||||||
path: Path.join(__dirname, 'static/css')
|
path: Path.join(__dirname, 'static/css')
|
||||||
}
|
}
|
||||||
} as any)
|
} as any) // eslint-disable-line @typescript-eslint/no-explicit-any
|
||||||
});
|
});
|
||||||
server.views({
|
server.views({
|
||||||
engines: {
|
engines: {
|
||||||
|
21
src/types/index.d.ts
vendored
21
src/types/index.d.ts
vendored
@ -5,15 +5,6 @@ interface Account {
|
|||||||
created_at: string;
|
created_at: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Gallery {
|
|
||||||
id: string;
|
|
||||||
title: string;
|
|
||||||
account: Account;
|
|
||||||
media: Media[];
|
|
||||||
tags: Tag[];
|
|
||||||
cover: Media;
|
|
||||||
}
|
|
||||||
|
|
||||||
type MediaMimeType = 'image/jpeg' | 'image/png' | 'image/gif';
|
type MediaMimeType = 'image/jpeg' | 'image/png' | 'image/gif';
|
||||||
type MediaType = 'image';
|
type MediaType = 'image';
|
||||||
type MediaExt = 'jpeg' | 'png' | 'gif';
|
type MediaExt = 'jpeg' | 'png' | 'gif';
|
||||||
@ -64,8 +55,8 @@ interface Comment {
|
|||||||
platform_id: number;
|
platform_id: number;
|
||||||
platform: MediaPlatform;
|
platform: MediaPlatform;
|
||||||
created_at: string;
|
created_at: string;
|
||||||
updated_at: "2021-10-01T00:08:51Z",
|
updated_at: string;
|
||||||
deleted_at: null,
|
deleted_at: null;
|
||||||
next: null; //?
|
next: null; //?
|
||||||
comments: Comment[];
|
comments: Comment[];
|
||||||
account: {
|
account: {
|
||||||
@ -75,3 +66,11 @@ interface Comment {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface Gallery {
|
||||||
|
id: string;
|
||||||
|
title: string;
|
||||||
|
account: Account;
|
||||||
|
media: Media[];
|
||||||
|
tags: Tag[];
|
||||||
|
cover: Media;
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user