Skip to content

Instantly share code, notes, and snippets.

View joedooley's full-sized avatar

Joe Dooley joedooley

  • Florida
  • 02:08 (UTC -04:00)
View GitHub Profile
@joedooley
joedooley / cleanup-steps.md
Created August 12, 2022 22:18 — forked from aws-amplify-ops/cleanup-steps.md
Steps for cleaning user data for owner based auth schema

Who is this Gist for?

This Gist demonstrates an approach to removing a specific user's data from an Amazon DynamoDB table that was created as an AWS AppSync data source. It may be helpful for those who need to remove records that are associated with a Cognito User that will be deleted from their Cognito User Pool.

Steps to clean up user data

Clean up user data with DataStore disabled (conflict resolution disabled)

Assuming you have this schema

@joedooley
joedooley / _middleware.ts
Created August 2, 2022 15:42 — forked from alexjtupper/_middleware.ts
@auth0-nextjs getSession compatible with Next.js Edge Runtime (middleware)
import { getSession } from './getMiddlewareSession';
import { NextMiddleware } from 'next/server';
const middleware: NextMiddleware = async (req, event) => {
try {
let session = await getSession(req)
console.log(session.user.name)
} catch (err) {
console.error(err)
}
@joedooley
joedooley / .babelrc.js
Created November 5, 2021 00:00 — forked from nodkz/.babelrc.js
Babel 7.0 with .babelrc.js DEPRECATED! This config was created when babel 7 was in beta
/* eslint-disable prefer-template */
const path = require('path');
const aliases = require('./aliases');
// ///////////////////////////////////////////////////////////////
// ////////////////// PLUGINS ////////////////////////////////
// ///////////////////////////////////////////////////////////////
const commonPlugins = [
@joedooley
joedooley / esm-package.md
Created September 1, 2021 13:51 — forked from sindresorhus/esm-package.md
Pure ESM package

Pure ESM package

The package linked to from here is now pure ESM. It cannot be require()'d from CommonJS.

This means you have the following choices:

  1. Use ESM yourself. (preferred)
    Use import foo from 'foo' instead of const foo = require('foo') to import the package. Follow the below guide.
  2. If the package is used in an async context, you could use await import(…) from CommonJS instead of require(…).
  3. Stay on the existing version of the package until you can move to ESM.
@joedooley
joedooley / custom-error.js
Created November 16, 2020 16:46 — forked from justmoon/custom-error.js
Creating custom Error classes in Node.js
'use strict';
module.exports = function CustomError(message, extra) {
Error.captureStackTrace(this, this.constructor);
this.name = this.constructor.name;
this.message = message;
this.extra = extra;
};
require('util').inherits(module.exports, Error);
@joedooley
joedooley / A: Secure Sessions Howto
Created October 29, 2020 00:51 — forked from nikmartin/A: Secure Sessions Howto
Secure sessions with Node.js, Express.js, and NginX as an SSL Proxy
Secure sessions are easy, but not very well documented.
Here's a recipe for secure sessions in Node.js when NginX is used as an SSL proxy:
The desired configuration for using NginX as an SSL proxy is to offload SSL processing
and to put a hardened web server in front of your Node.js application, like:
[NODE.JS APP] <- HTTP -> [NginX] <- HTTPS -> [PUBLIC INTERNET] <-> [CLIENT]
Edit for express 4.X and >: Express no longer uses Connect as its middleware framework, it implements its own now.
@joedooley
joedooley / better-nodejs-require-paths.md
Created October 24, 2020 23:08 — forked from branneman/better-nodejs-require-paths.md
Better local require() paths for Node.js

Better local require() paths for Node.js

Problem

When the directory structure of your Node.js application (not library!) has some depth, you end up with a lot of annoying relative paths in your require calls like:

const Article = require('../../../../app/models/article');

Those suck for maintenance and they're ugly.

Possible solutions

@joedooley
joedooley / localhost-ssl.sh
Created August 23, 2020 14:59 — forked from jonsamp/localhost-ssl.sh
Create https key and cert on localhost
cd ~/
mkdir .localhost-ssl
sudo openssl genrsa -out ~/.localhost-ssl/localhost.key 2048
sudo openssl req -new -x509 -key ~/.localhost-ssl/localhost.key -out ~/.localhost-ssl/localhost.crt -days 3650 -subj /CN=localhost
sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain ~/.localhost-ssl/localhost.crt
npm install -g http-server
echo "
function https-server() {
@joedooley
joedooley / App.js
Created February 17, 2020 21:51 — forked from nvbn/App.js
Hooks with classes
import React from "react";
import Counter from "./Counter";
const App = () => {
return (
<div className="App">
<Counter initialCount={100} />
</div>
);
};
@joedooley
joedooley / Contract Killer 3.md
Created July 14, 2019 18:17 — forked from jesgs/Contract Killer 3.md
The latest version of my ‘killer contract’ for web designers and developers

Contract Killer

The popular open-source contract for web professionals by Stuff & Nonsense

  • Originally published: 23rd December 2008
  • Revised date: March 15th 2016
  • Original post