Toggle navigation
Toggle navigation
This project
Loading...
Sign in
진성욱
/
OSS
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Network
Create a new issue
Commits
Issue Boards
Authored by
Dexter Jin
2020-02-03 15:48:08 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
ae141bcc740614bee6a4180fbfc04d3acacfc3be
ae141bcc
1 parent
14327d13
Rename
Hide whitespace changes
Inline
Side-by-side
Showing
38 changed files
with
0 additions
and
202 deletions
Experiments/experiments08/Assignments/01/app.js
Experiments/experiments08/Assignments/01/mymodule.js
Experiments/experiments08/Assignments/02/consumer.js
Experiments/experiments08/Assignments/02/producer.js
Experiments/experiments08/Tutorial/event01/app.js
Experiments/experiments08/Tutorial/event02/app.js
Experiments/experiments08/Tutorial/mymodule/app.js
Experiments/experiments08/Tutorial/mymodule/mymodule.js
Experiments/experiments09/tutorials/approute/app.js → Experiments/experiments08/tutorials/approute/app.js
Experiments/experiments09/tutorials/approute/package.json → Experiments/experiments08/tutorials/approute/package.json
Experiments/experiments09/tutorials/expressrouter/app.js → Experiments/experiments08/tutorials/expressrouter/app.js
Experiments/experiments09/tutorials/expressrouter/birds.js → Experiments/experiments08/tutorials/expressrouter/birds.js
Experiments/experiments09/tutorials/expressrouter/package.json → Experiments/experiments08/tutorials/expressrouter/package.json
Experiments/experiments09/tutorials/helloworld/app.js → Experiments/experiments08/tutorials/helloworld/app.js
Experiments/experiments09/tutorials/helloworld/package.json → Experiments/experiments08/tutorials/helloworld/package.json
Experiments/experiments09/tutorials/multiplehandler/app.js → Experiments/experiments08/tutorials/multiplehandler/app.js
Experiments/experiments09/tutorials/multiplehandler/package.json → Experiments/experiments08/tutorials/multiplehandler/package.json
Experiments/experiments09/tutorials/render/app.js → Experiments/experiments08/tutorials/render/app.js
Experiments/experiments09/tutorials/render/package.json → Experiments/experiments08/tutorials/render/package.json
Experiments/experiments09/tutorials/render/views/index.ejs → Experiments/experiments08/tutorials/render/views/index.ejs
Experiments/experiments09/tutorials/routeparameter/app.js → Experiments/experiments08/tutorials/routeparameter/app.js
Experiments/experiments09/tutorials/routeparameter/package.json → Experiments/experiments08/tutorials/routeparameter/package.json
Experiments/experiments09/tutorials/routingpath/app.js → Experiments/experiments08/tutorials/routingpath/app.js
Experiments/experiments09/tutorials/routingpath/package.json → Experiments/experiments08/tutorials/routingpath/package.json
Experiments/experiments09/tutorials/session/app.js → Experiments/experiments08/tutorials/session/app.js
Experiments/experiments09/tutorials/session/package.json → Experiments/experiments08/tutorials/session/package.json
Experiments/experiments09/tutorials/simplerouting/app.js → Experiments/experiments08/tutorials/simplerouting/app.js
Experiments/experiments09/tutorials/simplerouting/package.json → Experiments/experiments08/tutorials/simplerouting/package.json
Experiments/experiments09/tutorials/specialrouting/app.js → Experiments/experiments08/tutorials/specialrouting/app.js
Experiments/experiments09/tutorials/specialrouting/package.json → Experiments/experiments08/tutorials/specialrouting/package.json
Experiments/experiments09/tutorials/staticfiles/app.js → Experiments/experiments08/tutorials/staticfiles/app.js
Experiments/experiments09/tutorials/staticfiles/package.json → Experiments/experiments08/tutorials/staticfiles/package.json
Experiments/experiments09/tutorials/staticfiles/public/icon.png → Experiments/experiments08/tutorials/staticfiles/public/icon.png
Experiments/experiments09/tutorials/staticfiles/public/index.html → Experiments/experiments08/tutorials/staticfiles/public/index.html
Experiments/experiments09/assignments/assignment01/app.js
Experiments/experiments09/assignments/assignment01/package.json
Experiments/experiments09/assignments/assignment02/app.js
Experiments/experiments09/assignments/assignment02/package.json
Experiments/experiments08/Assignments/01/app.js
deleted
100644 → 0
View file @
14327d1
// mymodule.js에 정의된 모듈로 불러서 사용하도록 처리
Experiments/experiments08/Assignments/01/mymodule.js
deleted
100644 → 0
View file @
14327d1
// 아래 2개의 함수를 모듈로 정의하는 것이 필요함
function
add
(
a
,
b
)
{
return
a
+
b
;
}
function
sub
(
a
,
b
)
{
return
a
-
b
;
}
Experiments/experiments08/Assignments/02/consumer.js
deleted
100644 → 0
View file @
14327d1
var
Producer
=
require
(
'./producer'
);
var
producer
=
new
Producer
();
producer
.
on
(
'add'
,
function
(
t
)
{
console
.
log
(
'add:'
,
t
);
});
producer
.
start
();
Experiments/experiments08/Assignments/02/producer.js
deleted
100644 → 0
View file @
14327d1
var
inherits
=
require
(
'util'
).
inherits
;
var
EventEmitter
=
require
(
'events'
).
EventEmitter
;
var
Producer
=
function
()
{
if
(
!
(
this
instanceof
Producer
))
return
new
Producer
();
EventEmitter
.
call
(
this
);
}
// inherits를 활용하여 Producer construct가 EventEmitter Construct를 상속받도록 해야 함
inherits
(
Producer
,
EventEmitter
);
// producer의 start 함수를 재정의 해야 함
Producer
.
prototype
.
start
=
function
()
{
// Random 스트링을 생성하여 이것을 Event에 실어서 보내야 하는 코드 작성
}
module
.
exports
=
Producer
;
Experiments/experiments08/Tutorial/event01/app.js
deleted
100644 → 0
View file @
14327d1
var
events
=
require
(
'events'
);
var
eventEmitter
=
new
events
.
EventEmitter
();
var
connectHandler
=
function
connected
()
{
console
.
log
(
'connection successful.'
);
eventEmitter
.
emit
(
'data_received'
);
}
eventEmitter
.
on
(
'connection'
,
connectHandler
);
eventEmitter
.
on
(
'data_received'
,
function
(){
console
.
log
(
'data received successfully.'
);
});
eventEmitter
.
emit
(
'connection'
);
console
.
log
(
"Program Ended."
);
Experiments/experiments08/Tutorial/event02/app.js
deleted
100644 → 0
View file @
14327d1
var
events
=
require
(
'events'
);
var
eventEmitter
=
new
events
.
EventEmitter
();
var
listner1
=
function
listner1
()
{
console
.
log
(
'listner1 executed.'
);
}
var
listner2
=
function
listner2
()
{
console
.
log
(
'listner2 executed.'
);
}
eventEmitter
.
addListener
(
'connection'
,
listner1
);
eventEmitter
.
on
(
'connection'
,
listner2
);
var
eventListeners
=
require
(
'events'
).
EventEmitter
.
listenerCount
(
eventEmitter
,
'connection'
);
console
.
log
(
eventListeners
+
" Listner(s) listening to connection event"
);
eventEmitter
.
emit
(
'connection'
);
eventEmitter
.
removeListener
(
'connection'
,
listner1
);
console
.
log
(
"Listner1 will not listen now."
);
eventEmitter
.
emit
(
'connection'
);
eventListeners
=
require
(
'events'
).
EventEmitter
.
listenerCount
(
eventEmitter
,
'connection'
);
console
.
log
(
eventListeners
+
" Listner(s) listening to connection event"
);
console
.
log
(
"Program Ended."
);
Experiments/experiments08/Tutorial/mymodule/app.js
deleted
100644 → 0
View file @
14327d1
var
dt
=
require
(
'./mymodule'
);
console
.
log
(
dt
.
myDateTime
());
Experiments/experiments08/Tutorial/mymodule/mymodule.js
deleted
100644 → 0
View file @
14327d1
exports
.
myDateTime
=
function
()
{
return
Date
();
};
Experiments/experiments0
9
/tutorials/approute/app.js
→
Experiments/experiments0
8
/tutorials/approute/app.js
View file @
ae141bc
File moved
Experiments/experiments0
9
/tutorials/approute/package.json
→
Experiments/experiments0
8
/tutorials/approute/package.json
View file @
ae141bc
File moved
Experiments/experiments0
9
/tutorials/expressrouter/app.js
→
Experiments/experiments0
8
/tutorials/expressrouter/app.js
View file @
ae141bc
File moved
Experiments/experiments0
9
/tutorials/expressrouter/birds.js
→
Experiments/experiments0
8
/tutorials/expressrouter/birds.js
View file @
ae141bc
File moved
Experiments/experiments0
9
/tutorials/expressrouter/package.json
→
Experiments/experiments0
8
/tutorials/expressrouter/package.json
View file @
ae141bc
File moved
Experiments/experiments0
9
/tutorials/helloworld/app.js
→
Experiments/experiments0
8
/tutorials/helloworld/app.js
View file @
ae141bc
File moved
Experiments/experiments0
9
/tutorials/helloworld/package.json
→
Experiments/experiments0
8
/tutorials/helloworld/package.json
View file @
ae141bc
File moved
Experiments/experiments0
9
/tutorials/multiplehandler/app.js
→
Experiments/experiments0
8
/tutorials/multiplehandler/app.js
View file @
ae141bc
File moved
Experiments/experiments0
9
/tutorials/multiplehandler/package.json
→
Experiments/experiments0
8
/tutorials/multiplehandler/package.json
View file @
ae141bc
File moved
Experiments/experiments0
9
/tutorials/render/app.js
→
Experiments/experiments0
8
/tutorials/render/app.js
View file @
ae141bc
File moved
Experiments/experiments0
9
/tutorials/render/package.json
→
Experiments/experiments0
8
/tutorials/render/package.json
View file @
ae141bc
File moved
Experiments/experiments0
9
/tutorials/render/views/index.ejs
→
Experiments/experiments0
8
/tutorials/render/views/index.ejs
View file @
ae141bc
File moved
Experiments/experiments0
9
/tutorials/routeparameter/app.js
→
Experiments/experiments0
8
/tutorials/routeparameter/app.js
View file @
ae141bc
File moved
Experiments/experiments0
9
/tutorials/routeparameter/package.json
→
Experiments/experiments0
8
/tutorials/routeparameter/package.json
View file @
ae141bc
File moved
Experiments/experiments0
9
/tutorials/routingpath/app.js
→
Experiments/experiments0
8
/tutorials/routingpath/app.js
View file @
ae141bc
File moved
Experiments/experiments0
9
/tutorials/routingpath/package.json
→
Experiments/experiments0
8
/tutorials/routingpath/package.json
View file @
ae141bc
File moved
Experiments/experiments0
9
/tutorials/session/app.js
→
Experiments/experiments0
8
/tutorials/session/app.js
View file @
ae141bc
File moved
Experiments/experiments0
9
/tutorials/session/package.json
→
Experiments/experiments0
8
/tutorials/session/package.json
View file @
ae141bc
File moved
Experiments/experiments0
9
/tutorials/simplerouting/app.js
→
Experiments/experiments0
8
/tutorials/simplerouting/app.js
View file @
ae141bc
File moved
Experiments/experiments0
9
/tutorials/simplerouting/package.json
→
Experiments/experiments0
8
/tutorials/simplerouting/package.json
View file @
ae141bc
File moved
Experiments/experiments0
9
/tutorials/specialrouting/app.js
→
Experiments/experiments0
8
/tutorials/specialrouting/app.js
View file @
ae141bc
File moved
Experiments/experiments0
9
/tutorials/specialrouting/package.json
→
Experiments/experiments0
8
/tutorials/specialrouting/package.json
View file @
ae141bc
File moved
Experiments/experiments0
9
/tutorials/staticfiles/app.js
→
Experiments/experiments0
8
/tutorials/staticfiles/app.js
View file @
ae141bc
File moved
Experiments/experiments0
9
/tutorials/staticfiles/package.json
→
Experiments/experiments0
8
/tutorials/staticfiles/package.json
View file @
ae141bc
File moved
Experiments/experiments0
9
/tutorials/staticfiles/public/icon.png
→
Experiments/experiments0
8
/tutorials/staticfiles/public/icon.png
View file @
ae141bc
6.72 KB
Experiments/experiments0
9
/tutorials/staticfiles/public/index.html
→
Experiments/experiments0
8
/tutorials/staticfiles/public/index.html
View file @
ae141bc
File moved
Experiments/experiments09/assignments/assignment01/app.js
deleted
100644 → 0
View file @
14327d1
var
express
=
require
(
'express'
);
var
app
=
express
();
var
bodyParser
=
require
(
'body-parser'
);
app
.
use
(
bodyParser
.
urlencoded
({
extended
:
false
}));
app
.
use
(
bodyParser
.
json
());
var
books
=
new
Array
();
app
.
get
(
'/book/:bookId'
,
function
(
req
,
res
)
{
var
bookId
=
req
.
params
.
bookId
;
console
.
log
(
books
[
bookId
]);
res
.
send
(
books
[
bookId
]);
});
/*
{
"id" : 2,
"name" : "book2",
"price" : 2000,
"author" : "jin"
}
*/
app
.
post
(
'/book'
,
function
(
req
,
res
)
{
// Create book information
books
[
req
.
body
.
id
]
=
[
req
.
body
.
id
,
req
.
body
.
name
,
req
.
body
.
price
,
req
.
body
.
author
];
res
.
send
(
books
[
req
.
body
.
id
]);
})
app
.
put
(
'/book/:bookId'
,
function
(
req
,
res
)
{
// Update book information
})
app
.
delete
(
'/book/:bookId'
,
function
(
req
,
res
)
{
// Delete book information
})
var
server
=
app
.
listen
(
80
);
console
.
log
(
books
);
Experiments/experiments09/assignments/assignment01/package.json
deleted
100644 → 0
View file @
14327d1
{
"name"
:
"assignment01"
,
"version"
:
"1.0.0"
,
"description"
:
""
,
"main"
:
"index.js"
,
"scripts"
:
{
"test"
:
"echo
\"
Error: no test specified
\"
&& exit 1"
},
"author"
:
""
,
"license"
:
"ISC"
,
"dependencies"
:
{
"body-parser"
:
"^1.17.1"
,
"express"
:
"^4.15.2"
}
}
Experiments/experiments09/assignments/assignment02/app.js
deleted
100644 → 0
View file @
14327d1
var
express
=
require
(
'express'
);
var
app
=
express
();
var
bodyParser
=
require
(
'body-parser'
);
var
session
=
require
(
'express-session'
)
app
.
use
(
session
({
secret
:
'keyboard cat'
,
cookie
:
{
maxAge
:
60000
}}))
app
.
use
(
bodyParser
.
urlencoded
({
extended
:
false
}));
app
.
use
(
bodyParser
.
json
());
var
users
=
new
Array
();
var
userId
=
'test'
;
var
userPass
=
'1234'
;
app
.
get
(
'/login/:userId/password/:password'
,
function
(
req
,
res
)
{
// users 배열에서 찾도록 수정해야 함
// admin 여부를 지원할 수 있도록 수정해야 함
if
(
req
.
params
.
userId
==
userId
&&
req
.
params
.
password
==
userPass
)
{
req
.
session
.
userId
=
userId
;
}
res
.
send
(
"Login"
);
});
app
.
get
(
'/logout/:userId'
,
function
(
req
,
res
)
{
// Logout
req
.
session
.
userId
=
null
;
res
.
send
(
"LogOut"
);
});
var
auth
=
function
(
req
,
res
,
next
)
{
// Session Check
if
(
req
.
session
.
userId
!=
null
)
next
();
else
res
.
send
(
"Error"
);
};
app
.
get
(
'/user/:userId'
,
auth
,
function
(
req
,
res
)
{
// get User Information
res
.
send
(
"OK"
);
});
// 사용자 추가 시에 admin 여부도 추가해야 함
var
server
=
app
.
listen
(
80
);
Experiments/experiments09/assignments/assignment02/package.json
deleted
100644 → 0
View file @
14327d1
{
"name"
:
"assignment02"
,
"version"
:
"1.0.0"
,
"description"
:
""
,
"main"
:
"index.js"
,
"scripts"
:
{
"test"
:
"echo
\"
Error: no test specified
\"
&& exit 1"
},
"author"
:
""
,
"license"
:
"ISC"
,
"dependencies"
:
{
"body-parser"
:
"^1.17.1"
,
"express"
:
"^4.15.2"
,
"express-session"
:
"^1.15.2"
}
}
Please
register
or
login
to post a comment