본문 바로가기

TIL: Today I Learned37

[TIL] 20210412 자바스크립트란? 자바 스크립트의 역사 1995년 브렌던 아이크(Brendan Eich)가 개발: 웹페이지의 보조적인 기능을 수행하기 위해 브라우저에서 동작하는 경량 프로그래밍 언어 1999년 Ajax 등장: 서버로부터 필요한 데이터만 전송받아 변경해야 하는 부분만 한정적으로 렌더링 하는 방식이 가능해짐. 웹브라우저에서도 데스크톱 애플리케이션과 유사한 빠른 성능과 부드러운 화면 전환이 가능해짐. V8 엔진 등장: 빠르게 동작하는 자바스크립트 엔진. 과거 웹 서버에서 수행되던 로직들이 대거 클라이언트(브라우저)로 이동함. Node.js 등장: 브라우저의 자바스크립트 엔진에서만 동작하던 자바스크립트를 브라우저 이외의 환경에서도 동작할 수 있도록 자바스크립트 엔진을 브라우저에서 독립시킨 자바스크립트 실행 환경. 2015년 공개.. 2021. 4. 12.
[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.