Last active
July 22, 2019 00:52
-
-
Save eduardoromero/7860d8a6a056228386382bcd9b6cd024 to your computer and use it in GitHub Desktop.
Setting up express and rethinkdb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const bodyParser = require('body-parser') | |
const express = require('express') | |
const Webtask = require('webtask-tools') | |
const server = express() | |
server.use(bodyParser.json()) | |
server.use(bodyParser.urlencoded({extended: true})) | |
// pass RethinkDB around xD | |
server.use((req, res, next) => { | |
req.db = require('rethinkdbdash')({ | |
db: 'weshare', | |
servers: [{host: req.webtaskContext.secrets.RETHINKDB_SERVER, port: 28015}] | |
}) | |
next() | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment