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
var logger = require('winston'); | |
var path = require('path'); | |
logger.add(logger.transports.File, {filename: path.join(__dirname, "../../logs/production.log")}); | |
// logger.remove(logger.transports.Console); | |
module.exports = logger; | |
// examples | |
//const logger = require('../tools/loger'); | |
//let metadata = {test: 123}; | |
//logger.info('user_created', 'description', metadata); |
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
var path = require('path'); | |
var path = require('crypto'); | |
var multer = require('multer'); | |
var storage = multer.diskStorage({ | |
destination: './uploads/', | |
filename: function (req, file, cb) { | |
crypto.pseudoRandomBytes(16, function (err, raw) { | |
if (err) return cb(err) |
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
var req = new XMLHttpRequest() | |
var file = new Blob(['This is a test'], { type: 'text/plain' }) | |
var data = new FormData() | |
data.append('photo', file, 'test.txt') | |
req.open('POST', '/upload') | |
req.send(data) |
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 EventsController = require('./events'); | |
const UsersController = require('./users'); | |
const socketsController = function (io) { | |
io.sockets.on('connection', function (socket) { | |
// login socket | |
if (!socket.decoded_token) { | |
console.log("Disconnecting unauthorized socket ", socket.id); | |
socket.disconnect('unauthorized'); | |
} else { | |
UsersController.initSocket(socket); |
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
var config = require('config'), | |
express = require('express'), | |
app = express(), | |
server = require('http').Server(app), | |
io = require('socket.io')(server, {'transports': ['websocket', 'polling']}), | |
bodyParser = require('body-parser'), | |
morgan = require('morgan'), | |
appConfig = require('./app/configs/config'), | |
jwt = require('jsonwebtoken'), | |
socketioJwt = require('socketio-jwt'), |
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
import {Component} from 'react'; | |
import store from 'store'; | |
import {socketConnect} from 'socket.io-react'; | |
import {connect} from 'react-redux'; | |
import errHandler from '../../errHandler'; | |
// import socket events constants | |
import {storeConstants} from '../../storeConstants'; | |
/** | |
* Class for EventList component. |
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
// sending to sender-client only | |
socket.emit('message', "this is a test"); | |
// sending to all clients, include sender | |
io.emit('message', "this is a test"); | |
// sending to all clients except sender | |
socket.broadcast.emit('message', "this is a test"); | |
// sending to all clients in 'game' room(channel) except sender |
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
delete a,b,c FROM wp_posts a LEFT JOIN wp_term_relationships b ON ( a.ID = b.object_id ) LEFT JOIN wp_postmeta c ON ( a.ID = c.post_id ) WHERE a.post_type IN("post", "attachment") |