mirror of
https://github.com/benjamin-wilson/public-pool.git
synced 2026-09-29 17:15:03 -07:00
feat: external pool shares (#89)
* feat:external shares --------- Co-authored-by: mrv777 <mrv777@users.noreply.github.com> Co-authored-by: Benjamin Wilson <admin@opensourceminer.com>
This commit is contained in:
co-authored by
mrv777
Benjamin Wilson
parent
0201703e35
commit
fda3f21b71
@@ -0,0 +1,31 @@
|
||||
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)
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user