tangled
alpha
login
or
join now
tsiry-sandratraina.com
/
rocksky-cli
9
fork
atom
🎧 The official command-line interface for Rocksky — a modern, decentralized music tracking and discovery platform built on the AT Protocol.
9
fork
atom
overview
issues
pulls
pipelines
save current user did to file
tsiry-sandratraina.com
11 months ago
1aa661f9
f2e89c99
+15
-2
1 changed file
expand all
collapse all
unified
split
src
client.ts
+15
-2
src/client.ts
···
0
0
0
0
1
export const ROCKSKY_API_URL = "https://api.rocksky.app";
2
3
export class RockskyClient {
···
122
123
async stats(did?: string) {
124
if (!did) {
125
-
const user = await this.getCurrentUser();
126
-
did = user.handle;
0
0
0
0
0
0
0
0
0
127
}
128
129
const response = await fetch(`${ROCKSKY_API_URL}/users/${did}/stats`, {
···
1
+
import fs from "fs";
2
+
import os from "os";
3
+
import path from "path";
4
+
5
export const ROCKSKY_API_URL = "https://api.rocksky.app";
6
7
export class RockskyClient {
···
126
127
async stats(did?: string) {
128
if (!did) {
129
+
const didFile = path.join(os.homedir(), ".rocksky", "did");
130
+
try {
131
+
await fs.promises.access(didFile);
132
+
did = await fs.promises.readFile(didFile, "utf-8");
133
+
} catch (err) {
134
+
const user = await this.getCurrentUser();
135
+
did = user.did;
136
+
const didPath = path.join(os.homedir(), ".rocksky");
137
+
fs.promises.mkdir(didPath, { recursive: true });
138
+
await fs.promises.writeFile(didFile, did);
139
+
}
140
}
141
142
const response = await fetch(`${ROCKSKY_API_URL}/users/${did}/stats`, {