Skip to content

Commit

Permalink
API to link public keys
Browse files Browse the repository at this point in the history
  • Loading branch information
boreq committed Oct 16, 2023
1 parent 17e5e23 commit 31a1db2
Show file tree
Hide file tree
Showing 12 changed files with 85 additions and 47 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export class AddPublicKeyRequest {
npub: string;

constructor(npub: string) {
this.npub = npub
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import axios, {AxiosResponse} from 'axios';
import {CurrentUser} from "@/dto/CurrentUser";
import {Mutation} from '@/store';
import {PublicKeys} from "@/dto/PublicKeys";
import {AddPublicKeyRequest} from "@/dto/AddPublicKeyRequest";

export class APIService {

Expand All @@ -20,6 +21,11 @@ export class APIService {
return this.axios.get<PublicKeys>(url);
}

addPublicKey(req: AddPublicKeyRequest): Promise<AxiosResponse<void>> {
const url = `/api/public-keys`;
return this.axios.post<void>(url, req);
}

refreshCurrentUser(): Promise<CurrentUser> {
return new Promise((resolve, reject) => {
this.currentUser()
Expand Down
15 changes: 15 additions & 0 deletions frontend/nos-crossposting-service-frontend/src/views/HomeView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
</div>
</div>

<input placeholder="npub..." v-model="npub">
<button @click="addPublicKey">Link public key</button>

</div>
</template>

Expand All @@ -41,6 +44,7 @@ import {User} from "@/dto/User";
import CurrentUser from "@/components/CurrentUser.vue";
import {APIService} from "@/services/APIService";
import {PublicKeys} from "@/dto/PublicKeys";
import {AddPublicKeyRequest} from "@/dto/AddPublicKeyRequest";
@Options({
Expand All @@ -56,6 +60,7 @@ export default class HomeView extends Vue {
private readonly store = useStore();
publicKeys: PublicKeys | null = null;
npub = "";
get loading(): boolean {
return this.store.state.user === undefined;
Expand All @@ -71,5 +76,15 @@ export default class HomeView extends Vue {
this.publicKeys = response.data;
})
}
addPublicKey(): void {
this.apiService.addPublicKey(new AddPublicKeyRequest(this.npub))
.then(resp => {
console.log("added");
})
.catch(error => {
console.log("error");
})
}
}
</script>
2 changes: 1 addition & 1 deletion service/ports/http/frontend/index.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!doctype html><html lang=""><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="icon" href="/favicon.ico"><title>nos-crossposting-service-frontend</title><script defer="defer" src="/js/chunk-vendors.aa55fb88.js"></script><script defer="defer" src="/js/app.a0bb4349.js"></script><link href="/css/app.ddbde395.css" rel="stylesheet"></head><body><noscript><strong>We're sorry but nos-crossposting-service-frontend doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div></body></html>
<!doctype html><html lang=""><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="icon" href="/favicon.ico"><title>nos-crossposting-service-frontend</title><script defer="defer" src="/js/chunk-vendors.d29f17a5.js"></script><script defer="defer" src="/js/app.efb3f865.js"></script><link href="/css/app.ddbde395.css" rel="stylesheet"></head><body><noscript><strong>We're sorry but nos-crossposting-service-frontend doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div></body></html>
2 changes: 0 additions & 2 deletions service/ports/http/frontend/js/app.a0bb4349.js

This file was deleted.

1 change: 0 additions & 1 deletion service/ports/http/frontend/js/app.a0bb4349.js.map

This file was deleted.

2 changes: 2 additions & 0 deletions service/ports/http/frontend/js/app.efb3f865.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions service/ports/http/frontend/js/app.efb3f865.js.map

Large diffs are not rendered by default.

This file was deleted.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Loading

0 comments on commit 31a1db2

Please sign in to comment.