mirror of
https://git.sr.ht/~cadence/cloudtube
synced 2026-05-26 12:32:25 +00:00
Add database and subscribe button
This commit is contained in:
parent
2af05e43a9
commit
f24e1bb39c
25 changed files with 972 additions and 44 deletions
|
|
@ -1,12 +1,16 @@
|
|||
const fetch = require("node-fetch")
|
||||
const {render} = require("pinski/plugins")
|
||||
const constants = require("./utils/constants")
|
||||
const {fetchChannel} = require("./utils/youtube")
|
||||
const {getUser} = require("./utils/getuser")
|
||||
|
||||
module.exports = [
|
||||
{
|
||||
route: "/channel/([A-Za-z0-9-_]+)", methods: ["GET"], code: async ({fill}) => {
|
||||
route: `/channel/(${constants.regex.ucid})`, methods: ["GET"], code: async ({req, fill}) => {
|
||||
const id = fill[0]
|
||||
const data = await fetch(`http://localhost:3000/api/v1/channels/${id}`).then(res => res.json())
|
||||
return render(200, "pug/channel.pug", {data})
|
||||
const data = await fetchChannel(id)
|
||||
const user = getUser(req)
|
||||
const subscribed = user.isSubscribed(id)
|
||||
return render(200, "pug/channel.pug", {data, subscribed})
|
||||
}
|
||||
}
|
||||
]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue