Skip to content

Instantly share code, notes, and snippets.

View marshallswain's full-sized avatar
😄

Marshall Thompson marshallswain

😄
View GitHub Profile
@marshallswain
marshallswain / authentication.js
Last active September 24, 2021 08:59
Example tools for using querystring redirects with Feathers OAuth login.
'use strict';
const authentication = require('feathers-authentication');
const jwt = require('feathers-authentication-jwt');
const local = require('feathers-authentication-local');
const oauth2 = require('feathers-authentication-oauth2');
const GithubStrategy = require('passport-github');
// Bring in the oauth-handler
const makeHandler = require('./oauth-handler');
@marshallswain
marshallswain / launch.json
Last active July 1, 2019 20:10
Setting up Visual Studio Code to work with Nuxt.js
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "npm run dev",
"runtimeExecutable": "npm",
"windows": {
"runtimeExecutable": "npm.cmd"
@marshallswain
marshallswain / readme.md
Created April 17, 2017 12:40
FeathersJS: Better permissions

Better Permissions Control

We have introduced 3 new hooks and 2 new middleware as part of feathers-permissions that give you much more flexibility and control over access permissions than was previously possible. Permissions are stored in the database on the entity record that needs to have access permissions checked (typically a user). They look like this:

[
    '*', // all services, all methods, all docs
    'users:*', // all methods on users service
    'users:remove:*', // can remove any user
    '*:remove', // can remove on any service
@marshallswain
marshallswain / birds.md
Last active May 2, 2017 20:48
Birds A-Z
@marshallswain
marshallswain / can-set-api.js
Last active May 6, 2017 00:18
Proposal for new can-set API (Rought Draft)
var set = require('can-set');
// The current API
var algebra = new set.Algebra(
// specify the unique identifier on data
set.props.id("_id"),
// specify that completed can be true, false or undefined
set.props.boolean("retired"),
// specify properties that define pagination
set.props.rangeInclusive("start","end"),
@marshallswain
marshallswain / app.js
Created May 30, 2017 22:28
Listening to user updates and updating the connected sockets
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');
@marshallswain
marshallswain / .htaccess
Created June 26, 2017 14:39
Feathers socket.io behind Apache reverse proxy - credit to j2l4e
RewriteEngine On
RewriteCond %{HTTP:Connection} Upgrade [NC]
RewriteRule ^/(.*) ws://localhost:3030/$1 [P,L]
ProxyPass / http://localhost:3030/
ProxyPassReverse / http://localhost:3030/
@marshallswain
marshallswain / generate-block.sh
Last active July 18, 2017 15:35
Starting Bitcoin Core dev
curl --user 'equibit:equibit' -H "Content-Type: application/json" -d '{"method":"generate", "params": [1]}' 127.0.0.1:18332
@marshallswain
marshallswain / iv-encrypt.js
Created June 29, 2017 19:47
Encrypt with Initialization Vector
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)
@marshallswain
marshallswain / feathers-mongoose-upsert.js
Last active July 8, 2017 04:08
Upserting with feathers-mongoose's `patch` method
const data = { address: '1', identifier: 'some-identifier' }
const params = {
query: { address: '1' },
mongoose: { upsert: true }
}
app.service('address-meta').patch(null, data, params)