Page 225 - Nodejs 교과서 개정2판
P. 225

ਬ૑ೞҊ र׮ݶ req ё୓ী ؘ੉ఠܳ ֍যفݶ ؾפ׮




           app.use((req,	res,	next)	=>	{
           		req.data	=	'데이터	넣기';
           		next();
           },	(req,	res,	next)	=>	{
           		console.log(req.data);	//	데이터	받기
           		next();
           });




         അ੤ ਃ୒੉ ୊ܻغח زউ req.dataܳ ా೧ ޷ٜਝয рী ؘ੉ఠܳ ҕਬೡ ࣻ ੓णפ׮  ࢜۽਍ ਃ୒੉ য়ݶ r

         eq.dataח ୡӝചؾפ׮  ࣘࢿݺ੉ ԙ dataੌ ೙ਃח হ૑݅ ׮ܲ ޷ٜਝয৬ Ҁ஖૑ ঋѱ ઑब೧ঠ ೤פ׮  ৘
         ܳ ٜয ࣘࢿݺਸ body۽ ೠ׮ݶ SFR CPEZ  CPEZ QBSTFS ޷ٜਝয৬ ӝמ੉ Ҁ஖ѱ ؾפ׮



           /PUF ™ BQQ TFUҗ੄ ର੉

           app.setਵ۽ ੊झ೐ۨझীࢲ ؘ੉ఠܳ ੷੢ೡ ࣻ ੓׮ח Ѫਸ ߓਛणפ׮  app.get ژח req.app.getਵ۽ য٣ࢲٚ૑ ؘ੉
           ఠܳ оઉৢ ࣻ ੓णפ׮  ೞ૑݅ app.setਸ ࢎਊೞ૑ ঋҊ req ё୓ী ؘ੉ఠܳ ֍যࢲ ׮਺ ޷ٜਝয۽ ੹׳ೞח ੉ਬо ੓

           णפ׮  app.set਷ ੊झ೐ۨझীࢲ ੹৉੸ਵ۽ ࢎਊغ޲۽ ࢎਊ੗ ѐѐੋ੄ чਸ ֍ӝীח ࠗ੸੺ೞݴ  জ ੹୓੄ ࢸ੿ਸ ҕ
           ਬೡ ٸ ࢎਊೞݶ ؾפ׮

           req ё୓ח ਃ୒ਸ ࠁմ ࢎਊ੗ ѐѐੋীѱ ӈࣘغ޲۽ req ё୓ܳ ా೧ ѐੋ੄ ؘ੉ఠܳ ੹׳ೞח Ѫ੉ જणפ׮




         ޷ٜਝযܳ ࢎਊೡ ٸ ਬਊೠ ಁఢ ೠ о૑ܳ ࣗѐ೤פ׮  ޷ٜਝয উী ޷ٜਝযܳ ֍ח ߑधੑפ׮  ׮਺ ৘
         ઁ੄ ف ߑध਷ э਷ ӝמਸ ೤פ׮





           app.use(morgan('dev'));
           //	또는
           app.use((req,	res,	next)	=>	{
           		morgan('dev')(req,	res,	next);
           });



         ੉ ಁఢ੉ ਬਊೠ ੉ਬח ӝઓ ޷ٜਝয੄ ӝמਸ ഛ੢ೡ ࣻ ੓ӝ ٸޙੑפ׮  ৘ܳ ٜয ׮਺җ э੉ ࠙ӝ ୊ܻ

         ܳ ೡ ࣻب ੓णפ׮  ઑѤޙী ٮۄ ׮ܲ ޷ٜਝযܳ ੸ਊೞח ௏٘ੑפ׮




           app.use((req,	res,	next)	=>	{
           		if	(process.env.NODE_ENV	===	'production')	{
           				morgan('combined')(req,	res,	next);
   220   221   222   223   224   225   226   227   228   229   230