remove leveldb

This commit is contained in:
Wingy 2020-11-03 22:01:52 -05:00
parent de17482fdf
commit 653b8ef91a
5 changed files with 622 additions and 142 deletions

View file

@ -15,9 +15,6 @@ EXPOSE 80
RUN mkdir -p /data/dbs RUN mkdir -p /data/dbs
ENV DB_PREFIX /data/dbs/ ENV DB_PREFIX /data/dbs/
RUN mkdir -p /data/sessions
ENV SESSION_STORE /data/sessions
ENV SECRET_DIRNAME /data ENV SECRET_DIRNAME /data
CMD ./Dockerstart.sh CMD ./Dockerstart.sh

View file

@ -9,7 +9,6 @@ module.exports = {
dbExposePort: Number(process.env.DB_EXPOSE_PORT) || null, dbExposePort: Number(process.env.DB_EXPOSE_PORT) || null,
proxyServer: process.env.PROXY_SERVER || undefined, proxyServer: process.env.PROXY_SERVER || undefined,
secret: process.env.SECRET || require('./secret'), secret: process.env.SECRET || require('./secret'),
sessionStore: process.env.SESSION_STORE || './sessions',
sessionMaxAge: Number(process.env.SESSION_MAX_AGE) || 1000 * 60 * 60 * 24 * 7, sessionMaxAge: Number(process.env.SESSION_MAX_AGE) || 1000 * 60 * 60 * 24 * 7,
siteTitle: process.env.SITE_TITLE || 'Christmas Community', siteTitle: process.env.SITE_TITLE || 'Christmas Community',
shortTitle: process.env.SHORT_TITLE || 'Christmas', shortTitle: process.env.SHORT_TITLE || 'Christmas',

View file

@ -1,5 +1,5 @@
global._CC = { require } global._CC = { require }
const expressSessionLevel = require('express-session-level'); const PouchSession = require('session-pouchdb-store');
const LocalStrategy = require('passport-local').Strategy; const LocalStrategy = require('passport-local').Strategy;
const session = require('express-session'); const session = require('express-session');
const bcrypt = require('bcrypt-nodejs'); const bcrypt = require('bcrypt-nodejs');
@ -19,7 +19,6 @@ if (!config.dbPrefix.startsWith('http')) {
const PouchDB = require('pouchdb').defaults({ prefix: config.dbPrefix }); const PouchDB = require('pouchdb').defaults({ prefix: config.dbPrefix });
const logger = require('./logger'); const logger = require('./logger');
const { dbExposePort } = require('./config');
const app = express(); const app = express();
app.set('base', config.base) app.set('base', config.base)
@ -54,15 +53,12 @@ passport.deserializeUser((user, callback) => {
}); });
const LevelStore = expressSessionLevel(session);
const sessionDb = level(config.sessionStore)
app.use(require('body-parser').urlencoded({ extended: true })); app.use(require('body-parser').urlencoded({ extended: true }));
app.use(session({ app.use(session({
secret: config.secret, secret: config.secret,
resave: false, resave: false,
saveUninitialized: true, saveUninitialized: true,
store: new LevelStore(sessionDb), store: new PouchSession(new PouchDB('sessions')),
cookie: { cookie: {
maxAge: config.sessionMaxAge maxAge: config.sessionMaxAge
}, },
@ -85,7 +81,7 @@ app.use(config.base, require('./routes')({ db, config }));
app.listen(config.port, () => logger.success('express', `Express server started on port ${config.port}!`)) app.listen(config.port, () => logger.success('express', `Express server started on port ${config.port}!`))
;(() => { ;(() => {
if (!dbExposePort) return if (!config.dbExposePort) return
const dbExposeApp = express() const dbExposeApp = express()
dbExposeApp.use('/', require('express-pouchdb')(PouchDB, { inMemoryConfig: true })); dbExposeApp.use('/', require('express-pouchdb')(PouchDB, { inMemoryConfig: true }));
dbExposeApp.listen(config.dbExposePort, () => logger.success('db expose', `DB has been exposed on port ${config.dbExposePort}`)) dbExposeApp.listen(config.dbExposePort, () => logger.success('db expose', `DB has been exposed on port ${config.dbExposePort}`))

View file

@ -24,9 +24,7 @@
"express": "4.17.1", "express": "4.17.1",
"express-pouchdb": "^4.2.0", "express-pouchdb": "^4.2.0",
"express-session": "^1.15.6", "express-session": "^1.15.6",
"express-session-level": "^1.0.0",
"get-product-name": "1", "get-product-name": "1",
"level": "^6.0.0",
"memdown": "^5.1.0", "memdown": "^5.1.0",
"mkdirp": "^0.5.5", "mkdirp": "^0.5.5",
"moment": "^2.29.1", "moment": "^2.29.1",
@ -35,6 +33,7 @@
"passport-local": "^1.0.0", "passport-local": "^1.0.0",
"pouchdb": "^7.2.2", "pouchdb": "^7.2.2",
"pug": "^3.0.0", "pug": "^3.0.0",
"session-pouchdb-store": "^0.4.1",
"u64": "^1.0.1", "u64": "^1.0.1",
"yes-no": "^0.0.1" "yes-no": "^0.0.1"
} }

747
yarn.lock

File diff suppressed because it is too large Load diff