-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: antondlr <[email protected]>
- Loading branch information
1 parent
2e2e4c3
commit 9a6011b
Showing
246 changed files
with
13,024 additions
and
3,853 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
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
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,34 @@ | ||
import fetchFromApi from '../../utilities/fetchFromApi' | ||
|
||
const backendUrl = process.env.BACKEND_URL | ||
|
||
export interface fetchActivitiesProps { | ||
token: string | ||
offset?: string | ||
limit?: string | ||
order?: string | ||
since?: string | ||
} | ||
|
||
export const fetchActivities = async (props: fetchActivitiesProps) => { | ||
const { token, offset, limit, order, since } = props | ||
const params = new URLSearchParams() | ||
|
||
if (offset) params.append('offset', offset) | ||
if (limit) params.append('limit', limit) | ||
if (order) params.append('order', order) | ||
if (since) params.append('since', since) | ||
|
||
return await fetchFromApi(`${backendUrl}/activity?${params.toString()}`, token) | ||
} | ||
|
||
export const logActivity = async (data: any, token: string) => | ||
await fetchFromApi(`${backendUrl}/activity`, token, { | ||
method: 'POST', | ||
body: JSON.stringify(data), | ||
}) | ||
|
||
export const readActivity = async (id: string, token: string) => | ||
await fetchFromApi(`${backendUrl}/activity/${id}/read`, token, { | ||
method: 'PUT', | ||
}) |
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,19 @@ | ||
import { NextResponse } from 'next/server' | ||
import getReqAuthToken from '../../../utilities/getReqAuthToken' | ||
import { fetchActivities } from '../activities' | ||
|
||
export async function GET(req: Request) { | ||
try { | ||
const { searchParams } = new URL(req.url) | ||
const offset = searchParams.get('offset') || undefined | ||
const limit = searchParams.get('limit') || undefined | ||
const order = searchParams.get('order') || undefined | ||
const since = searchParams.get('since') || undefined | ||
|
||
const token = getReqAuthToken(req) | ||
const data = await fetchActivities({ token, offset, limit, order, since }) | ||
return NextResponse.json(data) | ||
} catch (error) { | ||
return NextResponse.json({ error: 'Failed to fetch activities' }, { status: 500 }) | ||
} | ||
} |
Oops, something went wrong.