뇌운동일지

AWS Portal 본문

purple duck 일지

AWS Portal

purpleduck 2021. 10. 25. 11:13

AWS SDK for JavaScript (Node.js) 

https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/getting-started-nodejs.html

 

1. keycloak으로 login 하는 것 구현 

Vue.js front에서 받아온 data로 로그인 되는 것 확인

keycloak

axios

vue.js 에서 axios 

https://zetcode.com/javascript/axios/

express

 

.auth() 로 로그인 후, 세션은 어떻게 처리하는지 -> 이건 나중에 한다. 

cookie vs session 

https://hahahoho5915.tistory.com/32

 

2. aws api test

Compute) EC2, EKS

DB) RDS

Network) ELB, RouteTables

ELB

one of your loadbalancers

describeLoadBalancers(params = {}, callback) ⇒ AWS.Request

all of your load balancers

 

Storge) S3

listBuckets(params = {}, callback) ⇒ AWS.Request

getBucketLocation(params = {}, callback) ⇒ AWS.Request

 

Access Key) EC2 Access Key

 

 

RDS

api

https://docs.aws.amazon.com/AmazonRDS/latest/APIReference/API_DescribeDBInstances.html

aws sdk for js : rds

https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/RDS.html

aws sdk for js v3 : rds

https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/clients/client-rds/index.html

 

AWS SDK for JavaScript v3

https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/index.html

 

 

array 형태로 조회해올 component 들의 name을 전달해주어야 하는 것들도 있음 

(ec2 instance 조회를 통해 unique 한 keyName을 가져와서 parameter로 전달하는 방법 생각중)

 

3. mongoDB find, rest api get

api 로 가져온 json 데이터를 mongoDB에 넣는다. 

어디서부터 어디까지 넣을 것인지. 각 api 마다 응답이 다른데 어떻게 처리할 것인지

 

TOBE) mongoDB insert를 method로 구현해서 cron으로 주기적으로 method 호출 

ASIS) 현재 호출 시마다 aws api 조회하여 mongoDB에 insert 후 find 하는 부분까지 구현됨

1. 호출 시마다 전체 delete/insert 하는 기능으로 바꾸고, (나중에는 cron 시점마다 없어진 것은 delete하고 새로 생긴 것은 insert하도록 처리하거나 - 배치를 돌릴 때 어떻게 해야하는지 납득이 안됨)

-> 여기까지 함

2. 그 다음 model 분리, delete/insert 하는 로직 따로 빼고, 호출 시 find만 하도록 바꾼다. 

3. delete 하지 말고, Y/N 값을 넣어줘서 Y인 것만 조회

 

TroubleShooting) 

Error [OverwriteModelError]: Cannot overwrite `S3` model once compiled.

https://nesin.io/blog/fix-mongoose-cannot-overwrite-model-once-compiled-error

 

4. mongoDB update, rest api put

5. cron 적용

 

snapshot 기능 구현할 것인지, -> snapshot 구현할거면 find 시 timestamp 를 보고 해당하는 값만 조회하든 그렇게 해야됨.

 

api에서 읽어온 값과 사용자입력 값은 테이블을 따로 만든다. (userinputSchema)

RDBMS 처럼 두 테이블을 조인하는 방식을 생각했었는데, 

mongoDB에서는 사용자 입력값 embedded 하는 방식을 사용한다고 함. -> embedded documents

skema 안에 skema 를 넣는 방법을 사용

embedded documents 에서 findOneAndUpdate -> findById 를 권장한다는 이야기를 들었다. 

https://stackoverflow.com/questions/60063481/mongoose-findoneandupdate-an-embedded-object-and-return-parent

 

일단은 없으면 insert, 있으면 update 로 하자. -> upsert: true 로 주고, update 만 써도 되는게 아닐까. (new: true) 도 줌. option 주는 거 알아볼 것. 

 

column 명을 명확하게 쓰기 위해서 직접 object를 만들어주는 것이 좋겠다. -> 이건 다음에 반영하자. 

 

frontend - backend 연결 

npm run build 가 필요하다

We're sorry but myaws doesn't work properly without JavaScript enabled. Please enable it to continue. 

devtool 로 network 확인해보니 이런게 나옴. 

https://sbarrys.tistory.com/85

 

jqxGrid field edit 하기 

https://www.jqwidgets.com/vue-components-documentation/documentation/jqxgrid/vue-datagrid-cells-editing.htm?search=jqxgrid 

jqxGrid 에서 선택적으로 celledit 

http://www.guriddo.net/demo/guriddojs/

jqxGrid 안에 button 그리기

https://www.jqwidgets.com/community/topic/making-a-column-of-buttons-and-passing-a-value-to-that-button/

 

vanillaJS .fetch() 사용해서 restapi 통신 

https://www.daleseo.com/js-window-fetch/

그렇게 만든 jqxGrid 내의 button 

        {
          text: "Submit",
          width: "20%",
          cellsrenderer: function editButton(cellvalue, options, rowObject) {
            return `<button onclick='fetch("http://localhost:5000/data/userinputkeypairs", {
              method: "PUT",
              headers: {
                 "Content-Type": "application/json",
              },
              body: JSON.stringify({
                    title: "Test",
                    body: "I am testing!",
                    userId: 1
                  }),
            })
            .then((response) => response.json())
            .then((data) => console.log(data))'
            >Save</button>`
          }
        }

 

columntype: "button" 으로 줘서 만드는 방법 

https://www.jqwidgets.com/community/topic/get-row-data-on-button-click-with-jqgrid-having-dynamic-id/

 

update 시, object 내의 key 값 못가져오는 문제 해결. request.body['object명.key'] 이렇게 직접 가져와서 넣어줌. 

jqxGrid 에 보여줄 때, datafields 로 보여주는 부분이 안되는 중 

 

만약, grid 내 cell 에서 입력이 없을 경우, 공백으로 update 되어야 하는데 되지 않고 있다. 

 

-----------------------------------

1. security group

2. 대용량 비동기 mongoDB crud async

summary 하는 건 elastic 쓰는데 mongoDB도 필요한가?

 

2. backend 프로젝트 구조

express 활용하여 서버 구현

npm install express-generator -g

 

1. npm 
cron
xlsx
aws sdk 
keycloak
mongoDB
axois : front back 간 http restful 통신 

cron 시간 입력 어떻게 받을까. 
조건) parameter 는 min 하나만 받음. 
60분(정각)마다, 30분마다, 10분마다,
parameter 전달 시간에 바로 처리? 특정 기준 시간부터 처리 
comboBox로 입력 가능한 분을 정해주는게 좋겠다. 

 

참고) 

docker 컨테이너명 변경

$ docker rename [old] [new]

 

git 명령어에 대한 설명 

https://programmingsummaries.tistory.com/366

'purple duck 일지' 카테고리의 다른 글

Vue.js bootstrap  (0) 2021.11.11
Vue.js search, PrimeVue, sequelize, sequelize-auto  (0) 2021.11.01
keycloak  (0) 2021.10.21
ansible  (0) 2021.10.20
window 환경의 docker 에서 centOS7 image pull  (0) 2021.10.20
Comments