-
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.
feat: update api version and implementation (#80)
- Loading branch information
Showing
14 changed files
with
170 additions
and
89 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { NextRequest, NextResponse } from 'next/server' | ||
import logger from '@/lib/api-client-config/logger' | ||
import { handleApiError } from '@/lib/api-client-config/errors/handler' | ||
import { getProductsApi } from '@/lib/api-client-config/api-client-factory' | ||
|
||
export async function GET( | ||
_request: NextRequest, | ||
{ params }: { params: Promise<{ id: string }> } | ||
) { | ||
try { | ||
const id = (await params).id | ||
|
||
logger.info(`Starting GET request to /api/products/${id}`) | ||
const productsApi = getProductsApi() | ||
|
||
const product = await productsApi.getProduct({ | ||
id | ||
}) | ||
|
||
logger.debug({ product }, 'Product retrieved successfully') | ||
return NextResponse.json(product) | ||
} catch (error) { | ||
return handleApiError(error) | ||
} | ||
} |
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,25 @@ | ||
import { NextRequest, NextResponse } from 'next/server' | ||
import logger from '@/lib/api-client-config/logger' | ||
import { handleApiError } from '@/lib/api-client-config/errors/handler' | ||
import { getUsersApi } from '@/lib/api-client-config/api-client-factory' | ||
|
||
export async function GET( | ||
_request: NextRequest, | ||
{ params }: { params: Promise<{ id: string }> } | ||
) { | ||
try { | ||
const id = (await params).id | ||
|
||
logger.info(`Starting GET request to /api/users/${id}`) | ||
const usersApi = getUsersApi() | ||
|
||
const user = await usersApi.getUser({ | ||
id | ||
}) | ||
|
||
logger.debug({ user }, 'User retrieved successfully') | ||
return NextResponse.json(user) | ||
} catch (error) { | ||
return handleApiError(error) | ||
} | ||
} |
Oops, something went wrong.