-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathuserAddress.js
35 lines (32 loc) · 1.29 KB
/
userAddress.js
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
(function() {
var http = require('http'),
url = require('url'),
config = require('./config').config;
function serve() {
http.createServer(function (req, res) {
var urlObj = url.parse(req.url, true);
console.log(urlObj);
//if(urlObj.pathname=='/single-origin-webfinger...really') {
if(true) {
res.writeHead(200, {
'Content-Type': 'xrd+xml',
'Access-Control-Allow-Origin': '*'});
var userName = (urlObj.query.userAddress.split('@'))[0];
res.end('<?xml version="1.0" encoding="UTF-8"?>\n'
+'<XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0" xmlns:hm="http://host-meta.net/xrd/1.0">\n'
+' <hm:Host xmlns="http://host-meta.net/xrd/1.0">'+config.facadeHost+'</hm:Host>\n'
+' <Link rel="remoteStorage"\n'
+' template="http://'+userName+'.'+config.proxyParentDomain+'/{category}/"\n'
+' auth="http://'+config.facadeHost+'/auth?userName='+userName+'"\n'
+' api="CouchDB"\n'
+' ></Link>\n'
+'</XRD>\n');
} else {
res.writeHead(404, {'Content-Type': 'text/plain'});
res.end('Not found\n');
}
}).listen(config.backends.userAddress);
console.log('listening on '+config.backends.userAddress);
}
serve();
})();