본문 바로가기

반응형

웹프로그래밍/node.js & Typescript

(20)
[node.js] adding .css file to ejs Your problem is not actually specific to ejs. 2 things to note here style.css is an external css file. So you dont need style tags inside that file. It should only contain the css. In your express app, you have to mention the public directory from which you are serving the static files. Like css/js/image it can be done byapp.use(express.static(__dirname + '/public')); assuming you put the css fi..
[node.js] Unable to include relative path file using Jade Template
[node.js] socket set() get() depracated! (socket.io) 기존의 get() set() 은 없어졌고, socket object 에다가 직접 넣어서 쓰면 된다. var http = require('http');var socketio = require('socket.io'); var server = http.createServer();var io = socketio.listen(server);io.sockets.on('connection', function(socket){//기존에 io.set('name') 이랫던거를... socket.on('setname', function(data){socket.name = data;});});
[node.js] How to use layout.ejs in Express 4
[node.js] How to get POST a query in Express.js/Node.js?
[node.js] How to access the GET parameters in Express.js or Node.js? /?parameter="test" 기존 request.param("parameter") 에서... 아래와 같이 업데이트됨; var app = express(); app.post 일때, request.body.parameter app.get 일때, request.params.parameter 어떤 방식으로 값이 들어오는지 보려면 console.log(request.params); console.log(request.body); console.log(request.query); 를 찍어보자.. 또한 app.use(bodyParser.urlencoded({ extended: true })); bodyParser 가 urlencoded 로 되어 있어야된다. JSON으로 되있을 경우 JSON 형식만 읽어오기떄문에..
[node.js] Most middleware (like logger) is no longer bundled with Express and must be installed separately... 『모던 웹을 위한 Node.js 프로그래밍』보면서 차근히 따라하고 있는데.. express에서 미들웨어 사용하다가 난관에 부딪혔다. logger 쓰려고 했더니, 에러가 빡!! 미들웨어가 더이상 번들로 설치되어 있는 게 아니니 따로 설치하란다. 이게 뭔...? 또다시 구글링... 구글링구글구긆릉르르르ㅏ르르르르 http://stackoverflow.com/questions/23526356/heroku-node-js-server-crash-with-error-most-middleware-like-logger-is-no-lo ↑ 이 사람 글을 보니, 2가지 방법이 있댄다. logger 대신에 morgan을 설치해서 사용하든가, express가 설치된 폴더 안에서 package.json 파일을 찾아서 expres..
[node.js] express cookie-parser Installation $ npm install cookie-parser API var express = require('express') var cookieParser = require('cookie-parser') var app = express() app.use(cookieParser()) cookieParser(secret, options) secret a string used for signing cookies. This is optional and if not specified, will not parse signed cookies. options an object that is passed to cookie.parse as the second option. See cookie for more..

반응형