-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev' into feature/project-page
- Loading branch information
Showing
61 changed files
with
1,527 additions
and
940 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { Client } from '@notionhq/client'; | ||
import { NextRequest } from 'next/server'; | ||
|
||
const notion = new Client({ | ||
auth: process.env.NOTION_SECRET_KEY, | ||
}); | ||
|
||
// seminar 데이터 query select, 오름차순 | ||
async function queryAllSeminarData(databaseId: string): Promise<any[]> { | ||
try { | ||
const response = await notion.databases.query({ | ||
database_id: databaseId, | ||
sorts: [ | ||
{ | ||
property: 'Date', | ||
direction: 'ascending' | ||
} | ||
] | ||
}); | ||
|
||
return response.results; | ||
} catch (error) { | ||
console.error('Error querying Notion database and fetching member data:', JSON.stringify(error)); | ||
throw error; | ||
} | ||
} | ||
|
||
type Data = { | ||
items?: any[]; | ||
message: string; | ||
}; | ||
|
||
export async function GET(req: NextRequest) { | ||
const databaseId = process.env.NOTION_SEMINAR_DATABASE_ID || ''; | ||
|
||
try { | ||
const data = await queryAllSeminarData(databaseId); | ||
return new Response(JSON.stringify({ data, message: 'Success' }), { | ||
status: 200, | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
}); | ||
} catch (error) { | ||
return new Response(JSON.stringify({ message: `Failed: ${error?.toString()}` }), { | ||
status: 500, | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
}); | ||
} | ||
} |
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,48 @@ | ||
import { Client } from '@notionhq/client'; | ||
import { NotionToMarkdown } from "notion-to-md"; | ||
import { NextRequest } from 'next/server'; | ||
|
||
const notion = new Client({ | ||
auth: process.env.NOTION_SECRET_KEY, | ||
}); | ||
|
||
const n2m = new NotionToMarkdown({ notionClient: notion }); | ||
|
||
async function getPageMarkdown(pageId: string): Promise<any> { | ||
const mdblocks = await n2m.pageToMarkdown(pageId); | ||
const mdString = n2m.toMarkdownString(mdblocks); | ||
return mdString; | ||
} | ||
|
||
|
||
// Next.js의 API 라우트 핸들러 | ||
export async function GET(req: NextRequest) { | ||
const url = new URL(req.url); | ||
const pageId = url.searchParams.get('pageId'); | ||
|
||
if (!pageId) { | ||
return new Response(JSON.stringify({ message: 'pageId is required' }), { | ||
status: 400, | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
}); | ||
} | ||
|
||
try { | ||
const pageContent = await getPageMarkdown(pageId); | ||
return new Response(JSON.stringify({ data: pageContent, message: 'Success' }), { | ||
status: 200, | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
}); | ||
} catch (error) { | ||
return new Response(JSON.stringify({ message: `Failed: ${error?.toString()}` }), { | ||
status: 500, | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
}); | ||
} | ||
} |
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,51 @@ | ||
import { Client } from '@notionhq/client'; | ||
import { NextRequest } from 'next/server'; | ||
|
||
const notion = new Client({ | ||
auth: process.env.NOTION_SECRET_KEY, | ||
}); | ||
|
||
async function queryOpenSeminarData(databaseId: string): Promise<any[]> { | ||
try { | ||
const response = await notion.databases.query({ | ||
database_id: databaseId, | ||
sorts: [ | ||
{ | ||
property: 'Date', | ||
direction: 'ascending' | ||
} | ||
] | ||
}); | ||
|
||
return response.results; | ||
} catch (error) { | ||
console.error('Error querying Notion database and fetching seminar data:', JSON.stringify(error)); | ||
throw error; | ||
} | ||
} | ||
|
||
type Data = { | ||
items?: any[]; | ||
message: string; | ||
}; | ||
|
||
export async function GET(req: NextRequest) { | ||
const databaseId = process.env.NOTION_OPEN_SEMINAR_DATABASE_ID || ''; | ||
|
||
try { | ||
const data = await queryOpenSeminarData(databaseId); | ||
return new Response(JSON.stringify({ data, message: 'Success' }), { | ||
status: 200, | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
}); | ||
} catch (error) { | ||
return new Response(JSON.stringify({ message: `Failed: ${error?.toString()}` }), { | ||
status: 500, | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
}); | ||
} | ||
} |
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,59 @@ | ||
import { Client } from '@notionhq/client'; | ||
import { NextRequest } from 'next/server'; | ||
|
||
const notion = new Client({ | ||
auth: process.env.NOTION_SECRET_KEY, | ||
}); | ||
|
||
// seminar id와 연결된 리뷰 불러오기 | ||
async function queryReviewData(databaseId: string, seminarId: string): Promise<any[]> { | ||
try { | ||
const response = await notion.databases.query({ | ||
database_id: databaseId, | ||
filter: { | ||
property: 'Seminar', | ||
relation: { | ||
contains: seminarId | ||
} | ||
} | ||
}); | ||
|
||
return response.results; | ||
} catch (error) { | ||
console.error('Error querying Notion database by Seminar ID:', error); | ||
throw error; | ||
} | ||
} | ||
|
||
export async function GET(req: NextRequest) { | ||
const url = new URL(req.url); | ||
const seminarId = url.searchParams.get('seminarId'); // 쿼리 파라미터에서 세미나 ID 가져오기 | ||
|
||
if (!seminarId) { | ||
return new Response(JSON.stringify({ message: 'Seminar ID is required' }), { | ||
status: 400, | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
}); | ||
} | ||
|
||
const databaseId = process.env.NOTION_REVIEW_DATABASE_ID || ''; // 리뷰 데이터베이스 ID | ||
|
||
try { | ||
const reviews = await queryReviewData(databaseId, seminarId); | ||
return new Response(JSON.stringify({ reviews, message: 'Success' }), { | ||
status: 200, | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
}); | ||
} catch (error) { | ||
return new Response(JSON.stringify({ message: `Failed: ${error?.toString()}` }), { | ||
status: 500, | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
}); | ||
} | ||
} |
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,70 @@ | ||
import { Client } from '@notionhq/client'; | ||
import { NextRequest } from 'next/server'; | ||
|
||
const notion = new Client({ | ||
auth: process.env.NOTION_SECRET_KEY, | ||
}); | ||
|
||
// seminar 데이터 query select, 오름차순 | ||
async function querySeminarData(databaseId: string, tag: string): Promise<any[]> { | ||
try { | ||
const response = await notion.databases.query({ | ||
database_id: databaseId, | ||
filter: { | ||
property: 'Tags', | ||
multi_select: { | ||
contains: tag | ||
} | ||
}, | ||
sorts: [ | ||
{ | ||
property: 'Date', | ||
direction: 'ascending' | ||
} | ||
] | ||
}); | ||
|
||
return response.results; | ||
} catch (error) { | ||
console.error('Error querying Notion database and fetching member data:', JSON.stringify(error)); | ||
throw error; | ||
} | ||
} | ||
|
||
type Data = { | ||
items?: any[]; | ||
message: string; | ||
}; | ||
|
||
export async function GET(req: NextRequest) { | ||
const url = new URL(req.url); | ||
const tag = url.searchParams.get('Tag'); // 쿼리 파라미터에서 세미나 ID 가져오기 | ||
|
||
if (!tag) { | ||
return new Response(JSON.stringify({ message: 'Tag is required' }), { | ||
status: 400, | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
}); | ||
} | ||
|
||
const databaseId = process.env.NOTION_SEMINAR_DATABASE_ID || ''; | ||
|
||
try { | ||
const data = await querySeminarData(databaseId, tag); | ||
return new Response(JSON.stringify({ data, message: 'Success' }), { | ||
status: 200, | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
}); | ||
} catch (error) { | ||
return new Response(JSON.stringify({ message: `Failed: ${error?.toString()}` }), { | ||
status: 500, | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
}); | ||
} | ||
} |
Oops, something went wrong.