This repository has been archived by the owner on Apr 13, 2024. It is now read-only.
-
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
f7121c9
commit f58beb8
Showing
8 changed files
with
106 additions
and
9 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
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
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 |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
email: "", | ||
password: "" | ||
}) | ||
const loginInfo = ref({ | ||
identifier: "", | ||
password: "" | ||
|
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,45 @@ | ||
<script setup lang="ts"> | ||
import { PublicUser } from '~/constants/types/User.types' | ||
const route = useRoute(); | ||
const { data: result } = await useFetch(`/api/v1/profile?username=${route.params.slug}`); | ||
if (!result.value) throw createError({ statusCode: 404, statusMessage: 'User not found.' }); | ||
const user = PublicUser.parse(result.value); | ||
useSeoMeta({ | ||
// Standard | ||
title: user.profile.displayname ?? user.username, | ||
description: '', | ||
// OpenGraph | ||
ogTitle: user.profile.displayname ?? user.username, | ||
ogDescription: '', | ||
ogImage: user.avatar ?? 'https://leafal.io/default.svg', | ||
ogUrl: `https://www.leafal.io${route.fullPath}`, | ||
twitterTitle: user.profile.displayname ?? user.username, | ||
twitterDescription: '', | ||
twitterImage: user.avatar ?? 'https://leafal.io/default.svg', | ||
twitterCard: 'summary' | ||
}) | ||
</script> | ||
|
||
<template> | ||
<main> | ||
<div class="user"> | ||
<h1>{{ user.profile.displayname ?? user.username }}</h1> | ||
</div> | ||
</main> | ||
</template> | ||
|
||
<style scoped lang="scss"> | ||
.user { | ||
margin: 2rem auto; | ||
position: relative; | ||
z-index: 5; | ||
max-width: 90vw; | ||
} | ||
</style> |
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,24 @@ | ||
import { PublicUser } from '~/constants/types/User.types'; | ||
import { connectDatabase } from '~/server/functions/database'; | ||
|
||
export default defineEventHandler(async (event) => { | ||
try { | ||
const username = getQuery(event)['username']; | ||
if (!username) throw { message: 'No username provided.' }; | ||
|
||
const database = await connectDatabase(); | ||
const user = await database.query<[PublicUser[]]>( | ||
'SELECT * FROM pubuser WHERE username = $username', | ||
{ username } | ||
); | ||
|
||
if (!user) throw { error: 'User not found', status: 404 }; | ||
|
||
setResponseStatus(event, 200); | ||
return user[0][0]; | ||
} catch (e: unknown) { | ||
const error = e as { error: unknown; status: number }; | ||
setResponseStatus(event, error.status); | ||
return e; | ||
} | ||
}); |
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