Skip to content

Instantly share code, notes, and snippets.

View PavelDemyanenko's full-sized avatar
:octocat:
Right now mostly reacting

xeLL PavelDemyanenko

:octocat:
Right now mostly reacting
View GitHub Profile
https://habr.com/post/351168/
Basic saga flow:
// sagas/index.js
export default function* rootSaga() {
yield fork(dataSaga)
}
// index.js
import rootSaga from './sagas'
https://medium.com/piterjs/announce26-917b2eb6b267
A7 data server
контроль теплоснобжения А7 системы
Что такое А7:
data base + applications server = fast big data server
db -> vm+control accsess =>> extenstion, graphs == 1m in memory 50k transactions (couchDB in speed perf)
a7 systems store data in counters for graphics and user actions
CRDT:
https://github.com/bind-disney/spbrubyconf-2108-crdt-example
react data stores (sets are stored in vesrions vector) (vesrions vector, changes vector)
so the max index of value wins in the case of this structures
merge fucntion is applyied when the replication starts
merge function has access to the index and merge state (vectors)
index: function(req, res) {
User.findOne(req.token).exec(function(err, message) {
// Work with the user here
});
};
module.exports = function(req, res, next) {
var token;
if (req.headers && req.headers.authorization) {
var parts = req.headers.authorization.split(' ');
if (parts.length == 2) {
var scheme = parts[0],
credentials = parts[1];
if (/^Bearer$/i.test(scheme)) {
register: function(req, res) {
//TODO: Do some validation on the input
if (req.body.password !== req.body.confirmPassword) {
return res.json(401, {err: 'Password doesn\'t match'});
}
User.create({email: req.body.email, password: req.body.password}).exec(function(err, user) {
if (err) {
res.json(err.status, {err: err});
return;
var jwt = require('jsonwebtoken');
module.exports.issueToken = function(payload) {
var token = jwt.sign(payload, process.env.TOKEN_SECRET || "our biggest secret");
return token;
};
module.exports.verifyToken = function(token, verified) {
return jwt.verify(token, process.env.TOKEN_SECRET || "our biggest secret", {}, verified);
};
@PavelDemyanenko
PavelDemyanenko / AuthController.js
Last active August 29, 2015 14:14
authController
authenticate: function(req, res) {
var email = req.param('email');
var password = req.param('password');
if (!email || !password) {
return res.json(401, {err: 'email and password required'});
}
User.findOneByEmail(email, function(err, user) {
if (!user) {
@PavelDemyanenko
PavelDemyanenko / .ackrc
Last active August 29, 2015 14:14 — forked from theaboutbox/.ackrc
--type-add=css=.sass,.less,.scss
--type-add=ruby=.rake,.rsel,.builder,.thor
--type-add=html=.haml,.html.erb,.html.haml
--type-add=js=.js.erb,.coffee
--type-set=cucumber=.feature
--type-set=c=.c,.cpp,.ino,.pde,.h
--ignore-dir=vendor
--ignore-dir=log
--ignore-dir=tmp
--ignore-dir=doc