Skip to content

Commit

Permalink
CORS and github API response (#5)
Browse files Browse the repository at this point in the history
* cors

* return res.data

* update cors list

* update cors list
  • Loading branch information
BlueHorn07 authored Oct 8, 2023
1 parent cf9b93e commit 90cef98
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
20 changes: 12 additions & 8 deletions src/github/github.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,30 @@ export class GithubController {
gh_token = process.env.GITHUB_TOKEN;

@Get()
getOrganizationInfo() {
async getOrganizationInfo() {
const octokit = new Octokit({ auth: this.gh_token });
return octokit.request('GET /orgs/poapper');
const res = await octokit.request('GET /orgs/poapper');
return res.data;
}

@Get('member')
getGithubMembers() {
async getGithubMembers() {
const octokit = new Octokit({ auth: this.gh_token });
return octokit.request('GET /orgs/poapper/public_members');
const res = await octokit.request('GET /orgs/poapper/public_members');
return res.data;
}

@Get('repo')
getGithubRepositories() {
async getGithubRepositories() {
const octokit = new Octokit({ auth: this.gh_token });
return octokit.request('GET /orgs/poapper/repos');
const res = await octokit.request('GET /orgs/poapper/repos');
return res.data;
}

@Get('event')
getGithubEvent() {
async getGithubEvent() {
const octokit = new Octokit({ auth: this.gh_token });
return octokit.request('GET /orgs/poapper/events?per_page=10');
const res = await octokit.request('GET /orgs/poapper/events?per_page=10');
return res.data;
}
}
8 changes: 7 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@ async function bootstrap() {

app.use(cookieParser());
app.enableCors({
origin: ['http://localhost:8000'],
origin: [
'http://localhost:8000',
'http://localhost:9000',
'http://localhost:9001',
'https://poapper.club',
'https://dev.poapper.club',
],
credentials: true,
});

Expand Down

0 comments on commit 90cef98

Please sign in to comment.