chore: eventing + refactoring
This commit is contained in:
parent
20184d767e
commit
4b7e3f7ee5
2 changed files with 9 additions and 4 deletions
11
api/event.js
11
api/event.js
|
@ -8,11 +8,16 @@ export default async (request, context) => {
|
||||||
const num = params.get('num') || 'unknown'
|
const num = params.get('num') || 'unknown'
|
||||||
const lang = decodeURIComponent(params.get('lang'))
|
const lang = decodeURIComponent(params.get('lang'))
|
||||||
const nav = decodeURIComponent(params.get('nav'))
|
const nav = decodeURIComponent(params.get('nav'))
|
||||||
|
const notLang = !lang || lang === 'null' || lang === 'undefined'
|
||||||
|
const notNav = !nav || nav === 'null' || nav === 'undefined'
|
||||||
const ig = params.get('ig')
|
const ig = params.get('ig')
|
||||||
const setUrl = (id, event) => `https://cdn.usefathom.com/?h=${encodeURIComponent(page)}&sid=CWSVCDJC&cid=${id}&name=${encodeURIComponent(event)}`
|
const setUrl = (id, event) => `https://cdn.usefathom.com/?h=${encodeURIComponent(page)}&sid=CWSVCDJC&cid=${id}&name=${encodeURIComponent(event)}`
|
||||||
const headers = {}
|
const acceptLanguage = notLang ? request['headers'].get('accept-language') : lang
|
||||||
if (lang) headers['Accept-Language'] = lang
|
const userAgent = notNav ? request['headers'].get('user-agent') : nav
|
||||||
if (nav) headers['User-Agent'] = nav
|
const headers = {
|
||||||
|
'Accept-Language': acceptLanguage,
|
||||||
|
'User-Agent': userAgent
|
||||||
|
}
|
||||||
let url
|
let url
|
||||||
|
|
||||||
if (ig) return
|
if (ig) return
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "coryd.dev",
|
"name": "coryd.dev",
|
||||||
"version": "8.7.2",
|
"version": "8.7.3",
|
||||||
"description": "The source for my personal site. Built using 11ty.",
|
"description": "The source for my personal site. Built using 11ty.",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|
Reference in a new issue