forked from umami-software/umami
-
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
Showing
14 changed files
with
142 additions
and
73 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { parse } from 'cookie'; | ||
import { verifySecureToken } from './crypto'; | ||
|
||
export default async req => { | ||
const token = parse(req.headers.cookie)['umami.auth']; | ||
|
||
return verifySecureToken(token); | ||
}; |
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,11 @@ | ||
import moment from 'moment-timezone'; | ||
import { addMinutes } from 'date-fns'; | ||
|
||
export function getTimezone() { | ||
const tz = moment.tz.guess(); | ||
return moment.tz.zone(tz).abbr(new Date().getTimezoneOffset()); | ||
} | ||
|
||
export function getLocalTime(t) { | ||
return addMinutes(new Date(t), new Date().getTimezoneOffset()); | ||
} |
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
File renamed without changes.
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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { getWebsites } from 'lib/db'; | ||
import { useAuth } from 'lib/middleware'; | ||
|
||
export default async (req, res) => { | ||
await useAuth(req, res); | ||
|
||
const { user_id } = req.auth; | ||
|
||
const websites = await getWebsites(user_id); | ||
|
||
res.status(200).json({ websites }); | ||
}; |
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 |
---|---|---|
@@ -1,10 +1,15 @@ | ||
import { getPageviews } from 'lib/db'; | ||
import { getPageviewData } from 'lib/db'; | ||
import { useAuth } from 'lib/middleware'; | ||
|
||
export default async (req, res) => { | ||
console.log(req.query); | ||
const { id, start_at, end_at } = req.query; | ||
await useAuth(req, res); | ||
|
||
const pageviews = await getPageviews(+id, new Date(+start_at), new Date(+end_at)); | ||
const { id, start_at, end_at, tz } = req.query; | ||
|
||
res.status(200).json({ pageviews }); | ||
const [pageviews, uniques] = await Promise.all([ | ||
getPageviewData(+id, new Date(+start_at), new Date(+end_at), tz, 'day', '*'), | ||
getPageviewData(+id, new Date(+start_at), new Date(+end_at), tz, 'day', 'distinct session_id'), | ||
]); | ||
|
||
res.status(200).json({ pageviews, uniques }); | ||
}; |
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,13 @@ | ||
import { getPageviews } from 'lib/db'; | ||
import { useAuth } from 'lib/middleware'; | ||
|
||
export default async (req, res) => { | ||
await useAuth(req, res); | ||
|
||
console.log(req.query); | ||
const { id, start_at, end_at } = req.query; | ||
|
||
const pageviews = await getPageviews(+id, new Date(+start_at), new Date(+end_at)); | ||
|
||
res.status(200).json({ pageviews }); | ||
}; |
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