lint
This commit is contained in:
parent
193ba6691d
commit
b382e8701b
|
@ -11,23 +11,23 @@ const GALLERY_JSON_REGEX = /window\.postDataJSON=(".*")$/;
|
||||||
const agent = {
|
const agent = {
|
||||||
http: CONFIG.http_proxy
|
http: CONFIG.http_proxy
|
||||||
? new HttpProxyAgent({
|
? new HttpProxyAgent({
|
||||||
keepAlive: true,
|
keepAlive: true,
|
||||||
keepAliveMsecs: 1000,
|
keepAliveMsecs: 1000,
|
||||||
maxSockets: 256,
|
maxSockets: 256,
|
||||||
maxFreeSockets: 256,
|
maxFreeSockets: 256,
|
||||||
scheduling: 'lifo',
|
scheduling: 'lifo',
|
||||||
proxy: CONFIG.http_proxy,
|
proxy: CONFIG.http_proxy,
|
||||||
})
|
})
|
||||||
: httpGlobalAgent,
|
: httpGlobalAgent,
|
||||||
https: CONFIG.https_proxy
|
https: CONFIG.https_proxy
|
||||||
? new HttpsProxyAgent({
|
? new HttpsProxyAgent({
|
||||||
keepAlive: true,
|
keepAlive: true,
|
||||||
keepAliveMsecs: 1000,
|
keepAliveMsecs: 1000,
|
||||||
maxSockets: 256,
|
maxSockets: 256,
|
||||||
maxFreeSockets: 256,
|
maxFreeSockets: 256,
|
||||||
scheduling: 'lifo',
|
scheduling: 'lifo',
|
||||||
proxy: CONFIG.https_proxy,
|
proxy: CONFIG.https_proxy,
|
||||||
})
|
})
|
||||||
: httpsGlobalAgent
|
: httpsGlobalAgent
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -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);
|
|
||||||
return h.view('bare-album', {
|
|
||||||
url,
|
|
||||||
pageTitle: CONFIG.page_title,
|
|
||||||
util,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
const url = await fetchAlbumURL(albumID);
|
||||||
|
return h.view('bare-album', {
|
||||||
|
url,
|
||||||
|
pageTitle: CONFIG.page_title,
|
||||||
|
util,
|
||||||
|
});
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const handleUser = (request: Hapi.Request, h: Hapi.ResponseToolkit) => {
|
export const handleUser = (request: Hapi.Request, h: Hapi.ResponseToolkit) => {
|
||||||
|
|
13
src/index.ts
13
src/index.ts
|
@ -1,8 +1,7 @@
|
||||||
'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';
|
||||||
|
|
||||||
import CONFIG from './config';
|
import CONFIG from './config';
|
||||||
|
@ -31,10 +30,10 @@ const init = async () => {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
path: '/css/{param*}',
|
path: '/css/{param*}',
|
||||||
handler: ({
|
handler: ({
|
||||||
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: {
|
||||||
|
|
|
@ -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