From 3b4b487c2c51b346152d22389ea575633e1f7873 Mon Sep 17 00:00:00 2001 From: Astro Date: Fri, 12 Dec 2014 16:51:37 +0100 Subject: [PATCH] examples/express-embed --- examples/express-embed/package.json | 13 +++++++++++++ examples/express-embed/server.js | 16 ++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 examples/express-embed/package.json create mode 100755 examples/express-embed/server.js diff --git a/examples/express-embed/package.json b/examples/express-embed/package.json new file mode 100644 index 0000000..07eceec --- /dev/null +++ b/examples/express-embed/package.json @@ -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 ", + "license": "MIT", + "dependencies": { + "express": "^4.10.5" + } +} diff --git a/examples/express-embed/server.js b/examples/express-embed/server.js new file mode 100755 index 0000000..8c64ce4 --- /dev/null +++ b/examples/express-embed/server.js @@ -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)