Programming/JS

    _ lodash

    1. lodash ( _ ) 데이터 구조를 쉽게 다룰 수 있도록 도와주는 라이브러리 1.1. lodash Docs https://docs-lodash.com/v4/ Lodash Docs v4.17.11 – Documentation for JavaScript utility library A modern JavaScript utility library delivering modularity, performance & extras. Download Lodash is released under the MIT license & supports modern environments.Review the build differences & pick one that’s right for you. Installation I..

    Node.JS ) require, os모듈, path모듈, url모듈, fs모듈

    목차 1. require, exports 자바에서 임포트해서 쓰던 클래스 -> 자바스크립트에서는 '모듈(Module)'을 require 한다고 표현한다. 1.1. os모듈을 활용해보기 const os = require('os'); // 'os모듈의 기능을 담고있는 객체를 불러와, os변수에 (const형 변수)에 저장하고 사용할 것이다.' 라는 뜻 console.log('운영체제 정보 -----------------------------------------------------------'); console.log('os.arch() : ', os.arch()); // 현재 운영체제의 설계 및 운영방식 console.log('os.platform() : ', os.platform()); //운영체제 기..

    Node.JS) Regex(정규 표현식)

    목차 2022.05.04 - [Programming/BACKEND] - Node.JS)05.02-04( expressServer - ORM, SNS서비스 만들기, sequelize, passport 활용(localStrategy), ) 1. 정규 표현식 '정규 표현식'은 '문자표현공식', '문자탐색공식'이라고 부르는 연산식과 같은 분류언어입니다. 전문가가 사용한는 정규표현식은 초보자에게 외계언어와 같은 느낌의 어려운 공식이지만 문자탐색과 스캔에 있어서 강력한 기능을 갖고있어서, 여러 분야에서 많이 사용되고 있습니다. 자바스크립트에서도 많은 '다양한 정규표현식의 적용을 지원'하고 있다. 2. 정규 표현식 사용 방법 2.1. 기본적인 키워드 찾기 string.match(/정규식/); index=12) b =..

    Node.JS ) expressServer - ORM, SNS서비스 만들기, sequelize, passport 활용(localStrategy, kakaoStrategy), bcrypt

    목차 2022.04.29 - [Programming/BACKEND] - Node.JS)04.26( ExpressServer - ORM( sequelize ), 게시판 ) 1. 사전 설정 1.1. npm 모듈 설치 및 환경 설정 npm init (npm 환경 구성) npm i express (express 설치) npm i -D nodemon (nodemon 설치) package.json "start": "nodemon app"로 수정 npm i sequelize sequelize-cli mysql2 sequelize, mysql2 모듈 설치 npx sequelize init (sequelize 환경 구성) /config/config.json 파일 수정 (pw와 db 수정) "password":"admin..

    node-express ) await axios로 router동작 시 주의사항

    목차 1. res.redirct( ), 사용이 불가능하다. 1.1. updateForm.html submit 클릭시 이벤트를 중단시키고, 페이지의 값을 formData에 담아 axios.post( '/boards/update', formData ) 로 보내고 'await'한다. ... 번호 {{board.id}} 작성자 ... 1.2. boards.js updateForm.html의 script 태그에서 넘겨받은 formData를 요리조리 하고, 다음 페이지로 전환시키려고 redirect(B라우터)로 데이터를 전달하려고 한다. // 게시물 수정 router.post('/update', upload.single('image'), async (req,res,next)=>{ try { ... res.redir..

    Node.JS)04.19( Promise, 동기·비동기적 처리 )

    목차 2022.04.20 - [Programming/BACKEND] - Node.JS)04.19( ArrowFunction(화살표 함수) ) 1. Promise 함수와 비슷한 기능을 갖고 있는 객체. 객체 내의 익명함수의 내용을 실행하고, '결과를 보관'하고 있다가, 결과가 필요할 때 전달받아 사용할 수 있게 해주는 구조의 객체. const pm = new Promise( /* 익명함수 */); //promise 객체의 전달인수 없는 선언문. promise 객체는 생성자의 전달인수로 현재 promise객체의 기능을 갖는 '익명함수를 전달하여야 생성'된다. func = (resolve, reject) => { } const pm = new Promise( func ); 또는 const pm = new Pr..

    Node.JS)04.26( ExpressServer - ORM( sequelize ), 게시판 )

    목차 2022.04.25 - [Programming/BACKEND] - Node.JS)04.25( ExpressServer - 라우터 분리, 쿠키/세션 암호화, nunjucks(넌적스)템플릿, ORM( sequelize ) ) 1. ORM ( Object-Relational Mapping ) ORM(Object-Relational Mapping)은 객체지향 패러다임을 활용하여 관계형 데이터베이스(RDB)의 데이터를 조작하게 하는 기술 이를 활용하면 쿼리를 작성하지 않고도 객체의 메서드를 활용하는 것처럼 쿼리 로직을 작성할 수 있다. Sequelizes는 Node.js의 대표적인 ORM Sequelize는 MySQL, PostgreSQL, MariaDB 등 많은 RDBMS를 지원하고 'Promise 기반으..

    Node.JS)04.25( ExpressServer - 라우터 분리, 쿠키/세션 암호화, nunjucks(넌적스)템플릿 )

    목차 2022.04.24 - [Programming/BACKEND] - Node.js)04.22( ExpressServer ( 기초, 라우터, 미들웨어, 추가모듈, 쿠키, 세션( express-session ), multer ) ) 1. 라우터 분리 1.1. routers 폴더 생성 아래 이미지와 같이 폴더와 js파일을 구성한다. 1.1.1. routers/index.js const express = require('express'); // const app = express(); const router = express.Router(); // app.get('/', (req, res)=>{}); router.get('/', (req, res)=>{ res.send("Hello, Express route..

    Node.js)04.22( ExpressServer ( 기초, 라우터, 미들웨어, 추가모듈, 쿠키, 세션( express-session ), multer ) )

    목차 2022.04.22 - [Programming/BACKEND] - Node.JS)04.21(HttpServer, Axios ) 1. ExpressServer Express서버의 다른서버와의 특징 http 모듈 웹서버의 확장판으로 코드 가독성이 좋고 확장성이 뛰어나다. 프레임이 잡혀있어 파일관리 및 운영이 용이하다. 비슷한 서버로서 Koa, Hapi 드이 있지만 Express서버를 가장 많이 사용한다. 코드관리 및 편의성에서 많은 장점을 제공한다.> nodemon의 이점 서버구동 및 운용에 발생한 모든 과정을 로깅으로 보여준다. 에러 수정이 용이하다. 일정 시간이 지나거나 주요파일이 저장되면 서버가 다시 재구동되므로, 수동으로 서버 재시작의 불편함이 없다. package.json Express 서버의..

    Node.JS)04.21(HttpServer, Axios )

    목차 1. HttpServer Node.js에 포함된 기능과 문법을 이용해서 웹호스팅을 할 수 있는 서버를 구축합니다. 1.1. http모듈을 require 서버 구축에 필요한 기능과 함수를 담고있는 'http모듈을 require'한다. // 서버 구축에 필요한 기능과 함수를 담고있는 'http모듈을 require'한다. const http = require('http'); 1.2. createServer( ) Node.js로 만든 http서버를 실행하는 함수. (req, res)=>{ } : 서버로 클라이언트의 요청이 있을 때 실행할 명령들이 들어간다. req, res를 전달받은 익명함수가 클라이언트로부터 들어온 요청에 응답한다. http.createServer( (req, res) => { // re..

    Node.JS)04.19( ArrowFunction(화살표 함수) )

    목차 2022.04.20 - [Programming/BACKEND] - Node.JS)04.19( ObjectArray(객체 배열), 구조 분해, 배열 요소 추출 ) 1. 화살표 함수 1.1. 일반적인 함수의 표현법 1.1.1. 일반적인 함수 표현방법 #1 // 함수의 표현방법 #1 function add1(x, y){ return x+y; } console.log( add1( 10, 20 ) ); // 30 1.1.2. 일반적인 함수 표현방법 #2 // 함수의 표현방법 #2 let add2 = function (x, y){ return x+y; } console.log( add2( 10, 20 ) ); // 30 1.2. 화살표 함수의 표현방법 일반적인 함수 표현법 화살표 함수 표현법 function(..

    Node.JS)04.19( ObjectArray(객체 배열), 구조 분해, 배열 요소 추출 )

    목차 2022.04.20 - [Programming/BACKEND] - Node.JS)04.19( Array(배열) : 배열의 요소 추가/제거 방법 ) 1. ObjectArray 객체 배열 1.1. 객체를 배열의 요소로 추가 function Student(name, korean, math, english, science){ this.name = name; this.kor = korean; this.math = math; this.english = english; this.science = science; this.getSum = function(){ return this.kor + this.math + this.english + this.science; } this.getAvg = function(){ ..