Skip to content

Commit

Permalink
Update schemas and format the JS example
Browse files Browse the repository at this point in the history
  • Loading branch information
dunglas committed Apr 17, 2020
1 parent 38bddb0 commit 45c6058
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 19 deletions.
41 changes: 22 additions & 19 deletions examples/publisher-node.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,34 @@
const http = require('http');
const querystring = require('querystring');
const http = require("http");
const querystring = require("querystring");


const demoJwt = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJtZXJjdXJlIjp7InN1YnNjcmliZSI6WyJmb28iLCJiYXIiXSwicHVibGlzaCI6WyJmb28iXX19.afLx2f2ut3YgNVFStCx95Zm_UND1mZJ69OenXaDuZL8';
const demoJwt =
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJtZXJjdXJlIjp7InN1YnNjcmliZSI6WyJmb28iLCJiYXIiXSwicHVibGlzaCI6WyJmb28iXX19.afLx2f2ut3YgNVFStCx95Zm_UND1mZJ69OenXaDuZL8";

const postData = querystring.stringify({
'topic': 'http://localhost:3000/demo/books/1.jsonld',
'data': JSON.stringify({ key: 'updated value' }),
topic: "http://localhost:3000/demo/books/1.jsonld",
data: JSON.stringify({ key: "updated value" }),
});

const req = http.request({
hostname: 'localhost',
port: '3000',
path: '/.well-known/mercure',
method: 'POST',
const req = http.request(
{
hostname: "localhost",
port: "3000",
path: "/.well-known/mercure",
method: "POST",
headers: {
Authorization: `Bearer ${demoJwt}`,
'Content-Type': 'application/x-www-form-urlencoded',
'Content-Length': Buffer.byteLength(postData),
}
}, (res) => {
Authorization: `Bearer ${demoJwt}`,
"Content-Type": "application/x-www-form-urlencoded",
"Content-Length": Buffer.byteLength(postData),
},
},
(res) => {
console.log(`Status: ${res.statusCode}`);
console.log(`Headers: ${JSON.stringify(res.headers)}`);
});
}
);

req.on('error', (e) => {
console.error(`An error occurred: ${e.message}`);
req.on("error", (e) => {
console.error(`An error occurred: ${e.message}`);
});

req.write(postData);
Expand Down
Binary file modified spec/authorization.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified spec/discovery.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 45c6058

Please sign in to comment.