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
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Commits
Issue Boards
Authored by
진성욱
2018-11-08 23:16:58 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
5e9bd3ce6e4131f4bec187ed54ebf915c28d5c06
5e9bd3ce
1 parent
e9077cb0
experiments08 & experiments09 updated
Show whitespace changes
Inline
Side-by-side
Showing
39 changed files
with
513 additions
and
0 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/Assignments/03/app.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/assignments/assignment01/app.js
Experiments/experiments09/assignments/assignment01/package.json
Experiments/experiments09/assignments/assignment02/app.js
Experiments/experiments09/assignments/assignment02/package.json
Experiments/experiments09/tutorials/approute/app.js
Experiments/experiments09/tutorials/approute/package.json
Experiments/experiments09/tutorials/expressrouter/app.js
Experiments/experiments09/tutorials/expressrouter/birds.js
Experiments/experiments09/tutorials/expressrouter/package.json
Experiments/experiments09/tutorials/helloworld/app.js
Experiments/experiments09/tutorials/helloworld/package.json
Experiments/experiments09/tutorials/multiplehandler/app.js
Experiments/experiments09/tutorials/multiplehandler/package.json
Experiments/experiments09/tutorials/render/app.js
Experiments/experiments09/tutorials/render/package.json
Experiments/experiments09/tutorials/render/views/index.ejs
Experiments/experiments09/tutorials/routeparameter/app.js
Experiments/experiments09/tutorials/routeparameter/package.json
Experiments/experiments09/tutorials/routingpath/app.js
Experiments/experiments09/tutorials/routingpath/package.json
Experiments/experiments09/tutorials/session/app.js
Experiments/experiments09/tutorials/session/package.json
Experiments/experiments09/tutorials/simplerouting/app.js
Experiments/experiments09/tutorials/simplerouting/package.json
Experiments/experiments09/tutorials/specialrouting/app.js
Experiments/experiments09/tutorials/specialrouting/package.json
Experiments/experiments09/tutorials/staticfiles/app.js
Experiments/experiments09/tutorials/staticfiles/package.json
Experiments/experiments09/tutorials/staticfiles/public/icon.png
Experiments/experiments09/tutorials/staticfiles/public/index.html
Experiments/experiments08/Assignments/01/app.js
0 → 100644
View file @
5e9bd3c
File mode changed
Experiments/experiments08/Assignments/01/mymodule.js
0 → 100644
View file @
5e9bd3c
function
add
(
a
,
b
)
{
return
a
+
b
;
}
function
sub
(
a
,
b
)
{
return
a
-
b
;
}
Experiments/experiments08/Assignments/02/consumer.js
0 → 100644
View file @
5e9bd3c
var
Producer
=
require
(
'./producer'
);
var
producer
=
new
Producer
();
producer
.
on
(
'add'
,
function
(
t
)
{
console
.
log
(
'add:'
,
t
);
});
producer
.
start
();
// stop the clock 10 seconds after
// setTimeout(function() {
// clock.stop();
// }, 10e3)
Experiments/experiments08/Assignments/02/producer.js
0 → 100644
View file @
5e9bd3c
var
inherits
=
require
(
'util'
).
inherits
;
var
EventEmitter
=
require
(
'events'
).
EventEmitter
;
var
Producer
=
function
()
{
if
(
!
(
this
instanceof
Producer
))
return
new
Producer
();
EventEmitter
.
call
(
this
);
}
module
.
exports
=
Producer
;
Experiments/experiments08/Assignments/03/app.js
0 → 100644
View file @
5e9bd3c
var
fs
=
require
(
"fs"
);
var
searchString
=
"test"
;
Experiments/experiments08/Tutorial/event01/app.js
0 → 100644
View file @
5e9bd3c
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
0 → 100644
View file @
5e9bd3c
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
0 → 100644
View file @
5e9bd3c
var
dt
=
require
(
'./mymodule'
);
console
.
log
(
dt
.
myDateTime
());
Experiments/experiments08/Tutorial/mymodule/mymodule.js
0 → 100644
View file @
5e9bd3c
exports
.
myDateTime
=
function
()
{
return
Date
();
};
Experiments/experiments09/assignments/assignment01/app.js
0 → 100644
View file @
5e9bd3c
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
)
{
// Get book information
});
app
.
put
(
'/book/:bookId'
,
function
(
req
,
res
)
{
// Update book information
})
app
.
post
(
'/book'
,
function
(
req
,
res
)
{
// Create book information
})
app
.
delete
(
'/book/:bookId'
,
function
(
req
,
res
)
{
// Delete book information
})
var
server
=
app
.
listen
(
23023
);
console
.
log
(
books
);
Experiments/experiments09/assignments/assignment01/package.json
0 → 100644
View file @
5e9bd3c
{
"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
0 → 100644
View file @
5e9bd3c
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
)
{
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"
);
});
var
server
=
app
.
listen
(
23023
);
Experiments/experiments09/assignments/assignment02/package.json
0 → 100644
View file @
5e9bd3c
{
"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"
}
}
Experiments/experiments09/tutorials/approute/app.js
0 → 100644
View file @
5e9bd3c
var
express
=
require
(
'express'
);
var
app
=
express
();
app
.
get
(
'/'
,
function
(
req
,
res
)
{
res
.
send
(
'hello world'
);
})
app
.
route
(
'/book'
)
.
get
(
function
(
req
,
res
)
{
res
.
send
(
'Get a random book'
);
})
.
post
(
function
(
req
,
res
)
{
res
.
send
(
'Add a book'
);
})
.
put
(
function
(
req
,
res
)
{
res
.
send
(
'Update the book'
);
});
var
server
=
app
.
listen
(
23023
);
Experiments/experiments09/tutorials/approute/package.json
0 → 100644
View file @
5e9bd3c
{
"name"
:
"approute"
,
"version"
:
"1.0.0"
,
"description"
:
""
,
"main"
:
"index.js"
,
"scripts"
:
{
"test"
:
"echo
\"
Error: no test specified
\"
&& exit 1"
},
"author"
:
""
,
"license"
:
"ISC"
,
"dependencies"
:
{
"express"
:
"^4.15.2"
}
}
Experiments/experiments09/tutorials/expressrouter/app.js
0 → 100644
View file @
5e9bd3c
var
express
=
require
(
'express'
);
var
app
=
express
();
var
birds
=
require
(
'./birds'
);
app
.
get
(
'/'
,
function
(
req
,
res
)
{
res
.
send
(
'hello world'
);
})
app
.
use
(
'/birds'
,
birds
);
var
server
=
app
.
listen
(
23023
);
Experiments/experiments09/tutorials/expressrouter/birds.js
0 → 100644
View file @
5e9bd3c
var
express
=
require
(
'express'
);
var
router
=
express
.
Router
();
router
.
get
(
'/'
,
function
(
req
,
res
)
{
res
.
send
(
'Birds home page'
);
})
router
.
get
(
'/about'
,
function
(
req
,
res
)
{
res
.
send
(
'About birds'
);
});
module
.
exports
=
router
;
Experiments/experiments09/tutorials/expressrouter/package.json
0 → 100644
View file @
5e9bd3c
{
"name"
:
"expressrouter"
,
"version"
:
"1.0.0"
,
"description"
:
""
,
"main"
:
"index.js"
,
"scripts"
:
{
"test"
:
"echo
\"
Error: no test specified
\"
&& exit 1"
},
"author"
:
""
,
"license"
:
"ISC"
,
"dependencies"
:
{
"express"
:
"^4.15.2"
}
}
Experiments/experiments09/tutorials/helloworld/app.js
0 → 100644
View file @
5e9bd3c
var
express
=
require
(
'express'
);
var
app
=
express
();
app
.
get
(
'/'
,
function
(
req
,
res
)
{
res
.
send
(
'Hello World'
);
})
var
server
=
app
.
listen
(
23023
,
function
()
{
var
host
=
server
.
address
().
address
var
port
=
server
.
address
().
port
console
.
log
(
"Example app listening at http://%s:%s"
,
host
,
port
)
})
Experiments/experiments09/tutorials/helloworld/package.json
0 → 100644
View file @
5e9bd3c
{
"name"
:
"helloworld"
,
"version"
:
"1.0.0"
,
"description"
:
""
,
"main"
:
"index.js"
,
"scripts"
:
{
"test"
:
"echo
\"
Error: no test specified
\"
&& exit 1"
},
"author"
:
""
,
"license"
:
"ISC"
,
"dependencies"
:
{
"express"
:
"^4.15.2"
}
}
Experiments/experiments09/tutorials/multiplehandler/app.js
0 → 100644
View file @
5e9bd3c
var
express
=
require
(
'express'
);
var
app
=
express
();
app
.
get
(
'/b'
,
function
(
req
,
res
,
next
)
{
console
.
log
(
'the response will be sent by the next function ...'
)
next
()
},
function
(
req
,
res
)
{
res
.
send
(
'Hello from B!'
)
})
var
cb0
=
function
(
req
,
res
,
next
)
{
console
.
log
(
"call by cb0"
);
next
()
}
var
cb1
=
function
(
req
,
res
,
next
)
{
console
.
log
(
"call by cb1"
);
res
.
send
(
'Hello from C!'
)
}
app
.
get
(
'/c'
,
[
cb0
,
cb1
])
var
server
=
app
.
listen
(
23023
);
Experiments/experiments09/tutorials/multiplehandler/package.json
0 → 100644
View file @
5e9bd3c
{
"name"
:
"multiplehandler"
,
"version"
:
"1.0.0"
,
"description"
:
""
,
"main"
:
"index.js"
,
"scripts"
:
{
"test"
:
"echo
\"
Error: no test specified
\"
&& exit 1"
},
"author"
:
""
,
"license"
:
"ISC"
,
"dependencies"
:
{
"express"
:
"^4.15.2"
}
}
Experiments/experiments09/tutorials/render/app.js
0 → 100644
View file @
5e9bd3c
var
express
=
require
(
'express'
);
var
app
=
express
();
app
.
set
(
'view engine'
,
'ejs'
);
app
.
set
(
'views'
,
'views'
);
app
.
get
(
'/'
,
function
(
req
,
res
)
{
res
.
render
(
'index'
,
{
title
:
'OSS Page'
});
});
var
server
=
app
.
listen
(
23023
);
Experiments/experiments09/tutorials/render/package.json
0 → 100644
View file @
5e9bd3c
{
"name"
:
"render"
,
"version"
:
"1.0.0"
,
"description"
:
""
,
"main"
:
"index.js"
,
"scripts"
:
{
"test"
:
"echo
\"
Error: no test specified
\"
&& exit 1"
},
"author"
:
""
,
"license"
:
"ISC"
,
"dependencies"
:
{
"ejs"
:
"^2.5.6"
,
"express"
:
"^4.15.2"
}
}
Experiments/experiments09/tutorials/render/views/index.ejs
0 → 100644
View file @
5e9bd3c
html>
<body>
<%= title %>
</body>
</html>
Experiments/experiments09/tutorials/routeparameter/app.js
0 → 100644
View file @
5e9bd3c
var
express
=
require
(
'express'
);
var
app
=
express
();
app
.
get
(
'/users/:userId/books/:bookId'
,
function
(
req
,
res
)
{
res
.
send
(
req
.
params
);
})
var
server
=
app
.
listen
(
23023
);
Experiments/experiments09/tutorials/routeparameter/package.json
0 → 100644
View file @
5e9bd3c
{
"name"
:
"routeparameter"
,
"version"
:
"1.0.0"
,
"description"
:
""
,
"main"
:
"index.js"
,
"scripts"
:
{
"test"
:
"echo
\"
Error: no test specified
\"
&& exit 1"
},
"author"
:
""
,
"license"
:
"ISC"
,
"dependencies"
:
{
"express"
:
"^4.15.2"
}
}
Experiments/experiments09/tutorials/routingpath/app.js
0 → 100644
View file @
5e9bd3c
var
express
=
require
(
'express'
);
var
app
=
express
();
// The routing path matches requests to /about
app
.
get
(
'/about'
,
function
(
req
,
res
)
{
res
.
send
(
'about'
)
})
// The routing path matches requests to /random.text
app
.
get
(
'/random.text'
,
function
(
req
,
res
)
{
res
.
send
(
'random.text'
)
})
// This route path matches abcd, abxcd, abRANDOMcd, ab123cd, and so on.
app
.
get
(
'/ab*cd'
,
function
(
req
,
res
)
{
res
.
send
(
'ab*cd'
)
})
var
server
=
app
.
listen
(
23023
);
Experiments/experiments09/tutorials/routingpath/package.json
0 → 100644
View file @
5e9bd3c
{
"name"
:
"routingpath"
,
"version"
:
"1.0.0"
,
"description"
:
""
,
"main"
:
"index.js"
,
"scripts"
:
{
"test"
:
"echo
\"
Error: no test specified
\"
&& exit 1"
},
"author"
:
""
,
"license"
:
"ISC"
,
"dependencies"
:
{
"express"
:
"^4.15.2"
}
}
Experiments/experiments09/tutorials/session/app.js
0 → 100644
View file @
5e9bd3c
var
express
=
require
(
'express'
);
var
app
=
express
();
var
session
=
require
(
'express-session'
)
app
.
use
(
session
({
secret
:
'keyboard cat'
,
cookie
:
{
maxAge
:
60000
}}))
app
.
get
(
'/'
,
function
(
req
,
res
,
next
)
{
var
sess
=
req
.
session
;
console
.
log
(
req
.
session
);
if
(
sess
.
views
)
{
sess
.
views
++
;
res
.
send
(
"session Views "
+
sess
.
views
);
res
.
send
();
}
else
{
req
.
session
.
views
=
1
;
res
.
send
(
"welcome to the session demo. refresh!"
);
res
.
end
();
}
});
var
server
=
app
.
listen
(
23023
);
Experiments/experiments09/tutorials/session/package.json
0 → 100644
View file @
5e9bd3c
{
"name"
:
"session"
,
"version"
:
"1.0.0"
,
"description"
:
""
,
"main"
:
"index.js"
,
"scripts"
:
{
"test"
:
"echo
\"
Error: no test specified
\"
&& exit 1"
},
"author"
:
""
,
"license"
:
"ISC"
,
"dependencies"
:
{
"express"
:
"^4.15.2"
,
"express-session"
:
"^1.15.2"
}
}
Experiments/experiments09/tutorials/simplerouting/app.js
0 → 100644
View file @
5e9bd3c
var
express
=
require
(
'express'
);
var
app
=
express
();
app
.
get
(
'/'
,
function
(
req
,
res
)
{
res
.
send
(
'hello world'
);
})
var
server
=
app
.
listen
(
23023
);
Experiments/experiments09/tutorials/simplerouting/package.json
0 → 100644
View file @
5e9bd3c
{
"name"
:
"simplerouting"
,
"version"
:
"1.0.0"
,
"description"
:
""
,
"main"
:
"index.js"
,
"scripts"
:
{
"test"
:
"echo
\"
Error: no test specified
\"
&& exit 1"
},
"author"
:
""
,
"license"
:
"ISC"
,
"dependencies"
:
{
"express"
:
"^4.15.2"
}
}
Experiments/experiments09/tutorials/specialrouting/app.js
0 → 100644
View file @
5e9bd3c
var
express
=
require
(
'express'
);
var
app
=
express
();
app
.
all
(
'/'
,
function
(
req
,
res
,
next
)
{
console
.
log
(
'Accessing the secret section ...'
)
next
()
// pass control to the next handler
})
app
.
get
(
'/'
,
function
(
req
,
res
)
{
res
.
send
(
'hello world'
);
})
app
.
post
(
'/'
,
function
(
req
,
res
)
{
res
.
send
(
'POST request to the homepage'
)
})
var
server
=
app
.
listen
(
23023
);
Experiments/experiments09/tutorials/specialrouting/package.json
0 → 100644
View file @
5e9bd3c
{
"name"
:
"specialrouting"
,
"version"
:
"1.0.0"
,
"description"
:
""
,
"main"
:
"index.js"
,
"scripts"
:
{
"test"
:
"echo
\"
Error: no test specified
\"
&& exit 1"
},
"author"
:
""
,
"license"
:
"ISC"
,
"dependencies"
:
{
"express"
:
"^4.15.2"
}
}
Experiments/experiments09/tutorials/staticfiles/app.js
0 → 100644
View file @
5e9bd3c
var
express
=
require
(
'express'
);
var
app
=
express
();
app
.
use
(
express
.
static
(
'public'
));
app
.
get
(
'/'
,
function
(
req
,
res
)
{
res
.
send
(
'Hello World'
);
})
var
server
=
app
.
listen
(
23023
);
Experiments/experiments09/tutorials/staticfiles/package.json
0 → 100644
View file @
5e9bd3c
{
"name"
:
"staticfiles"
,
"version"
:
"1.0.0"
,
"description"
:
""
,
"main"
:
"index.js"
,
"scripts"
:
{
"test"
:
"echo
\"
Error: no test specified
\"
&& exit 1"
},
"author"
:
""
,
"license"
:
"ISC"
,
"dependencies"
:
{
"express"
:
"^4.15.2"
}
}
Experiments/experiments09/tutorials/staticfiles/public/icon.png
0 → 100644
View file @
5e9bd3c
6.72 KB
Experiments/experiments09/tutorials/staticfiles/public/index.html
0 → 100644
View file @
5e9bd3c
<html>
<body>
Public index.html
</body>
</html>
Please
register
or
login
to post a comment