make mongodb db name configurable

merge-requests/208/head
some random guy 4 years ago
parent 2adff07989
commit 822d191603
  1. 1
      configs/main.js.example
  2. 2
      db/accounts.js
  3. 2
      db/bans.js
  4. 2
      db/boards.js
  5. 2
      db/bypass.js
  6. 2
      db/captchas.js
  7. 4
      db/db.js
  8. 2
      db/files.js
  9. 2
      db/modlogs.js
  10. 2
      db/news.js
  11. 2
      db/posts.js
  12. 2
      db/ratelimits.js
  13. 2
      db/stats.js
  14. 2
      db/webring.js
  15. 4
      gulpfile.js
  16. 2
      schedules/webring.js

@ -2,6 +2,7 @@ module.exports = {
//mongodb connection string //mongodb connection string
dbURL: 'mongodb://username:password@localhost:27017', dbURL: 'mongodb://username:password@localhost:27017',
dbName: 'jschan',
//redis connection info //redis connection info
redis: { redis: {

@ -1,7 +1,7 @@
'use strict'; 'use strict';
const Mongo = require(__dirname+'/db.js') const Mongo = require(__dirname+'/db.js')
, db = Mongo.client.db('jschan').collection('accounts') , db = Mongo.db.collection('accounts')
, bcrypt = require('bcrypt') , bcrypt = require('bcrypt')
, cache = require(__dirname+'/../redis.js'); , cache = require(__dirname+'/../redis.js');

@ -2,7 +2,7 @@
'use strict'; 'use strict';
const Mongo = require(__dirname+'/db.js') const Mongo = require(__dirname+'/db.js')
, db = Mongo.client.db('jschan').collection('bans'); , db = Mongo.db.collection('bans');
module.exports = { module.exports = {

@ -3,7 +3,7 @@
const Mongo = require(__dirname+'/db.js') const Mongo = require(__dirname+'/db.js')
, cache = require(__dirname+'/../redis.js') , cache = require(__dirname+'/../redis.js')
, dynamicResponse = require(__dirname+'/../helpers/dynamic.js') , dynamicResponse = require(__dirname+'/../helpers/dynamic.js')
, db = Mongo.client.db('jschan').collection('boards'); , db = Mongo.db.collection('boards');
module.exports = { module.exports = {

@ -2,7 +2,7 @@
const Mongo = require(__dirname+'/db.js') const Mongo = require(__dirname+'/db.js')
, { blockBypass } = require(__dirname+'/../configs/main.js') , { blockBypass } = require(__dirname+'/../configs/main.js')
, db = Mongo.client.db('jschan').collection('bypass'); , db = Mongo.db.collection('bypass');
module.exports = { module.exports = {

@ -1,7 +1,7 @@
'use strict'; 'use strict';
const Mongo = require(__dirname+'/db.js') const Mongo = require(__dirname+'/db.js')
, db = Mongo.client.db('jschan').collection('captcha'); , db = Mongo.db.collection('captcha');
module.exports = { module.exports = {

@ -14,11 +14,11 @@ module.exports = {
useNewUrlParser: true, useNewUrlParser: true,
useUnifiedTopology: true useUnifiedTopology: true
}); });
module.exports.db = module.exports.client.db(configs.dbName);
}, },
checkVersion: async() => { checkVersion: async() => {
const currentVersion = await module.exports.client const currentVersion = await module.exports.db
.db('jschan')
.collection('version') .collection('version')
.findOne({ '_id': 'version' }) .findOne({ '_id': 'version' })
.then(res => res.version); .then(res => res.version);

@ -3,7 +3,7 @@
const Mongo = require(__dirname+'/db.js') const Mongo = require(__dirname+'/db.js')
, Boards = require(__dirname+'/boards.js') , Boards = require(__dirname+'/boards.js')
, formatSize = require(__dirname+'/../helpers/files/formatsize.js') , formatSize = require(__dirname+'/../helpers/files/formatsize.js')
, db = Mongo.client.db('jschan').collection('files') , db = Mongo.db.collection('files')
module.exports = { module.exports = {

@ -1,7 +1,7 @@
'use strict'; 'use strict';
const Mongo = require(__dirname+'/db.js') const Mongo = require(__dirname+'/db.js')
, db = Mongo.client.db('jschan').collection('modlog'); , db = Mongo.db.collection('modlog');
module.exports = { module.exports = {

@ -2,7 +2,7 @@
'use strict'; 'use strict';
const Mongo = require(__dirname+'/db.js') const Mongo = require(__dirname+'/db.js')
, db = Mongo.client.db('jschan').collection('news'); , db = Mongo.db.collection('news');
module.exports = { module.exports = {

@ -3,7 +3,7 @@
const Mongo = require(__dirname+'/db.js') const Mongo = require(__dirname+'/db.js')
, Boards = require(__dirname+'/boards.js') , Boards = require(__dirname+'/boards.js')
, Stats = require(__dirname+'/stats.js') , Stats = require(__dirname+'/stats.js')
, db = Mongo.client.db('jschan').collection('posts') , db = Mongo.db.collection('posts')
, { quoteLimit, previewReplies, stickyPreviewReplies , { quoteLimit, previewReplies, stickyPreviewReplies
, early404Replies, early404Fraction } = require(__dirname+'/../configs/main.js'); , early404Replies, early404Fraction } = require(__dirname+'/../configs/main.js');

@ -1,7 +1,7 @@
'use strict'; 'use strict';
const Mongo = require(__dirname+'/db.js') const Mongo = require(__dirname+'/db.js')
, db = Mongo.client.db('jschan').collection('ratelimit'); , db = Mongo.db.collection('ratelimit');
module.exports = { module.exports = {

@ -2,7 +2,7 @@
'use strict'; 'use strict';
const Mongo = require(__dirname+'/db.js') const Mongo = require(__dirname+'/db.js')
, db = Mongo.client.db('jschan').collection('poststats'); , db = Mongo.db.collection('poststats');
module.exports = { module.exports = {

@ -1,7 +1,7 @@
'use strict'; 'use strict';
const Mongo = require(__dirname+'/db.js') const Mongo = require(__dirname+'/db.js')
, db = Mongo.client.db('jschan').collection('webring'); , db = Mongo.db.collection('webring');
module.exports = { module.exports = {

@ -45,7 +45,7 @@ async function wipe() {
const Mongo = require(__dirname+'/db/db.js') const Mongo = require(__dirname+'/db/db.js')
const Redis = require(__dirname+'/redis.js') const Redis = require(__dirname+'/redis.js')
await Mongo.connect(); await Mongo.connect();
const db = Mongo.client.db('jschan'); const db = Mongo.db;
//make these because mongo is dumb and doesnt make them automatically //make these because mongo is dumb and doesnt make them automatically
await db.createCollection('accounts'); await db.createCollection('accounts');
@ -313,7 +313,7 @@ async function migrate() {
const Mongo = require(__dirname+'/db/db.js') const Mongo = require(__dirname+'/db/db.js')
const Redis = require(__dirname+'/redis.js') const Redis = require(__dirname+'/redis.js')
await Mongo.connect(); await Mongo.connect();
const db = Mongo.client.db('jschan'); const db = Mongo.db;
//get current version from db if present (set in 'reset' task in recent versions) //get current version from db if present (set in 'reset' task in recent versions)
let currentVersion = await db.collection('version').findOne({ let currentVersion = await db.collection('version').findOne({

@ -60,7 +60,7 @@ module.exports = async () => {
if (webringBoards.length > 0) { if (webringBoards.length > 0) {
//$out from temp collection to replace webring boards //$out from temp collection to replace webring boards
const tempCollection = Mongo.client.db('jschan').collection('tempwebring'); const tempCollection = Mongo.db.collection('tempwebring');
await tempCollection.insertMany(webringBoards); await tempCollection.insertMany(webringBoards);
await tempCollection.aggregate([ await tempCollection.aggregate([
{ $out : 'webring' } { $out : 'webring' }

Loading…
Cancel
Save