mirror of
https://github.com/benjamin-wilson/public-pool.git
synced 2026-09-29 09:05:06 -07:00
* feat:external shares --------- Co-authored-by: mrv777 <mrv777@users.noreply.github.com> Co-authored-by: Benjamin Wilson <admin@opensourceminer.com>
32 lines
1019 B
TypeScript
32 lines
1019 B
TypeScript
import { Injectable } from '@nestjs/common';
|
|
import { HttpService } from '@nestjs/axios';
|
|
import { ConfigService } from '@nestjs/config';
|
|
import { ExternalPoolShare } from '../models/ExternalPoolShare';
|
|
|
|
@Injectable()
|
|
export class ExternalSharesService {
|
|
private readonly shareApiUrl: string;
|
|
private readonly shareApiKey: string;
|
|
|
|
constructor(
|
|
private readonly configService: ConfigService,
|
|
private readonly httpService: HttpService
|
|
) {
|
|
this.shareApiUrl = this.configService.get('SHARE_SUBMISSION_URL') || 'https://web.public-pool.io';
|
|
this.shareApiKey = this.configService.get('SHARE_SUBMISSION_API_KEY');
|
|
}
|
|
|
|
public submitShare(share: ExternalPoolShare): void {
|
|
this.httpService.post(`${this.shareApiUrl}/api/share`, share, {
|
|
headers: {
|
|
'x-api-key': this.shareApiKey
|
|
}
|
|
}).subscribe({
|
|
next: () =>{
|
|
console.log('External share accepted');
|
|
},
|
|
error: (error) => console.error('Failed to submit share to API:', error.message)
|
|
});
|
|
}
|
|
}
|