-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
464efaa
commit e43a72a
Showing
6 changed files
with
82 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,51 @@ | ||
export const complexlity = () => { | ||
console.log("Here we gooo!!"); | ||
}; | ||
import { services, TService, Service } from "./services"; | ||
|
||
|
||
class uniFarcasterSdk { | ||
private hubUrl: string = "DEFAULT_HUB_URL"; | ||
private neynarApiKey: string | undefined; | ||
private airstackApiKey: string | undefined; | ||
private activeService: Service = services.hub; | ||
|
||
constructor(config: { | ||
hubUrl?: string; | ||
neynarApiKey?: string; | ||
airstackApiKey?: string; | ||
activeService?: TService; | ||
}) { | ||
this.hubUrl = config.hubUrl ?? "DEFAULT_HUB_URL"; | ||
this.neynarApiKey = config.neynarApiKey; | ||
this.airstackApiKey = config.airstackApiKey; | ||
this.activeService = this.getActiveService(config.activeService); | ||
} | ||
|
||
//TODO: Make more composable | ||
private getActiveService(service?: TService): Service { | ||
if (service === "neynar" && this.neynarApiKey) { | ||
return services.neynar; | ||
} else if (service === "airstack" && this.airstackApiKey) { | ||
return services.airstack; | ||
} else { | ||
return services.hub; | ||
} | ||
} | ||
|
||
public getUserByFid(fid: number, viewerFid: number): User { | ||
Check failure on line 33 in src/index.ts GitHub Actions / build
|
||
return this.activeService.getUserByFid(fid, viewerFid); | ||
} | ||
|
||
public getUserByUsername(username: string, viewerFid: number): User { | ||
Check failure on line 37 in src/index.ts GitHub Actions / build
|
||
return this.activeService.getUserByUsername(username, viewerFid); | ||
} | ||
|
||
public getCastByHash(hash: string, viewerFid: number): Cast { | ||
Check failure on line 41 in src/index.ts GitHub Actions / build
|
||
return this.activeService.getCastByHash(hash, viewerFid); | ||
} | ||
|
||
public getCastByUrl(url: string, viewerFid: number): Cast { | ||
Check failure on line 45 in src/index.ts GitHub Actions / build
|
||
return this.activeService.getCastByUrl(url, viewerFid); | ||
} | ||
|
||
} | ||
|
||
export default uniFarcasterSdk; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { Service } from "."; | ||
|
||
export const airstackService: Service= { | ||
name: "airstack" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { Service } from "."; | ||
|
||
export const hubService: Service = { | ||
name: "hub" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { neynarService } from "./neynar"; | ||
import { airstackService } from "./airstack"; | ||
import { hubService } from "./hub"; | ||
|
||
|
||
export const services = { | ||
neynar: neynarService, | ||
airstack: airstackService, | ||
hub: hubService | ||
} | ||
|
||
export type Service = {name: string} & any | ||
|
||
|
||
export type TService = keyof typeof services; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { Service } from "."; | ||
|
||
export const neynarService: Service = { | ||
name: "neynar" | ||
} |