-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from vgrichina/web4-login
Switch to login and submit transactions via web4
- Loading branch information
Showing
7 changed files
with
3,614 additions
and
3,086 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
async function sendJson({ method, url, json }) { | ||
const res = await fetch(url, { | ||
method: method, | ||
body: method !== 'GET' ? JSON.stringify(json) : undefined, | ||
headers: { 'content-type': 'application/json; charset=utf-8' } | ||
}); | ||
|
||
if (!res.ok) { | ||
const err = new Error(`HTTP error: ${res.status} ${res.statusText}`); | ||
err.data = await res.text(); | ||
} | ||
|
||
if (res.status === 204) { | ||
// No Content | ||
return null; | ||
} | ||
} | ||
|
||
export async function getJson(url) { | ||
return await sendJson({ method: 'GET', url }); | ||
} | ||
|
||
export async function postJson(url, json) { | ||
return await sendJson({ method: 'POST', url, json }); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
const web4 = require('web4-near') | ||
|
||
module.exports = function (app) { | ||
// Proxy to web4 gateway when the path starts with /web4 | ||
const web4Callback = web4.callback(); | ||
app.use((req, res, next) => { | ||
if (req.url.startsWith('/web4')) { | ||
web4Callback(req, res, next); | ||
return; | ||
} | ||
|
||
next(); | ||
}); | ||
} |
Oops, something went wrong.