-
Notifications
You must be signed in to change notification settings - Fork 0
/
router.coffee
46 lines (35 loc) · 903 Bytes
/
router.coffee
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
FIRST = 'abcdefghijklmnopqrstuvwxyz'
SECOND = 'aeiou'
THIRD = FIRST
getRandomRoomName = ->
parts = []
for wordArray in [FIRST, SECOND, THIRD]
parts.push Random.choice(wordArray)
parts.join('')
Router.configure
layoutTemplate: 'layout'
Router.map ->
@route 'root',
where: 'server'
path: '/'
action: ->
newName = getRandomRoomName()
@response.writeHead 307,
Location: Router.path 'home', roomName: newName
@response.end()
@route 'imageRoot',
where: 'server'
path: '/image-stream'
action: ->
newName = getRandomRoomName()
@response.writeHead 307,
Location: Router.path 'ImageStream', roomName: newName
@response.end()
@route 'multiDraw',
path: '/multi_draw'
@route 'drawer',
path: '/drawer'
@route 'home',
path: '/:roomName'
@route 'ImageStream',
path: '/image-stream/:roomName'