Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: ✨ CWL validations across repo, single instance db, bot restructering, updated CWL github issue template #42

Merged
merged 17 commits into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions bot/db.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { MongoClient } from "mongodb";
const MONGODB_URI = process.env.MONGODB_URI;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion (code-quality): Prefer object destructuring when accessing and using properties. (use-object-destructuring)

Suggested change
const MONGODB_URI = process.env.MONGODB_URI;
const {MONGODB_URI} = process.env;


ExplanationObject destructuring can often remove an unnecessary temporary reference, as well as making your code more succinct.

From the Airbnb Javascript Style Guide

const MONGODB_DB_NAME = process.env.MONGODB_DB_NAME;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion (code-quality): Prefer object destructuring when accessing and using properties. (use-object-destructuring)

Suggested change
const MONGODB_DB_NAME = process.env.MONGODB_DB_NAME;
const {MONGODB_DB_NAME} = process.env;


ExplanationObject destructuring can often remove an unnecessary temporary reference, as well as making your code more succinct.

From the Airbnb Javascript Style Guide


class Database {
constructor() {
if (!Database.instance) {
this.client = new MongoClient(MONGODB_URI, {});
Database.instance = this;
}

return Database.instance;
}

async connect() {
if (!this.db) {
await this.client.connect();
this.db = this.client.db(MONGODB_DB_NAME);
}

return this.db;
}

getDb() {
return this.db;
}
}

const instance = new Database();

export default instance;
Loading