Programming/node.js2018. 10. 16. 19:15

node.js에서 url로 데이터를 받는 방법에 대한 글


/api/value 나

/api?key=value 나

POST header로 받는 법이 있음


[링크 : https://scotch.io/tutorials/use-expressjs-to-get-url-and-post-parameters]


(req.params) Checks route params, ex: /user/:id

(req.query) Checks query string params, ex: ?id=12 Checks urlencoded body params

(req.body), ex: id=12 To utilize urlencoded request bodies, req.body should be an object. This can be done by using the _express.bodyParser middleware. 

[링크 : https://stackoverflow.com/.../how-to-get-get-query-string-variables-in-express-js-on-node-js]

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

node spawn args  (0) 2018.10.17
node post header max size  (0) 2018.10.16
node.js spawn 과 exec  (0) 2018.10.16
node tmp uuid  (0) 2018.10.12
node.js mysql PROTOCOL_ENQUEUE_AFTER_FATAL_ERROR 에러  (0) 2018.10.11
Posted by 구차니
Programming/node.js2018. 10. 16. 18:56

실행하는 것에는 child-process 하위의

exec와 spawn이 있는데 exec는 버퍼를 돌려주고 spawn은 스트림을 돌려준다고 한다.

그런 이유로 dir /s와 같이 미친듯한 용량의 데이터를 뿜어주는 애를

exec로 실행할 경우 금세 200KB 버퍼 용량이 차서 node가 뻗어 버리게 된다.


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

[링크 : https://stackoverflow.com/questions/10232192/exec-display-stdout-live]


kill

[링크 : https://stackoverflow.com/questions/18275809/kill-all-child-process-when-node-process-is-killed]


exec buffer 200kb

[링크 : http://ohgyun.com/453]

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

node post header max size  (0) 2018.10.16
node url parametet  (0) 2018.10.16
node tmp uuid  (0) 2018.10.12
node.js mysql PROTOCOL_ENQUEUE_AFTER_FATAL_ERROR 에러  (0) 2018.10.11
node.js 정적 파일 서비스  (0) 2018.10.10
Posted by 구차니
Programming/node.js2018. 10. 12. 19:21

cropper.js 써보다 보니 uuid로 업로드된 파일이 변경되길래

먼가하고 찾는데 딱히 그걸 지원하는 무언가는 없는 듯?



[링크 : https://www.npmjs.com/package/tmp]

[링크 : https://www.npmjs.com/package/uuid]

   [링크 : https://fengyuanchen.github.io/cropperjs/]

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

node url parametet  (0) 2018.10.16
node.js spawn 과 exec  (0) 2018.10.16
node.js mysql PROTOCOL_ENQUEUE_AFTER_FATAL_ERROR 에러  (0) 2018.10.11
node.js 정적 파일 서비스  (0) 2018.10.10
waveform 출력하는 자바스크립트 모듈  (0) 2018.10.05
Posted by 구차니
Programming/node.js2018. 10. 11. 13:35

명확한 원인과 해결방법은 아직 못 찾음

mac과 centos에서 node.js를 통해 mysql 접속시 장시간 지난후

이런 에러가 발생을 하는데 mysql 쪽 세션 timeout 이 원인으로 추정됨


{"code":"PROTOCOL_ENQUEUE_AFTER_FATAL_ERROR","fatal":false} 


[링크 : https://stackoverflow.com/.../node-js-mysql-protocol-enqueue-after-fatal-error]

[링크 : https://stackoverflow.com/...mac-and-have-an-error-occurred-when-deploying-on-centos]



+

일정 주기로 쓸모없는 쿼리문 보내도록 해주는 미봉책

[링크 : http://nashorn.tistory.com/entry/Nodejs-서버-운영시-발생하는-오류-대응]

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

node.js spawn 과 exec  (0) 2018.10.16
node tmp uuid  (0) 2018.10.12
node.js 정적 파일 서비스  (0) 2018.10.10
waveform 출력하는 자바스크립트 모듈  (0) 2018.10.05
xz로 압축된 node.js 설치하기  (0) 2018.10.02
Posted by 구차니
Programming/node.js2018. 10. 10. 16:40

/static 아래에서는 /public으로 연결해서 자유롭게 파일을 직접 액세스 하도록 해주는 기능



app.use('/static', express.static('public')); 

[링크 : http://expressjs.com/en/starter/static-files.html]

[링크 : http://expressjs.com/ko/starter/static-files.html]

[링크 : http://infodbbase.tistory.com/40]

[링크 : https://opentutorials.org/course/2136/11857]

Posted by 구차니
Programming/node.js2018. 10. 5. 19:25

canvas를 이용해서 waveform을 그려주는 녀석인.. 듯?

아무튼 파형 확대/축소도 가능하고

이퀄라이저도 포함되는 녀석이라 한번 써볼만 할 듯


[링크 : https://wavesurfer-js.org]

Posted by 구차니
Programming/node.js2018. 10. 2. 23:04

라즈베리 구버전을 써서 node.js가 0.10 버전대라

배포판 업그레이드 하거나 밀긴 귀찮아서

node.js arm 용으로 빌드된 걸 받아서 설치해보는데


rpi 2b니까 ARMv7용으로 받고

압축을 풀어서 bin과 lib를 /bin과 /lib로 복사해도 되고

[링크 : https://nodejs.org/ko/download/]


아래와 같이 -C / 이런 옵션을 주고 / 에다가 압축을 풀게 하는 것도 방법일 듯

tar Jxf --strip=1 -C /usr/local node-v4.4.0-linux-x64.tar.xz 

[링크 : https://stackoverflow.com/.../how-to-install-node-linux-binaries-tar-xz-file-in-ubuntu-14-04]

Posted by 구차니
Programming/node.js2018. 9. 27. 23:04

집에서는 잘 안하긴 했지만.. 회사에서도 윈도우인데 잘 돌아갔는데..

왜 안되나 해서 찾아보니.. 파이썬이 없어서 그런건가?


D:\work\node>npm install http-request


> mmmagic@0.5.1 install D:\work\node\node_modules\mmmagic

> node-gyp rebuild



D:\work\node\node_modules\mmmagic>if not defined npm_config_node_gyp (node "C:\P

rogram Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin\\..

\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else (node "C:\Program Fil

es\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" rebuild )

gyp ERR! configure error

gyp ERR! stack Error: Can't find Python executable "python", you can set the PYT

HON env variable.

gyp ERR! stack     at PythonFinder.failNoPython (C:\Program Files\nodejs\node_mo

dules\npm\node_modules\node-gyp\lib\configure.js:484:19)

gyp ERR! stack     at PythonFinder.<anonymous> (C:\Program Files\nodejs\node_mod

ules\npm\node_modules\node-gyp\lib\configure.js:509:16)

gyp ERR! stack     at C:\Program Files\nodejs\node_modules\npm\node_modules\grac

eful-fs\polyfills.js:284:29

gyp ERR! stack     at FSReqWrap.oncomplete (fs.js:152:21)

gyp ERR! System Windows_NT 6.1.7601

gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodej

s\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"

gyp ERR! cwd D:\work\node\node_modules\mmmagic

gyp ERR! node -v v8.12.0

gyp ERR! node-gyp -v v3.8.0

gyp ERR! not ok

npm WARN cancer@1.0.0 No description

npm WARN cancer@1.0.0 No repository field.


npm ERR! code ELIFECYCLE

npm ERR! errno 1

npm ERR! mmmagic@0.5.1 install: `node-gyp rebuild`

npm ERR! Exit status 1

npm ERR!

npm ERR! Failed at the mmmagic@0.5.1 install script.

npm ERR! This is probably not a problem with npm. There is likely additional log

ging output above.


npm ERR! A complete log of this run can be found in:

npm ERR!     C:\Users\user\AppData\Roaming\npm-cache\_logs\2018-09-27T13_58_50

_212Z-debug.log 


하는데 드럽게 오래걸리네...

근데 회사는 윈10이라 그런건가.. 무슨 차이지?

(관리자 권한으로 아래는 실행해야 함)

npm install --global --production windows-build-tools

npm install --global node-gyp 

[링크 : https://code.i-harness.com/ko-kr/q/e6ce22]

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

waveform 출력하는 자바스크립트 모듈  (0) 2018.10.05
xz로 압축된 node.js 설치하기  (0) 2018.10.02
node.js 를 이용한 HTML 데이터 추출(크롤링)  (4) 2018.09.27
npm audit  (0) 2018.09.19
promise-mysql  (0) 2018.09.18
Posted by 구차니
Programming/node.js2018. 9. 27. 19:05
Programming/node.js2018. 9. 19. 12:25

회사에서 설치할때는 별 소리 없더니

집에와서 설치하려고 하니 먼가 경고가 뿜뿜한다 -_-

결론만 말하자면, 저거 경고일뿐 일단 설치는 된거니 무시해도 된다 정도?


$ npm install

added 150 packages from 251 contributors and audited 305 packages in 12.634s

found 2 vulnerabilities (1 low, 1 moderate)

  run `npm audit fix` to fix them, or `npm audit` for details


$ npm audit fix

+ mysql@2.16.0

added 4 packages from 8 contributors, removed 1 package and updated 5 packages i

fixed 1 of 2 vulnerabilities in 305 scanned packages

  1 vulnerability required manual review and could not be updated


$ npm audit

=== npm audit security report ===



                                 Manual Review

             Some vulnerabilities require your attention to resolve


          Visit https://go.npm.me/audit-guide for additional guidance



  Low             Regular Expression Denial of Service


  Package         debug


  Patched in      >= 2.6.9 < 3.0.0 || >= 3.1.0


  Dependency of   node-rest-client


  Path            node-rest-client > debug


  More info       https://nodesecurity.io/advisories/534


found 1 low severity vulnerability in 310 scanned packages

  1 vulnerability requires manual review. See the full report for details.



$ npm install --no-audit

up to date in 0.912s 


[링크 : https://blog.outsider.ne.kr/1375]

Posted by 구차니