feat: init public notes
This commit is contained in:
@@ -19,6 +19,9 @@
|
||||
<router-link v-if="isLogged" :to="{ name: 'RepoList' }" class="btn"
|
||||
>Manage your repos</router-link
|
||||
>
|
||||
<router-link :to="{ name: 'PublicNoteList' }" class="btn"
|
||||
>Public notes</router-link
|
||||
>
|
||||
</div>
|
||||
|
||||
<form class="github-form" @submit.prevent>
|
||||
|
||||
28
src/main.ts
28
src/main.ts
@@ -1,18 +1,24 @@
|
||||
import 'notyf/notyf.min.css'
|
||||
import './styles/app.css'
|
||||
import "notyf/notyf.min.css"
|
||||
import "./styles/app.css"
|
||||
|
||||
import { createPinia } from 'pinia'
|
||||
import { createApp } from 'vue'
|
||||
import { createI18n } from 'vue-i18n'
|
||||
import { createPinia } from "pinia"
|
||||
import { createApp } from "vue"
|
||||
import { createI18n } from "vue-i18n"
|
||||
|
||||
import { messages } from '@/locales/message'
|
||||
import { router } from '@/router/router'
|
||||
import { messages } from "@/locales/message"
|
||||
import { router } from "@/router/router"
|
||||
import { VueQueryPlugin } from "@tanstack/vue-query"
|
||||
|
||||
import App from './App.vue'
|
||||
import App from "./App.vue"
|
||||
|
||||
const i18n = createI18n({
|
||||
locale: 'en',
|
||||
messages
|
||||
locale: "en",
|
||||
messages,
|
||||
})
|
||||
|
||||
createApp(App).use(router).use(i18n).use(createPinia()).mount('#app')
|
||||
createApp(App)
|
||||
.use(router)
|
||||
.use(VueQueryPlugin)
|
||||
.use(i18n)
|
||||
.use(createPinia())
|
||||
.mount("#app")
|
||||
|
||||
64
src/modules/post/data/client.ts
Normal file
64
src/modules/post/data/client.ts
Normal file
@@ -0,0 +1,64 @@
|
||||
import { initContract } from "@ts-rest/core"
|
||||
import { type } from "arktype"
|
||||
import { initQueryClient } from "@ts-rest/vue-query"
|
||||
|
||||
const PublicNoteListItem = type({
|
||||
did: "string",
|
||||
rkey: "string",
|
||||
title: "string",
|
||||
publishedAt: "string",
|
||||
createdAt: "string",
|
||||
})
|
||||
|
||||
export type PublicNoteListItem = typeof PublicNoteListItem.infer
|
||||
|
||||
const PublicNote = type({
|
||||
did: "string",
|
||||
rkey: "string",
|
||||
title: "string",
|
||||
content: "string",
|
||||
publishedAt: "string",
|
||||
createdAt: "string",
|
||||
})
|
||||
|
||||
export type PublicNote = typeof PublicNote.infer
|
||||
|
||||
const contract = initContract()
|
||||
|
||||
export const noteRouter = contract.router({
|
||||
noteLists: {
|
||||
method: "GET",
|
||||
path: "/notes",
|
||||
query: type({
|
||||
cursor: "string | undefined",
|
||||
limit: "number | undefined",
|
||||
}),
|
||||
responses: {
|
||||
200: type({
|
||||
notes: PublicNoteListItem.array(),
|
||||
}),
|
||||
},
|
||||
summary: "List all notes",
|
||||
},
|
||||
noteListsByDid: {
|
||||
method: "GET",
|
||||
path: "/:did/notes",
|
||||
pathParams: type({
|
||||
did: "string",
|
||||
}),
|
||||
query: type({
|
||||
cursor: "string | undefined",
|
||||
limit: "number | undefined",
|
||||
}),
|
||||
responses: {
|
||||
200: type({
|
||||
notes: PublicNoteListItem.array(),
|
||||
}),
|
||||
},
|
||||
summary: "List all notes",
|
||||
},
|
||||
})
|
||||
|
||||
export const client = initQueryClient(noteRouter, {
|
||||
baseUrl: "https://api.litenote.li212.fr",
|
||||
})
|
||||
@@ -8,6 +8,11 @@ const routes: Array<RouteRecordRaw> = [
|
||||
name: "RepoList",
|
||||
component: () => import("@/views/RepoList.vue"),
|
||||
},
|
||||
{
|
||||
path: "/notes",
|
||||
name: "PublicNoteList",
|
||||
component: () => import("@/views/PublicNoteList.vue"),
|
||||
},
|
||||
{
|
||||
path: "/:user/:repo",
|
||||
name: "FluxNoteView",
|
||||
|
||||
18
src/views/PublicNoteList.vue
Normal file
18
src/views/PublicNoteList.vue
Normal file
@@ -0,0 +1,18 @@
|
||||
<script setup lang="ts">
|
||||
import { noteRouter } from "@/modules/post/data/client"
|
||||
|
||||
const { data: notes, isLoading } = noteRouter.noteLists.get.useQuery(["notes"])
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="public-note-view" v-if="isLoading">
|
||||
<ul>
|
||||
<li v-for="note in notes">{{ note.did }} / {{ note.rkey }}</li>
|
||||
</ul>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.public-note-view {
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user