Skip to content

Commit 81987e5

Browse files
committed
quick demo using hazel as a node module
0 parents  commit 81987e5

File tree

4 files changed

+5530
-0
lines changed

4 files changed

+5530
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules

index.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
'use strict'
2+
3+
const http = require('http')
4+
const hazel = require('hazel-server')
5+
6+
const server = http.createServer((req, res) => {
7+
const segs = req.url.split('/').filter(Boolean)
8+
const [account, repository] = segs
9+
if (!account || !repository) {
10+
res.statusCode = 404
11+
return res.end('Not found')
12+
}
13+
req.url = '/' + segs.slice(2).join('/')
14+
hazel({ account, repository })(req, res)
15+
})
16+
17+
server.listen(3000, () => console.log(`http://localhost:${server.address().port}`))

0 commit comments

Comments
 (0)