Skip to content

Instantly share code, notes, and snippets.

View paigen11's full-sized avatar

Paige Niedringhaus paigen11

View GitHub Profile
@paigen11
paigen11 / mysql-sequelize-connections.js
Created September 4, 2018 20:42
Quick config for setting up a MySQL database using Sequelize ORM in one file. Then this can be imported into route files or the server.js file directly
import Sequelize from 'sequelize';
import UserModel from './models/user';
const sequelize = new Sequelize('<table name>', '<db username>', '<db password>', {
host: '<host - could be localhost or service name for docker-compose service>',
dialect: 'mysql <or whichever SQL dialect you choose>',
});
const User = UserModel(sequelize, Sequelize);
@paigen11
paigen11 / findUser.js
Created September 4, 2018 20:50
Passport local and Passport JWT authentication with custom callbacks examples with a user registration MERN service.
import passport from 'passport';
module.exports = app => {
app.get('/findUser', (req, res, next) => {
passport.authenticate('jwt', { session: false }, (err, user, info) => {
if (err) {
console.log(err);
}
if (info != undefined) {
console.log(info.message);
@paigen11
paigen11 / og-pr-template.md
Created June 8, 2019 19:47
An example of the type of pull request my development team used to keep the formatting consistent

Story

Jira, Pivotal Tracker, (link to where the story you worked on lives)

PR Branch

URL to the automated branch build for feature testing

Code Coverage

URL to the automated code coverage report run during the automated build process

e2e

@paigen11
paigen11 / pull_request_template.md
Last active June 8, 2019 21:26
An example of a pull request template, as used by Github to automatically provide formatted PRs.

Tracker ID: #ADD LINK TO PIVOTAL STORY

Unit tests completed?: (Y/N)

PR Branch #ADD LINK TO PR BRANCH

Code Coverage & Build Info

@paigen11
paigen11 / basic-string.js
Created September 14, 2019 15:01
Basic String
const string1 = 'this is a string in single quotes';
const string2 = "this is a string in double quotes";
@paigen11
paigen11 / string-template.js
Last active September 15, 2019 18:38
Template literal examples: single line, multi-line, and expression placeholders
// just a normal string in one line - not much different from a traditional string
const simpleString = `a template literal is surrounded by backticks`;
// a string spread across multiple lines
const multiLineString = `it can be spread across
multiple lines with just
one set of enclosing backticks`;
const name = "Paige";
@paigen11
paigen11 / back-ticks.js
Last active September 14, 2019 23:13
Template literal back-ticks basic example
/* your basic JavaScript strings, but with back-ticks.
notice the lack of escape characters needed for things
like single quotes, double quotes, and apostrophes
when back-ticks are employed */
const fooString = `A string called 'fooString'`;
const barString = `Another string named "barString"`;
const bazString = `Without fooString and barString, you can't have bazString, right?`;
@paigen11
paigen11 / expression-placeholder.js
Last active September 14, 2019 23:26
Template expression placeholder example
function authorize(user, action) {
if (!user.hasPermission(action)) {
throw new Error(
`User ${user.name} is not allowed to ${action}.`
);
}
}
const person = {
name: "Sean"
@paigen11
paigen11 / og-multi-line-string.js
Last active September 14, 2019 23:42
Multi-line string examples using traditional strings versus template literal back-ticks
console.log("To make a multi-line string this way\n" +
"I have to concatenate two separate strings with a + sign");
/* prints: To make a multi-line string this way
I have to concatenate two separate strings with a + sign */
@paigen11
paigen11 / template-literal-multi-line-string.js
Created September 14, 2019 23:43
Multi-line string created using template literal syntactic sugar
console.log(`With template literal back-ticks, I can spread strings across
as many lines as I want
with
no
problem.`);
/* prints: With template literal back-ticks, I can spread strings across
as many lines as I want
with
no