examples/express-embed

This commit is contained in:
Astro 2014-12-12 16:51:37 +01:00
parent 79068a49cf
commit 3b4b487c2c
2 changed files with 29 additions and 0 deletions

View File

@ -0,0 +1,13 @@
{
"name": "bittorrent-tracker-example-express-embed",
"version": "0.0.0",
"description": "Example for embedding bittorrent-tracker server in express.js",
"scripts": {
"server": "./server.js"
},
"author": "Astro <astro@spaceboyz.net>",
"license": "MIT",
"dependencies": {
"express": "^4.10.5"
}
}

View File

@ -0,0 +1,16 @@
#!/usr/bin/env node
var Server = require('../..').Server
var express = require('express')
var app = express()
var server = new Server({
http: false, // we do our own
udp: false // not interested
})
var onHttpRequest = server._onHttpRequest.bind(server)
app.get('/announce', onHttpRequest)
app.get('/scrape', onHttpRequest)
app.listen(8080)