본문 바로가기

til34

[TIL] 20201228 Authentication from "Scratch" Authentication The process of verifying who a particular user is. We typically authenticate with a username/password combo, but we can also use security questions, facial recognition, etc. Authorization Verifying what a specific user has access to. Generally, we authorize after a user has been authenticated. How to (Not) Store Passwords: NEVER Store Passwords As They Are Rather than storing a pa.. 2020. 12. 28.
[TIL] 20201226 Express Session & Flash Sessions Sessions are a server-side data store that we use to make HTTP stateful. Instead of storing data using cookies, we store the data on the server-side and then send the browser a cookie that can be used to retrieve the data. It's not very practical or secure to store a lot of data client-side using cookies. This is where sessions come in. Express Session install : npm i express-session Ex.. 2020. 12. 26.
[TIL] 20201222 Express Router & Cookies Router An isolated instance of middleware and routes. Helps grouping routes into separate files. express.Router() Example //index.js const express = require('express'); const app = express(); const shelterRoutes = require('./shelters'); app.use('/shelters', shelterRoutes); //shelters.js const express = require('express'); const router = express.Router(); router.get('/', (req, res) => { //'/' is .. 2020. 12. 22.
[TIL] 20201221 Data Relationships With Mongo Mongo Relationships We usually have a lot of data and they are interconnected to each other. SQL Relationships Overview Have independent tables and they reference each other to have relationships. To keep up with Many to Many relationships, it is common to create another table that only references other tables. One to Few Embed the data directly in the document Example { name : 'Tommy Cash', sav.. 2020. 12. 21.
[TIL] 20201219 Handling Errors in Express Apps Express' Built-In Error Handler Responds with default 500 status code HTML response Custom Error Handlers Error-handling functions have four arguments (err, req, res, next) Example app.use(function(err, req, res, next) { console.error(err.stack); res.status(500).send('Something Broke'); //default error doesn't work anymore. } If you pass anything to the next() function, Express regards the curre.. 2020. 12. 19.
[TIL] 20201218 Middleware: The Key To Express Express Middleware Functions that run during the request/response lifecycle. request → Middleware → response Each middleware has access to the request and response objects Middleware can end the HTTP request by sending back a response with method like res.send() Or middleware can be chained together, one after another by calling next() Middleware functions can perform the following tasks: Execut.. 2020. 12. 19.
[TIL] 20201217 MongoDB / Mongoose Database Why Use DB DB can handle large amounts of data effectively and store it compactly. DB provide tools for easy insertion, querying, and updating of data. DB generally offer security features and control over access to data. DB (generally) scale well. SQL vs. NoSQL Databases SQL NoSQL Structured Query Language Do not use SQL. (Newer, diverse group) Relational DB : Can relate tables, often .. 2020. 12. 17.
[TIL] 20201216 Express / Dynamic HTML with Templating / RESTful Routes Express An NPM package which comes with a bunch of methods and optional plugins that we can use to build web applications and APIs Fast, unopinionated, minimalist web framework for Node.js Start up a server to listen for requests Parse income requrests Match those requests to particular routes Craft our http response and associated content Library vs. Framework Library: The user controls the flo.. 2020. 12. 16.
[TIL] 20201215 The Terminal / Our First Brush with Node / Exploring Modules & The NPM Terminal Terminal Text-based prompt where the user can interact with the machine. Originally, used to be a physical object. Now we use software terminals. Why Use Terminal Using terminal takes less time than using GUI once you get used to it. Terminal provides a "mainline" into the heart of the computer, giving us access to areas we normally don't interact with. Many of the tools we need are ins.. 2020. 12. 15.
[TIL] 20201214 Prototypes, Classes & OOP Object Prototypes The mechanism by which JavaScript Object inherit features from one another. A template object Typically contains properties and methods. __proto__ : reference to the object prototype Obj.prototype : The real object prototype. Factory Functions A function that creates an object like a template. If the object contains all the properties that a function needs as arguments, it's be.. 2020. 12. 14.
[TIL] 20201212 AJAX and API's AJAX Asynchronous Javascript And Xml Nowadays most APIs use JSON instead of XML Creates applications where we can fatch, load, and send data without refreshing the whole page. API Application Programming Interface Web API : Web-based Interfaces. HTTP based. Can retrieve the information we need. JSON JavaScript Object Notation A format for sending data Has key-value pair Can't store JavaScript va.. 2020. 12. 13.
[TIL] 20201211 Async JavaScript The Call Stack Definition The mechanism the JavaScript interpreter uses to keep track of its place in a script that calls multiple functions. How JavaScript 'knows' what function is currently being run and what functions are called from within that function, etc. Some sort of "bookmark" How it works When a script calls a function, the interpreter adds it to the call stack and then starts carryin.. 2020. 12. 13.