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 feathers = require('feathers/client') | |
const io = require('socket.io-client') | |
const axios = require('axios') | |
const rest = require('feathers-rest/client') | |
const socketio = require('feathers-socketio/client') | |
const auth = require('feathers-authentication-client') | |
const hooks = require('feathers-hooks') | |
// TODO: make this port dynamic like the server tests | |
const host = 'http://localhost:3030' |
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
module.exports = function (upsertQuery) { | |
if (typeof upsertQuery !== 'function') { | |
console.warn('No `upsertQuery` function was passed to the mapCreateToUpsert hook. Please set params.upsertQuery in the hook context to dynamically declare the function.') | |
} | |
return function mapCreateToUpsert (context) { | |
const { service, data, params } = context // const data = { address: '123', identifier: 'my-identifier' } | |
upsertQuery = params.upsertQuery || upsertQuery | |
if (typeof upsertQuery !== 'function') { |
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 data = { address: '2', identifier: 'some-other-identifier' } | |
const params = { | |
query: { address: '2' }, | |
mongoose: { upsert: true } | |
} | |
app.service('address-meta').patch(null, data, params) |
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
[ | |
{"address": "1", "identifier": "xxx"}, | |
{"address": "1", "identifier": "yyy"}, | |
{"address": "1", "identifier": "zzz"}, | |
] |
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
// address-map-model.js - A mongoose model | |
// | |
// See http://mongoosejs.com/docs/models.html for more of what you can do here. | |
module.exports = function (app) { | |
const mongooseClient = app.get('mongooseClient') | |
const addressMap = new mongooseClient.Schema({ | |
identifier: { type: String, required: true }, | |
address: { type: String, required: true } | |
}) |
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 data = { address: '1', identifier: 'some-identifier' } | |
const params = { | |
query: { address: '1' }, | |
mongoose: { upsert: true } | |
} | |
app.service('address-meta').patch(null, data, params) |
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 crypto = require('crypto') | |
const { Buffer } = require('buffer') | |
const IV_LENGTH = 16 // For AES, this is always 16 | |
function encrypt (text, key) { | |
let iv = crypto.randomBytes(IV_LENGTH) | |
let cipher = crypto.createCipheriv('aes-256-cbc', Buffer.from(key), iv) | |
let encrypted = cipher.update(text) |
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
curl --user 'equibit:equibit' -H "Content-Type: application/json" -d '{"method":"generate", "params": [1]}' 127.0.0.1:18332 |
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
RewriteEngine On | |
RewriteCond %{HTTP:Connection} Upgrade [NC] | |
RewriteRule ^/(.*) ws://localhost:3030/$1 [P,L] | |
ProxyPass / http://localhost:3030/ | |
ProxyPassReverse / http://localhost:3030/ |
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 path = require('path'); | |
const favicon = require('serve-favicon'); | |
const compress = require('compression'); | |
const cors = require('cors'); | |
const helmet = require('helmet'); | |
const bodyParser = require('body-parser'); | |
const feathers = require('feathers'); | |
const configuration = require('feathers-configuration'); | |
const hooks = require('feathers-hooks'); |