Password reset implementation for CouchDB
const http = require('http')
const jsonBody = require('body/json')
const PasswordReset = require('couchdb-password-reset')
const Templates = reqiure('couchdb-password-reset/templates')| function ensureParams (...params) { | |
| params.forEach((param) => assert(window[param], `${param} must be passed`)) | |
| } |
| /* global emit */ | |
| const TOKEN_LIFESPAN = 30 // seconds | |
| module.exports = { | |
| _id: '_design/users', | |
| views: { | |
| byEmail: { | |
| map: function (doc) { | |
| emit(doc.metadata.email) | |
| } |
| app.router((route) => [ | |
| route('/', Layout()), | |
| route('/:phone', requireLogin(Layout(Chat))), | |
| route('/login', Layout(Login)) | |
| ]) | |
| function requireLogin (View) { | |
| return function (state, prev, send) { | |
| if (!state.user.name) send('user:requireLogin') | |
| return View(state, prev, send) |
| const choo = require('choo') | |
| const html = require('choo/html') | |
| const app = choo() | |
| let dispatch | |
| const listen = (cb) => dispatch = cb | |
| app.model({ | |
| state: { foo: 'bar' }, |
| worker_processes 1; | |
| error_log logs/error.log; | |
| events { | |
| worker_connections 1024; | |
| } | |
| http { | |
| proxy_buffer_size 128k; | |
| proxy_buffers 4 256k; | |
| proxy_busy_buffers_size 256k; | |
| sendfile on; |
| const htmlIndex = require('simple-html-index') | |
| const BufferList = require('bl') | |
| function createPage (title) { | |
| const html = htmlIndex({ title }) | |
| const htmlBuffer = html.pipe(BufferList()) | |
| return function flush () { | |
| // return htmlBuffer // works | |
| return htmlBuffer.duplicate() // doesn't work (empty) |
| client.select('*').from(opts.table).stream() | |
| .pipe(through.obj(chunkToFiles)) | |
| .pipe(vfs.dest('./' + opts.table)) | |
| function chunkToFiles (chunk, enc, callback) { | |
| const primaryKey = chunk[opts.primaryKey] | |
| const keys = Object.keys(chunk) | |
| keys.forEach((key) => { | |
| const file = new File({ |
| --- | |
| layout: default | |
| --- | |
| {% include breadcrumbs.html parent="Datasets" %} | |
| {% assign schema = page.schema | default: site.schema %} | |
| {% assign dataset_fields = site.data.schemas[schema].dataset_fields %} | |
| {% assign dataset_system_fields = "title|organization|notes|license" | split: "|" %} | |
| {% assign resource_fields = site.data.schemas[schema].resource_fields %} | |
| {% assign resource_system_fields = "name|url|format|description" | split: "|" %} |
| const http = require('http') | |
| const Readable = require('stream').Readable | |
| const formBody = require('body/form') | |
| http.createServer(function (req, res) { | |
| const stream = new Readable | |
| console.log('inbound') | |
| formBody(req, {}, (err, body) => { | |
| stream.push('hi') | |
| stream.push(null) |