-
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.
Merge pull request #368 from vishnoianil/fix-contribute
Fix skill and knowledge contribution for nextjs refactoring
- Loading branch information
Showing
14 changed files
with
511 additions
and
510 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -18,8 +18,8 @@ export const authOptions: NextAuthOptions = { | |
}, | ||
authorize: async (credentials) => { | ||
if ( | ||
credentials?.username === (process.env.NEXT_PUBLIC_IL_UI_ADMIN_USERNAME || 'admin') && | ||
credentials?.password === (process.env.NEXT_PUBLIC_IL_UI_ADMIN_PASSWORD || 'password') | ||
credentials?.username === (process.env.IL_UI_ADMIN_USERNAME || 'admin') && | ||
credentials?.password === (process.env.IL_UI_ADMIN_PASSWORD || 'password') | ||
) { | ||
return { id: '1', name: 'Admin', email: '[email protected]' }; | ||
} | ||
|
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,38 +1,40 @@ | ||
// pages/api/pr/knowledge.ts | ||
import type { NextApiRequest, NextApiResponse } from 'next'; | ||
// src/app/api/pr/knowledge/route.ts | ||
|
||
import { NextResponse } from 'next/server'; | ||
|
||
const API_SERVER_URL = process.env.IL_UI_API_SERVER_URL || 'http://localhost:3000'; | ||
const USERNAME = process.env.IL_UI_API_SERVER_USERNAME || 'kitteh'; | ||
const PASSWORD = process.env.IL_UI_API_SERVER_PASSWORD || 'floofykittens'; | ||
|
||
export default async function handler(req: NextApiRequest, res: NextApiResponse) { | ||
if (req.method === 'POST') { | ||
const auth = Buffer.from(`${USERNAME}:${PASSWORD}`).toString('base64'); | ||
const headers = { | ||
'Content-Type': 'application/json', | ||
Authorization: 'Basic ' + auth, | ||
}; | ||
|
||
try { | ||
const apiRes = await fetch(`${API_SERVER_URL}pr/knowledge`, { | ||
method: 'POST', | ||
headers, | ||
body: JSON.stringify(req.body), | ||
}); | ||
|
||
if (!apiRes.ok) { | ||
const errorResult = await apiRes.json(); | ||
throw new Error(`HTTP error! status: ${apiRes.status} - ${errorResult.error}`); | ||
} | ||
|
||
const result = await apiRes.json(); | ||
res.status(201).json(result); | ||
} catch (error) { | ||
console.error('Failed to post Knowledge PR:', error); | ||
res.status(500).json({ error: 'Failed to post Knowledge PR' }); | ||
export async function POST(req: Request) { | ||
console.log(`Received request: ${req.method} ${req.url} ${req.body}}`); | ||
|
||
const auth = Buffer.from(`${USERNAME}:${PASSWORD}`).toString('base64'); | ||
const headers = { | ||
'Content-Type': 'application/json', | ||
Authorization: 'Basic ' + auth, | ||
}; | ||
|
||
try { | ||
const body = await req.json(); | ||
const response = await fetch(`${API_SERVER_URL}/pr/knowledge`, { | ||
method: 'POST', | ||
headers, | ||
body: JSON.stringify(body), | ||
}); | ||
|
||
if (response.status !== 201) { | ||
throw new Error(`HTTP error! status: ${response.status}`); | ||
} | ||
} else { | ||
res.setHeader('Allow', ['POST']); | ||
res.status(405).end(`Method ${req.method} Not Allowed`); | ||
|
||
const result = await response.json(); | ||
return NextResponse.json(result, { status: 201 }); | ||
} catch (error) { | ||
console.error('Failed to post knowledge data:', error); | ||
return NextResponse.json({ error: 'Failed to post knowledge data' }, { status: 500 }); | ||
} | ||
} | ||
|
||
export const methods = { | ||
POST, | ||
}; |
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,38 +1,40 @@ | ||
// pages/api/pr/skill.ts | ||
import type { NextApiRequest, NextApiResponse } from 'next'; | ||
// src/app/api/pr/skill/route.ts | ||
|
||
import { NextResponse } from 'next/server'; | ||
|
||
const API_SERVER_URL = process.env.IL_UI_API_SERVER_URL || 'http://localhost:3000'; | ||
const USERNAME = process.env.IL_UI_API_SERVER_USERNAME || 'kitteh'; | ||
const PASSWORD = process.env.IL_UI_API_SERVER_PASSWORD || 'floofykittens'; | ||
|
||
export default async function handler(req: NextApiRequest, res: NextApiResponse) { | ||
if (req.method === 'POST') { | ||
const auth = Buffer.from(`${USERNAME}:${PASSWORD}`).toString('base64'); | ||
const headers = { | ||
'Content-Type': 'application/json', | ||
Authorization: 'Basic ' + auth, | ||
}; | ||
|
||
try { | ||
const apiRes = await fetch(`${API_SERVER_URL}pr/skill`, { | ||
method: 'POST', | ||
headers, | ||
body: JSON.stringify(req.body), | ||
}); | ||
|
||
if (!apiRes.ok) { | ||
const errorResult = await apiRes.json(); | ||
throw new Error(`HTTP error! status: ${apiRes.status} - ${errorResult.error}`); | ||
} | ||
|
||
const result = await apiRes.json(); | ||
res.status(201).json(result); | ||
} catch (error) { | ||
console.error('Failed to post Skill PR:', error); | ||
res.status(500).json({ error: 'Failed to post Skill PR' }); | ||
export async function POST(req: Request) { | ||
console.log(`Received request: ${req.method} ${req.url} ${req.body}}`); | ||
|
||
const auth = Buffer.from(`${USERNAME}:${PASSWORD}`).toString('base64'); | ||
const headers = { | ||
'Content-Type': 'application/json', | ||
Authorization: 'Basic ' + auth, | ||
}; | ||
|
||
try { | ||
const body = await req.json(); | ||
const response = await fetch(`${API_SERVER_URL}/pr/skill`, { | ||
method: 'POST', | ||
headers, | ||
body: JSON.stringify(body), | ||
}); | ||
|
||
if (response.status !== 201) { | ||
throw new Error(`HTTP error! status: ${response.status}`); | ||
} | ||
} else { | ||
res.setHeader('Allow', ['POST']); | ||
res.status(405).end(`Method ${req.method} Not Allowed`); | ||
|
||
const result = await response.json(); | ||
return NextResponse.json(result, { status: 201 }); | ||
} catch (error) { | ||
console.error('Failed to post skill data:', error); | ||
return NextResponse.json({ error: 'Failed to post skill data' }, { status: 500 }); | ||
} | ||
} | ||
|
||
export const methods = { | ||
POST, | ||
}; |
Oops, something went wrong.