Add sunnaly proxy option
This commit is contained in:
		
							parent
							
								
									9a295a85b1
								
							
						
					
					
						commit
						c56ff5d88d
					
				
					 3 changed files with 15 additions and 1 deletions
				
			
		| 
						 | 
					@ -138,3 +138,6 @@ drive:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Clustering
 | 
					# Clustering
 | 
				
			||||||
# clusterLimit: 1
 | 
					# clusterLimit: 1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Summaly proxy
 | 
				
			||||||
 | 
					# summalyProxy: "http://example.com"
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -62,6 +62,8 @@ export type Source = {
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	ghost?: string;
 | 
						ghost?: string;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						summalyProxy?: string;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	accesslog?: string;
 | 
						accesslog?: string;
 | 
				
			||||||
	twitter?: {
 | 
						twitter?: {
 | 
				
			||||||
		consumer_key: string;
 | 
							consumer_key: string;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,11 +1,20 @@
 | 
				
			||||||
import * as Koa from 'koa';
 | 
					import * as Koa from 'koa';
 | 
				
			||||||
 | 
					import * as request from 'request-promise-native';
 | 
				
			||||||
import summaly from 'summaly';
 | 
					import summaly from 'summaly';
 | 
				
			||||||
 | 
					import config from '../../config';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
module.exports = async (ctx: Koa.Context) => {
 | 
					module.exports = async (ctx: Koa.Context) => {
 | 
				
			||||||
	try {
 | 
						try {
 | 
				
			||||||
		const summary = await summaly(ctx.query.url, {
 | 
							const summary = config.summalyProxy ? await request.get({
 | 
				
			||||||
 | 
								url: config.summalyProxy,
 | 
				
			||||||
 | 
								qs: {
 | 
				
			||||||
 | 
									url: ctx.query.url
 | 
				
			||||||
 | 
								},
 | 
				
			||||||
 | 
								json: true
 | 
				
			||||||
 | 
							}) : await summaly(ctx.query.url, {
 | 
				
			||||||
			followRedirects: false
 | 
								followRedirects: false
 | 
				
			||||||
		});
 | 
							});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		summary.icon = wrap(summary.icon);
 | 
							summary.icon = wrap(summary.icon);
 | 
				
			||||||
		summary.thumbnail = wrap(summary.thumbnail);
 | 
							summary.thumbnail = wrap(summary.thumbnail);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue