Skip to content

Instantly share code, notes, and snippets.

View marshallswain's full-sized avatar
😄

Marshall Thompson marshallswain

😄
View GitHub Profile
@kkkrist
kkkrist / app.js
Last active February 26, 2019 00:26
Rate limiting for FeathersJS HTTP (REST API) and Web Sockets connections (Express, Node.js)
'use strict'
const bodyParser = require('body-parser')
const compress = require('compression')
const configuration = require('feathers-configuration')
const cors = require('cors')
const favicon = require('serve-favicon')
const feathers = require('feathers')
const hooks = require('feathers-hooks')
const limiter = require('limiter').RateLimiter // Generic limiter used for authentication attempts inside web socket connection
<script src="../node_modules/steal/steal.js">
window.rerun = true;
function rerunIfSuccessful() {
var result = document.getElementById('qunit-testresult');
var failed = result.getElementsByClassName('failed');
if (!failed.length) {
setTimeout(rerunIfSuccessful, 4000);
} else if (failed[0].innerHTML === "0" && window.rerun) {
location.reload(true);
}
@vlucas
vlucas / encryption.ts
Last active March 9, 2025 19:43
Stronger Encryption and Decryption in Node.js
import { createCipheriv, createDecipheriv, randomBytes } from "crypto";
const ENCRYPTION_KEY: string = process.env.ENCRYPTION_KEY || ""; // Must be 256 bits (32 characters)
const IV_LENGTH: number = 16; // For AES, this is always 16
/**
* Will generate valid encryption keys for use
* Not used in the code below, but generate one and store it in ENV for your own purposes
*/
export function keyGen() {
@silvestreh
silvestreh / app-index.js
Last active August 21, 2019 17:19
Integrate Nuxt into Feathers
// src/index.js
/* eslint-disable no-console */
const logger = require('winston');
const app = require('./app');
const port = app.get('port');
process.on('unhandledRejection', (reason, p) => {
logger.error('Unhandled Rejection at: Promise ', p, reason);
@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');
@dcvezzani
dcvezzani / 20170603-Cordova-Running-an-ios-app-in-a-specifi.md
Last active September 14, 2017 04:28
Cordova: Running an ios app in a specific ios emulator

Cordova: Running an ios app in a specific ios emulator

You need two flags when specifying which target to emulate. Also, do not include the version number on the end.

Find out what emulator images are available. Again, take into account that the version number will not be included when specifying the target in the cordova call.

./platforms/ios/cordova/lib/list-emulator-images

iPhone-5, 10.3
@daffl
daffl / models.js
Created November 6, 2019 18:06
Feathers Schema proposal ideas
const { setSchema } = require('@feathersjs/schema');
class User {}
setSchema(User, {
id: {
type: Number
},
email: {
description: 'The user email',