parent
8eb5f6d438
commit
a76ae4606e
@ -0,0 +1,29 @@ |
|||||||
|
// Next.js API route support: https://nextjs.org/docs/api-routes/introduction
|
||||||
|
import type { NextApiRequest, NextApiResponse } from 'next' |
||||||
|
import Select from "../../../../server/db/select"; |
||||||
|
import Insert from "../../../../server/db/insert"; |
||||||
|
import { getRssXml, Items } from '../../../../сomponents/podcasts'; |
||||||
|
|
||||||
|
const id = 4; |
||||||
|
|
||||||
|
const sql_company = "SELECT * FROM podcasts, company WHERE podcasts.id="+id; |
||||||
|
const sql_items = "SELECT * FROM `podcasts`, items, company WHERE podcasts.id=items.id_podcasts ORDER BY items.pubDate DESC"; |
||||||
|
|
||||||
|
const sql_userAgent = "INSERT INTO views (id_podcasts, userAgent,ip) VALUES (?,?,?)"; |
||||||
|
|
||||||
|
export default function handler( |
||||||
|
req: NextApiRequest, |
||||||
|
res: NextApiResponse |
||||||
|
) { |
||||||
|
const views = [id, req.headers['user-agent'], req.socket.remoteAddress] |
||||||
|
Select(sql_company, function(data_company : any){ |
||||||
|
Select(sql_items, function(data_items : any){ |
||||||
|
res.setHeader('Content-Type', 'text/xml'); |
||||||
|
res.status(200).send(getRssXml(data_company[0])+data_items.map((rows : any) => Items(rows))+'</channel> </rss>'); |
||||||
|
}) |
||||||
|
|
||||||
|
}) |
||||||
|
Insert(sql_userAgent, views as string[], function(message){ |
||||||
|
console.log(message); |
||||||
|
}) |
||||||
|
}
|
Loading…
Reference in new issue