First entity: Github repo

This commit is contained in:
askeluv
2019-03-08 12:32:21 +08:00
parent 2c329023c2
commit 1991bd437f
12 changed files with 338 additions and 1 deletions

View File

@@ -0,0 +1,28 @@
import { Connection, ConnectionOptions, createConnection } from 'typeorm';
import { GithubSource } from '../data_sources/github';
import { GithubRepo } from '../entities';
import * as ormConfig from '../ormconfig';
import { parseGithubRepo } from '../parsers/github';
import { handleError } from '../utils';
const GITHUB_OWNER = '0xProject';
const GITHUB_REPO = '0x-monorepo';
let connection: Connection;
(async () => {
connection = await createConnection(ormConfig as ConnectionOptions);
const GithubRepoRepository = connection.getRepository(GithubRepo);
const githubSource = new GithubSource(GITHUB_OWNER, GITHUB_REPO);
// get repo and save
const rawRepo = await githubSource.getGithubRepoAsync();
const observedTimestamp = Date.now();
const record = parseGithubRepo(rawRepo, observedTimestamp);
await GithubRepoRepository.save(record);
// TODO: get pull requests and save
process.exit(0);
})().catch(handleError);