'Programming'에 해당되는 글 1786건

  1. 2020.01.29 es6 전개문구 (...)
  2. 2020.01.29 node.js 객체 합치기
  3. 2020.01.29 unserscore 라이브러리
  4. 2020.01.23 node.js 집합연산
  5. 2020.01.20 node.js promise
  6. 2020.01.19 node.js cookie 관련 함수들
  7. 2020.01.19 node.js crypto 모듈
  8. 2020.01.15 java oop 개념
  9. 2020.01.15 tomcat war 정적 웹페이지
  10. 2020.01.15 spring 다시 시작
Programming/node.js2020. 1. 29. 17:45

... 은 es6부터 추가된 문법으로

배열을 풀어서 인자로 만들어 주는 듯

 

function sum(x, y, z) {
  return x + y + z;
}

const numbers = [1, 2, 3];

console.log(sum(...numbers));
// expected output: 6

[링크 : https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Operators/Spread_syntax]

[링크 : https://2ality.com/2015/01/es6-set-operations.html]

'Programming > node.js' 카테고리의 다른 글

node.js postgresql transaction  (0) 2020.01.31
for 에서 async, await  (0) 2020.01.30
node.js 객체 합치기  (0) 2020.01.29
unserscore 라이브러리  (0) 2020.01.29
node.js 집합연산  (0) 2020.01.23
Posted by 구차니
Programming/node.js2020. 1. 29. 17:05

assign()을 쓰면 가능은 한데..

동일 이름일 경우에는 어떻게 해야할까?

 

[링크 : https://4urdev.tistory.com/22]

+

키 이름을 미리 바꾸고 합치면 되려나?

[링크 : https://www.freecodecamp.org/news/30-seconds-of-code-rename-many-object-keys-in-javascript-268f279c7bfa/]

'Programming > node.js' 카테고리의 다른 글

for 에서 async, await  (0) 2020.01.30
es6 전개문구 (...)  (0) 2020.01.29
unserscore 라이브러리  (0) 2020.01.29
node.js 집합연산  (0) 2020.01.23
node.js promise  (0) 2020.01.20
Posted by 구차니
Programming/node.js2020. 1. 29. 13:29

node.js 에서 사용할수 있는 라이브러리.

객체등을 uniq하게 정렬해줄수 있다는데

정작해보니.. 키에 따라서 정리만 해주는 정도?

 

[링크 : https://ddalpange.github.io/2017/10/10/js-not-duplicated-object-array/]

[링크 : http://underscorejs.org/]

[링크 : https://harrythegreat.tistory.com/entry/언더스코어-정리]

 

+

함수로 정리하는 내용

[링크 : https://gamblecoder.tistory.com/29]

 

'Programming > node.js' 카테고리의 다른 글

es6 전개문구 (...)  (0) 2020.01.29
node.js 객체 합치기  (0) 2020.01.29
node.js 집합연산  (0) 2020.01.23
node.js promise  (0) 2020.01.20
node.js cookie 관련 함수들  (0) 2020.01.19
Posted by 구차니
Programming/node.js2020. 1. 23. 19:32

array와 set을 통해서 집합 연산을 할 수 있다.

단.. 2개의 집합에 대해서는 용이한데 3개의 집합에 대한 교집합 은 쉽지 않고

객체에 대해서 하려면 이래저래 손이 많이 갈 듯..

 

3개의 집합에 대해서 항목별로 계산하려면

최소 7가지 정보가 필요한데

 

[링크 : https://zetawiki.com/wiki/JavaScript_합집합,_교집합,_차집합,_대칭차]

'Programming > node.js' 카테고리의 다른 글

node.js 객체 합치기  (0) 2020.01.29
unserscore 라이브러리  (0) 2020.01.29
node.js promise  (0) 2020.01.20
node.js cookie 관련 함수들  (0) 2020.01.19
node.js crypto 모듈  (0) 2020.01.19
Posted by 구차니
Programming/node.js2020. 1. 20. 16:10

promise는 비동기 작업을 동기작업으로 바꿀수(?)있는 마법의 키워드 이다.

아래와 같이 new promise를 통해서 만들어 주고

return new promise((resolve, reject) => {

// 비동기 작업

// 비동기 작업의 리턴값 (정상)

   resolve(value);

// 비동기 작업 비정상 종료시 리턴값

   reject(value);

})

 

3개의 비동기 작업이 모두 종료되고 그 값을 이용해 무언가를 하려면

promise.all로 구현을 해주고 값을 하나로 합쳐주면 된다.

Promise.all([worker1, worker2, worker3])

.then([value1, value2, value3]) => {

return ({value1, value2, value3})

 

 

[링크 : https://programmingsummaries.tistory.com/325]

[링크 : https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Global_Objects/Promise/all]

[링크 : https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Global_Objects/Promise]

 

구조 분해 할당

[링크 : https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment]

'Programming > node.js' 카테고리의 다른 글

unserscore 라이브러리  (0) 2020.01.29
node.js 집합연산  (0) 2020.01.23
node.js cookie 관련 함수들  (0) 2020.01.19
node.js crypto 모듈  (0) 2020.01.19
node.js xpath 그리고 boolean  (0) 2019.12.17
Posted by 구차니
Programming/node.js2020. 1. 19. 17:17

쿠키를 삭제한다. 단 삭제만 하고 어떠한 응답을 주는것이 아니기에

redirection 등을 추가로 해주어야 클라이언트에서 작동을 인식한다.

res.clearCookie(name [, options])
Clears the cookie specified by name. For details about the options object, see res.cookie().

Web browsers and other compliant clients will only clear the cookie if the given options is identical to those given to res.cookie(), excluding expires and maxAge.

res.cookie('name', 'tobi', { path: '/admin' })
res.clearCookie('name', { path: '/admin' })

[링크 : https://expressjs.com/ko/api.html]

[링크 : https://victorydntmd.tistory.com/35]

 

 

아래 블로그의 path는 optional 이기에 굳이 넣어주지 않아도 된다.

app.get('/logout', function(req,res) {
    res.clearCookie(key);
});

 

app.get('/logout', function(req,res) {
    res.clearCookie(key, {path:'/path'});
});

[링크 : https://kwanghyuk.tistory.com/90]

'Programming > node.js' 카테고리의 다른 글

node.js 집합연산  (0) 2020.01.23
node.js promise  (0) 2020.01.20
node.js crypto 모듈  (0) 2020.01.19
node.js xpath 그리고 boolean  (0) 2019.12.17
node.js JWT with refresh token  (0) 2019.12.10
Posted by 구차니
Programming/node.js2020. 1. 19. 16:42

DB에서 하는거나 was에서 하는거랑 좀 차이가 있다면 있을수 있지만

postgresql의 경우 crypto 모듈을 설치해야 하는 문장 하나를 관리해줘야 하니

보안상 문제나 구조적 문제가 없다면 WAS에서 처리하는 것도 나쁘진 않다는 생각이 든다.

 

crypto 모듈은 기본 모듈이라 npm install을 해주지 않아도 된다.

const crypto = require('crypto');

const secret = 'abcdefg';
const hash = crypto.createHmac('sha256', secret)
                   .update('I love cupcakes')
                   .digest('hex');
console.log(hash);
// Prints:
//   c0fa1bc00531bd78ef38c628449c5102aeabd49b5dc3a2a516ea6ea959d6658e

 

[링크 : https://nodejs.org/api/crypto.html]

 

+

[링크 : https://victorydntmd.tistory.com/33]

'Programming > node.js' 카테고리의 다른 글

node.js promise  (0) 2020.01.20
node.js cookie 관련 함수들  (0) 2020.01.19
node.js xpath 그리고 boolean  (0) 2019.12.17
node.js JWT with refresh token  (0) 2019.12.10
node.js synchornous file write  (0) 2019.11.06
Posted by 구차니
Programming/Java2020. 1. 15. 13:01

개념은 대충 알았지만.. 시대가 바뀌어서 그런가..

예전의 맨날 돌리고 돌리는 orbit 보다는 구체화된 예로 이해하기가 쉬운 시대가 되었네.

 

[링크 : https://gmlwjd9405.github.io/2018/07/05/oop-features.html]

[링크 : https://gmlwjd9405.github.io/2018/07/05/oop-solid.html]

'Programming > Java' 카테고리의 다른 글

java 람다, 클로저  (0) 2025.01.31
자바 annotation  (0) 2020.06.16
java cipher  (0) 2019.11.25
jaxb - Java Architecture for XML Binding  (0) 2019.06.25
jar 실행하기  (0) 2019.01.15
Posted by 구차니
Programming/jsp2020. 1. 15. 12:31

java/tomcat 으로 서버 호스팅 하는데도 많으니

정적웹을 java/tomcat으로 war 파일을 통해 deploy 가능하겠다 싶어서 검색

 

[링크 : https://10apps.tistory.com/118]

Posted by 구차니
Programming/Java(Spring)2020. 1. 15. 10:50

JDK 설치

$ sudo apt install openjdk-8-jdk

[링크 : https://daddyprogrammer.org/post/2062/openjdk-install-update-delete/]

 

예제 spring 프로젝트 다운로드(git)

$ git clone https://github.com/spring-guides/gs-rest-service.git

$ cd gs-rest-service/initial

$ ./gradlew bootRun

[링크 : https://spring.io/guides/gs/rest-service/]

 

http://localhost:8080/greeting

외부에서 접근하려면 ip로 바꾸고 8080 포트로 접속하면 된다.

다만.. 위에서 bootRun으로 했기 수정없이 실행했기에 greeting이 아직 생성되지 않아 접근이 되지 않는다.

gs-rest-service/initial/src/main/java/com/example/restservice/Greeting.java

package com.example.restservice;

public class Greeting {

private final long id;
private final String content;

public Greeting(long id, String content) {
this.id = id;
this.content = content;
}

public long getId() {
return id;
}

public String getContent() {
return content;
}
}

 

gs-rest-service/initial/src/main/java/com/example/restservice/GreetingController.java

package com.example.restservice;

import java.util.concurrent.atomic.AtomicLong;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class GreetingController {

private static final String template = "Hello, %s!";
private final AtomicLong counter = new AtomicLong();

@GetMapping("/greeting")
public Greeting greeting(@RequestParam(value = "name", defaultValue = "World") String name) {
return new Greeting(counter.incrementAndGet(), String.format(template, name));
}
}

+

위에서 GetMapping으로 greeting일 경우에

Parameter 이기에 greeting?name= 형식으로 값을 받되, 값이 없으면 기본값을 World로 지정해 주는 것으로 보인다.

@로 시작하는 annotation들은 조금 공부가 필요 할 듯 하다.

 

 

이렇게 파일 두개 추가해주고 gs-rest-service/initial 디렉토리로 돌아와

gradlew bootRun을 실행후

http://localhost:8080/greeting

http://localhost:8080/greeting?name=User

을 접속하면 15분(?) 강좌 끝

 

+

gradlwe bootRun은

gradle 도움말에 안나오는 걸 봐서는 spring boot 에서 추가된 taskName으로 추정된다.

[링크 : https://docs.gradle.org/current/userguide/command_line_interface.html]

 

+

[링크 : https://spring.io/guides/gs/spring-boot/] spring boot

[링크 : https://spring.io/guides/gs/accessing-data-rest/] JPA

[링크 : https://spring.io/guides/gs/accessing-data-mysql/] MYSQL

Posted by 구차니