File tree Expand file tree Collapse file tree 4 files changed +34
-6
lines changed
Expand file tree Collapse file tree 4 files changed +34
-6
lines changed Original file line number Diff line number Diff line change 11import { getOrcicornShiftCodes } from './source/orcicorn' ;
22import { getFextralifeShiftCodes } from './source/fextralife' ;
3+ import { getCodeVaultShiftCodes } from './source/codevault' ;
34
45export async function * getShiftCodes ( ) {
56 yield * getFextralifeShiftCodes ( ) ;
67 yield * getOrcicornShiftCodes ( ) ;
8+ yield * getCodeVaultShiftCodes ( ) ;
79}
Original file line number Diff line number Diff line change 1+ import { ShiftCode } from '../types' ;
2+
3+ import { parseDate } from '../utils/parseDate' ;
4+
5+ const BL4_SHIFT_CODES_URL = 'https://code-vault.celo.workers.dev/api/codes' ;
6+
7+ export async function * getCodeVaultBL4ShiftCodes ( ) : AsyncGenerator < ShiftCode > {
8+ const response = await fetch ( BL4_SHIFT_CODES_URL ) ;
9+ const json = ( await response . json ( ) ) as {
10+ data : { code : string ; created_at : string } [ ] ;
11+ } ;
12+
13+ for ( const entry of json . data ) {
14+ yield {
15+ code : entry . code ,
16+ game : 'Borderlands 4' ,
17+ platform : 'Universal' ,
18+ reward : 'Unknown' ,
19+ created : parseDate ( entry . created_at ) ,
20+ } ;
21+ }
22+ }
23+
24+ export async function * getCodeVaultShiftCodes ( ) : AsyncGenerator < ShiftCode > {
25+ yield * getCodeVaultBL4ShiftCodes ( ) ;
26+ }
Original file line number Diff line number Diff line change @@ -3,15 +3,10 @@ const Pick = require('stream-json/filters/Pick');
33const { streamValues} = require ( 'stream-json/streamers/StreamValues' ) ;
44
55import { ShiftCode } from '../types' ;
6+ import { parseDate } from '../utils/parseDate' ;
67
78const SHIFT_CODES_URL = 'https://shift.orcicorn.com/shift-code/index.json' ;
89
9- function parseDate ( str : string ) {
10- const date = new Date ( str ) ;
11- if ( isNaN ( date . valueOf ( ) ) ) return undefined ;
12- return date ;
13- }
14-
1510export async function * getOrcicornShiftCodes ( ) : AsyncGenerator < ShiftCode > {
1611 const response = await fetch ( SHIFT_CODES_URL ) ;
1712
Original file line number Diff line number Diff line change 1+ export function parseDate ( str : string ) {
2+ const date = new Date ( str ) ;
3+ if ( isNaN ( date . valueOf ( ) ) ) return undefined ;
4+ return date ;
5+ }
You can’t perform that action at this time.
0 commit comments