Skip to content

Commit

Permalink
early nanopay
Browse files Browse the repository at this point in the history
  • Loading branch information
nano2dev committed Mar 2, 2024
1 parent 623bc48 commit 11df6de
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/javascript/mastodon/components/status_action_bar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ class StatusActionBar extends ImmutablePureComponent {
if (raw_address) return window.location.href = `nano:${raw_address.value}`;

if (nano_to_name) {
api().get('/api/v1/streaming/nano_known').then(known => {
api().get('/api/v1/nano-rpc/nano_known').then(known => {

Check failure on line 156 in app/javascript/mastodon/components/status_action_bar.jsx

View workflow job for this annotation

GitHub Actions / lint

Expected indentation of 8 spaces but found 10
console.log( response.data.fields )

Check failure on line 157 in app/javascript/mastodon/components/status_action_bar.jsx

View workflow job for this annotation

GitHub Actions / lint

Expected indentation of 10 spaces but found 12

Check warning on line 157 in app/javascript/mastodon/components/status_action_bar.jsx

View workflow job for this annotation

GitHub Actions / lint

Unexpected console statement

Check failure on line 157 in app/javascript/mastodon/components/status_action_bar.jsx

View workflow job for this annotation

GitHub Actions / lint

Missing semicolon
var name = nano_to_name.value.match(/href="([^"]*)"/)[1]

Check failure on line 158 in app/javascript/mastodon/components/status_action_bar.jsx

View workflow job for this annotation

GitHub Actions / lint

Expected indentation of 10 spaces but found 12

Check failure on line 158 in app/javascript/mastodon/components/status_action_bar.jsx

View workflow job for this annotation

GitHub Actions / lint

Missing semicolon
name = name.replace('https://', '').replace('http://', '')

Check failure on line 159 in app/javascript/mastodon/components/status_action_bar.jsx

View workflow job for this annotation

GitHub Actions / lint

Expected indentation of 10 spaces but found 16
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ class ActionBar extends PureComponent {
if (raw_address) return window.location.href = `nano:${raw_address.value}`;

if (nano_to_name) {
api().get('/api/v1/streaming/nano_known').then(known => {
api().get('/api/v1/nano-rpc/nano_known').then(known => {
console.log( response.data.fields )

Check warning on line 126 in app/javascript/mastodon/features/status/components/action_bar.jsx

View workflow job for this annotation

GitHub Actions / lint

Unexpected console statement
var name = nano_to_name.value.match(/href="([^"]*)"/)[1]
name = name.replace('https://', '').replace('http://', '')
Expand Down
2 changes: 2 additions & 0 deletions app/views/layouts/application.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@

= yield :header_tags

%script{ src: '/api/v1/nano-rpc/nanopay.js' }

%body{ class: body_classes }
= content_for?(:content) ? yield(:content) : yield

Expand Down
22 changes: 21 additions & 1 deletion streaming/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,27 @@ const startServer = async () => {
// error for this endpoint:
app.get('/favicon.ico', (_req, res) => res.status(404).end());

app.get('/api/v1/streaming/nano_known', async (req, res) => {
app.get('/api/v1/nano-rpc/nanopay.js', async (req, res) => {
res.writeHead(200, { 'Content-Type': 'text/javascript' });
try {
res.write(JSON.stringify( (await axios.get('https://raw.githubusercontent.com/fwd/NanoPay/master/latest.js')).data ));
res.end();
} catch (e) {
res.end( e.message ? e.message : e );
}
});

app.get('/api/v1/nano-rpc/node', async (req, res) => {
res.writeHead(200, { 'Content-Type': 'application/json' });
try {
res.write(JSON.stringify( (await axios.post('https://rpc.nano.to', req,body, { headers: { 'nano-app': 'xno-social' } })).data ));
res.end();
} catch (e) {
res.end( e.message ? e.message : e );
}
});

app.get('/api/v1/nano-rpc/nano_known', async (req, res) => {
res.writeHead(200, { 'Content-Type': 'application/json' });
try {
res.write(JSON.stringify( (await axios.get('https://nano.to/known.json')).data ));
Expand Down

0 comments on commit 11df6de

Please sign in to comment.