- What does MVC stand for? What is MVC?
- Model, View, Controller
- Pattern - Design Pattern
- A way to present information to a user
- A way to seperate an application
- Separates an application into 3 parts
- Allow different information to be accessed by different
- Controller manipulates Model
- View - view and input - user interaction
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.get('/search/:location/:job', (request, response) => { | |
const { location, job } = request.params; | |
const cl = `https://${location}.craigslist.org/search/jjj?query=${job}`; | |
const reddit = `https://www.reddit.com/r/jobbit/search.json?q=${job}&restrict_sr=1`; | |
Promise.all([ | |
fetch(cl) | |
.then(response => response.text()), | |
fetch(reddit) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<div class="container"> | |
<div v-if="alertMessage" class="alert alert-secondary invisible" role="alert">{{alertMessage}}</div> | |
<div class="row"> | |
<div class="col-md-8 col-md-offset-2"> | |
<div class="panel panel-default"> | |
<div class="panel-heading">Example Chat</div> | |
<div class="panel-body"> | |
<ul> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
process.on('uncaughtException', (error) => { | |
console.log('Uncaught Exception:', error); | |
}); | |
process.on('unhandledRejection', (reason, p) => { | |
console.log('Unhandled Rejection at:', p, 'reason:', reason); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
router.post('/signup', async (req, res, next) => { | |
if (validUser(req.body)) { | |
const user = await User.getOneByEmail(req.body.email); | |
if (!user) { | |
const hash = await bcrypt.hash(req.body.password, 5); | |
const user = { | |
email: req.body.email, | |
password: hash, | |
created_at: new Date() | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const jwt = require('jsonwebtoken'); | |
const payload = { | |
id: 2, | |
email: '[email protected]' | |
}; | |
const token_secret = 'keyboard_cat'; | |
jwt.sign(payload, token_secret, { expiresIn: '1h' }, (err, token) => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require('express'); | |
const app = express(); | |
// app.use === generic, will be called for every request | |
app.use((req, res, next) => { | |
console.log(req.originalUrl, 'Time:', new Date()); | |
req.time = new Date(); | |
next(); | |
}); |
heroku login # login once
heroku create [name] # Initializes heroku app and adds remote.
heroku addons:create heroku-postgresql # add a postgres db addon to your heroku app
heroku logs [--tail] # Shows heroku server terminal
heroku pg:psql # connect to heroku addon database server
heroku config # shows heroku environment variables
- heroku config:set clown=fiesta # set a config variable
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(appReady); | |
function appReady() { | |
setLoading(false); | |
$('form').submit(sendMessage); | |
} | |
let progressInterval = null; | |
function setLoading(isLoading) { |