Move modules into collab library as opposed to using the binary

This ensures that we can use collab's modules from the seed script
as well.
This commit is contained in:
Antonio Scandurra 2022-12-02 14:37:26 +01:00
parent 7502558631
commit 1b46b7a7d6
3 changed files with 73 additions and 77 deletions

View file

@ -1,12 +1,8 @@
use collab::{Error, Result};
use db::{DefaultDb, UserId};
use collab::{db, Error, Result};
use db::{ConnectOptions, Database, UserId};
use serde::{de::DeserializeOwned, Deserialize};
use std::fmt::Write;
#[allow(unused)]
#[path = "../db.rs"]
mod db;
#[derive(Debug, Deserialize)]
struct GitHubUser {
id: i32,
@ -17,7 +13,7 @@ struct GitHubUser {
#[tokio::main]
async fn main() {
let database_url = std::env::var("DATABASE_URL").expect("missing DATABASE_URL env var");
let db = DefaultDb::new(&database_url, 5)
let db = Database::new(ConnectOptions::new(database_url))
.await
.expect("failed to connect to postgres database");
let github_token = std::env::var("GITHUB_TOKEN").expect("missing GITHUB_TOKEN env var");