mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
* refactor(backend): types for global config I saw merge conflicts in these files for #8463 so let's get some parts of this PR into `master` already. I believe this fixes a small bug. They guard clause didn't ensure that all of REDIS_ configurations were set. * remove old email mechanism * refactor(backend: react to @ulfgebhardt's review See: https://github.com/Ocelot-Social-Community/Ocelot-Social/pull/8485#pullrequestreview-2813528327 * build(backend): optional commit @ulfgebhardt this is how I tested the configurations. We don't need to include this commit but I wouldn't expect to send out real emails from a `docker-compose` setup. --------- Co-authored-by: Moriz Wahl <moriz.wahl@gmx.de>
33 lines
900 B
TypeScript
33 lines
900 B
TypeScript
/* eslint-disable import/no-named-as-default-member */
|
|
import neo4j, { Driver } from 'neo4j-driver'
|
|
import Neode from 'neode'
|
|
|
|
import CONFIG from '@config/index'
|
|
import models from '@db/models/index'
|
|
|
|
let driver: Driver
|
|
const defaultOptions = {
|
|
uri: CONFIG.NEO4J_URI,
|
|
username: CONFIG.NEO4J_USERNAME,
|
|
password: CONFIG.NEO4J_PASSWORD,
|
|
}
|
|
|
|
export function getDriver(options = {}) {
|
|
const { uri, username, password } = { ...defaultOptions, ...options }
|
|
if (!driver) {
|
|
driver = neo4j.driver(uri, neo4j.auth.basic(username, password))
|
|
}
|
|
return driver
|
|
}
|
|
|
|
let neodeInstance: Neode
|
|
export function getNeode(options = {}) {
|
|
if (!neodeInstance) {
|
|
const { uri, username, password } = { ...defaultOptions, ...options }
|
|
neodeInstance = new Neode(uri, username, password).with(models)
|
|
neodeInstance.extend('Post', 'Article', {})
|
|
return neodeInstance
|
|
}
|
|
return neodeInstance
|
|
}
|