Skip to content

Instantly share code, notes, and snippets.

View camperbot's full-sized avatar
🤖
I am just a bot.

freeCodeCamp's Camper Bot camperbot

🤖
I am just a bot.
View GitHub Profile
@camperbot
camperbot / quotes.json
Created December 19, 2017 18:13 — forked from nasrulhazim/quotes.json
Quotes List in JSON Format
{
"quotes": [
{
"quote":"Life isn’t about getting and having, it’s about giving and being.","author":"Kevin Kruse"},
{
"quote":"Whatever the mind of man can conceive and believe, it can achieve.","author":"Napoleon Hill"},
{
"quote":"Strive not to be a success, but rather to be of value.","author":"Albert Einstein"},
{
@camperbot
camperbot / client.js
Last active April 29, 2022 02:07 — forked from ShaunSHamilton/client.js
Advanced Node and Express - Send and Display Chat Messages
$(document).ready(function () {
/* Global io */
let socket = io();
socket.on('user', (data) => {
$('#num-users').text(data.currentUsers + ' users online');
let message = data.name + (data.connected ? ' has joined the chat.' : ' has left the chat.');
$('#messages').append($('<li>').html('<b>' + message + '</b>'));
});
@camperbot
camperbot / client.js
Last active February 4, 2022 16:29 — forked from ShaunSHamilton/client.js
Advanced Node and Express - Announce New Users
$(document).ready(function () {
/* Global io */
let socket = io();
socket.on('user', (data) => {
$('#num-users').text(data.currentUsers + ' users online');
let message = data.name + (data.connected ? ' has joined the chat.' : ' has left the chat.');
$('#messages').append($('<li>').html('<b>' + message + '</b>'));
});
@camperbot
camperbot / server.js
Last active August 27, 2022 10:19 — forked from ShaunSHamilton/server.js
Advanced Node and Express - Authentication with Socket.IO
'use strict';
require('dotenv').config();
const express = require('express');
const myDB = require('./connection');
const fccTesting = require('./freeCodeCamp/fcctesting.js');
const session = require('express-session');
const passport = require('passport');
const routes = require('./routes');
const auth = require('./auth.js');
@camperbot
camperbot / server.js
Last active September 14, 2020 03:42 — forked from ShaunSHamilton/server.js
Advanced Node and Express - Handle a Disconnect
'use strict';
require('dotenv').config();
const express = require('express');
const myDB = require('./connection');
const fccTesting = require('./freeCodeCamp/fcctesting.js');
const session = require('express-session');
const passport = require('passport');
const routes = require('./routes');
const auth = require('./auth.js');
@camperbot
camperbot / client.js
Last active September 14, 2020 03:41 — forked from ShaunSHamilton/client.js
Advanced Node and Express - Communicate by Emitting
$(document).ready(function () {
/* Global io*/
let socket = io();
socket.on('user count', function (data) {
console.log(data);
});
// Form submittion with new message in field with id 'm'
$('form').submit(function () {
@camperbot
camperbot / client.js
Last active July 9, 2022 01:35 — forked from ShaunSHamilton/client.js
Advanced Node and Express - Set up the Environment
// This file's full path is /public/client.js
$(document).ready(function () {
/* Global io */
let socket = io();
// Form submittion with new message in field with id 'm'
$('form').submit(function () {
let messageToSend = $('#m').val();
// Send message to server here?
$('#m').val('');
@camperbot
camperbot / auth.js
Last active August 20, 2022 21:10 — forked from ShaunSHamilton/auth.js
Advanced Node and Express - Implementation of Social Authentication III
const passport = require('passport');
const LocalStrategy = require('passport-local');
const bcrypt = require('bcrypt');
const ObjectID = require('mongodb').ObjectID;
const GitHubStrategy = require('passport-github').Strategy;
module.exports = function (app, myDataBase) {
passport.serializeUser((user, done) => {
done(null, user._id);
});
@camperbot
camperbot / auth.js
Last active October 21, 2022 11:28 — forked from ShaunSHamilton/auth.js
Advanced Node and Express - Implementation of Social Authentication II
const passport = require('passport');
const LocalStrategy = require('passport-local');
const bcrypt = require('bcrypt');
const ObjectID = require('mongodb').ObjectID;
const GitHubStrategy = require('passport-github').Strategy;
module.exports = function (app, myDataBase) {
passport.serializeUser((user, done) => {
done(null, user._id);
});
@camperbot
camperbot / routes.js
Last active September 16, 2021 19:50 — forked from ShaunSHamilton/routes.js
Advanced Node and Express - Implementation of Social Authentication
const passport = require('passport');
const bcrypt = require('bcrypt');
module.exports = function (app, myDataBase) {
app.route('/').get((req, res) => {
// Change the response to render the Pug template
res.render('pug', { title: 'Connected to Database', message: 'Please login', showLogin: true, showRegistration: true, showSocialAuth: true });
});
app.route('/login').post(passport.authenticate('local', { failureRedirect: '/' }), (req, res) => {
res.redirect('/profile');