You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First of all, thanks for doing this! This npm module seems pretty interesting. I personally don't use koa, but just wanted to make a quick suggestion to your documentation.
I like the simplicity of your example, but the variable naming is a bit confusing. Let me try to explain why with comments...
var koa = require('koa')
// for use with koa-generic-session
var session = require('koa-generic-session')
var RethinkSession = require('koa-generic-session-rethinkdb')
/*!
* In most example of rethinkdbdash, the code used to instanstiate it is the following:
* `var r = require('rethinkdbdash')();`
* The fact that this is different (only by two parenthesis is already a little confusing!).
* That being said, naming it to `rethinkdb` seems appropriate
*/
var rethinkdb = require('rethinkdbdash')
/*!
* What the function returned by importing `rethinkdbdash` returns is not really a connection.
* It's more an instance of rethinkdbdash which actually has a connection pool, which actually
* has multiple connections. Using the word connection is not totally off, but (by convention)
* most people use the `r` variable here. Not using the `r` variable somehow seems to suggest that
* this is different, when this is actually not.
*/
var connection = rethinkdb({
host: 'localhost',
port: 28015
})
var sessionStore = new RethinkSession({connection: connection})
// create the db, table and indexes to store sessions
sessionStore.setup()
var app = koa()
// used for cookie stuffs
app.keys = ['foo', 'bar']
app.use(session({
store: sessionStore
})
I suggest the following:
var koa = require('koa')
// for use with koa-generic-session
var session = require('koa-generic-session')
var RethinkSession = require('koa-generic-session-rethinkdb')
var r = require('rethinkdbdash')({
host: 'localhost',
port: 28015
});
var sessionStore = new RethinkSession({connection: r })
// create the db, table and indexes to store sessions
sessionStore.setup()
var app = koa()
// used for cookie stuffs
app.keys = ['foo', 'bar']
app.use(session({
store: sessionStore
})
Again, thanks for taking time to work on this! Just had an issue with a user who got a little confused because of the variable naming and thought others might have run into this. I might also be totally wrong about all this and missing something :). Thanks!
The text was updated successfully, but these errors were encountered:
First of all, thanks for doing this! This npm module seems pretty interesting. I personally don't use koa, but just wanted to make a quick suggestion to your documentation.
I like the simplicity of your example, but the variable naming is a bit confusing. Let me try to explain why with comments...
I suggest the following:
Again, thanks for taking time to work on this! Just had an issue with a user who got a little confused because of the variable naming and thought others might have run into this. I might also be totally wrong about all this and missing something :). Thanks!
The text was updated successfully, but these errors were encountered: