core/pages/servers/[id]/join.tsx
SKINMAKER b421d1ab64
chore: apply prettier (#637)
* chore: apply prettier

* chore: edit ready comment

* chore: move ts comment
2023-11-29 22:04:33 +09:00

20 lines
784 B
TypeScript

import { NextPage, GetServerSideProps } from 'next'
import NotFound from 'pages/404'
import { get } from '@utils/Query'
import { DiscordEnpoints } from '@utils/Constants'
const Join: NextPage = () => <NotFound />
export const getServerSideProps: GetServerSideProps = async (ctx) => {
const data = await get.server.load(ctx.query.id as string)
if (!data) return { props: {} }
// // const record = await Bots.updateOne({ _id: data.id, 'inviteMetrix.day': getYYMMDD() }, { $inc: { 'inviteMetrix.$.count': 1 } })
// if(record.n === 0) await Bots.findByIdAndUpdate(data.id, { $push: { inviteMetrix: { count: 1 } } }, { upsert: true })
ctx.res.statusCode = 307
ctx.res.setHeader('Location', DiscordEnpoints.ServerInvite(data.invite))
return {
props: {},
}
}
export default Join