Module

Younghwan Cha·2021년 9월 30일
0

Express.js

목록 보기
2/4

Node.js

fs

var fs = require('fs')

Common use for the File System module:

fs.readdir

fs.readdir(path[, options], callback)

  • Read files
  • Create files
  • Update files

fs.unlink(path, callback)

  • Delete files

fs.rename

fs.rename(oldPath, newPath, callback)

  • Rename files

var sanitizeHTML = require('sanitize-html');
** sanitize : 소독하다

외부에서

<script>코드기술</script>

과 같이 악성스크립트를 집어넣는 것을 방어하기위한 node 의 패키지 모듈

path

const path = require('path')

Path 모듈은 파일과 Directory 경로 작업을 위한 Utility를 제공한다.

path.parse('C:\\path\\dir\\file.txt');
// Returns:
// { root: 'C:\\',
//   dir: 'C:\\path\\dir',
//   base: 'file.txt',
//   ext: '.txt',
//   name: 'file' }

┌─────────────────────┬────────────┐
│          dir       │   base   │
├──────┬             ├──────┬─────┤
│ root │            │ name │ ext │
" C:\    path\dir   \ file  .txt "
└──────┴──────────────┴──────┴─────┘

request

request.on('data')

on method binds an event to a object

request.on('end')

end method simply finishes sending the request

request.params

변수를 반환한다.
Route path: /users/:userId/books/:bookId
Request URL: http://localhost:3000/users/34/books/8989
req.params: { "userId": "34", "bookId": "8989" }

response

response.writeHead

response.writeHead(statusCode[,statusMessage][,headers])

response.redirect

response.redirect(url, [,status]);

Sends a response header to the request
profile
개발 기록

0개의 댓글