Skip to content

Instantly share code, notes, and snippets.

View dapperAuteur's full-sized avatar
🏠
teach what's been taught.

dapperAuteur dapperAuteur

🏠
teach what's been taught.
View GitHub Profile
package com.awews;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import com.awews.person.User;
@dapperAuteur
dapperAuteur / index.js
Created September 14, 2018 21:55
facebook messenger chatbot using express and fb api
require("dotenv").config()
var express = require('express'),
app = express(),
// cors = require('cors'),
bodyParser = require('body-parser');
const request = require('request');
// app.use(cors());
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
async handleLoadPalabras() {
let fourLetterWords = await apiCalls.getPalabras('four-letter-words');
let prefixSuffixRoots = await apiCalls.getPalabras('prefix-suffix-roots');
let verbos = await apiCalls.getPalabras('verbos');
this.setState({
fourLetterWords,
prefixSuffixRoots,
verbos
});
@dapperAuteur
dapperAuteur / index.js
Created August 31, 2018 13:37
chatbot webhook with switch statements and regex
'use strict'
const express = require('express')
const bodyParser = require('body-parser')
const request = require('request');
const app = express().use(bodyParser.json());
let db = require("./models");
let challengerRoutes = require("./routes/challengers");
let attachmentRoutes = require("./routes/attachments");
@dapperAuteur
dapperAuteur / DetailsPalabra.js
Created March 25, 2018 15:32
attempting to update `p` based on the location.hash or location.pathname
import React, { Component } from 'react';
import PropTypes from 'prop-types';
class DetailsPalabras extends Component {
constructor(props) {
super(props);
const { fourLetterWord, prefixSuffixRoot, verbo } = props.data;
// load next random word
const { p } = props.location.hash;
const { onLoadRandomPalabra } = props.data;
@dapperAuteur
dapperAuteur / errorMessage on public routes
Last active March 24, 2018 00:10
below is the index.js file for my app error message I get on public routes of my api when attempting to add auth0
{
"error": {
"message": "No authorization token was found"
}
}
@dapperAuteur
dapperAuteur / App.js
Created March 21, 2018 14:58
App.js method calls method in apiCalls.js ; NOT handling erros properly, Unhandled Rejection (TypeError): Cannot read property '_id' of undefined
async handleLoadPalabra(p, pObj){
let palabra;
let params = p.slice(0, -1);
console.log(p, pObj);
if (pObj.hasOwnProperty("_id")) {
console.log(pObj);
palabra = await apiCalls.getPalabra(p, pObj);
console.log(palabra);
} else if (pObj.hasOwnProperty('word')) {
let word = pObj.word;
@dapperAuteur
dapperAuteur / api.js
Created March 19, 2018 23:42
passing the token in the header to communicate user is authorized
export async function updatePalabra(p, pObj) {
console.log(`${APIURL}${p}${pObj._id}`);
console.log(pObj);
let token = `Bearer ${pObj.token}`;
console.log(token);
return fetch(`${APIURL}${p}${pObj._id}`, {
method: 'put',
headers: new Headers({
'Content-Type': 'application/json',
'Authorization': token
require('dotenv').load()
var jwt = require("jsonwebtoken")
exports.loginRequired = function (req, res, next) {
try {
var token = req.headers.authorization.split(" ")[1]
jwt.verify(token, process.env.SECRET_KEY, function (err, decoded) {
if (decoded) {
next();
} else {
require("dotenv").config()
var express = require('express'),
app = express(),
cors = require('cors'),
bodyParser = require('body-parser');
authRoutes = require("./routes/auth");
var db = require("./models");
var authRoutes = require('./routes/auth');
var gameRoutes = require('./routes/games');