Skip to content

Commit

Permalink
Add /v1/ and redirect (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
MrLuit authored Oct 3, 2018
1 parent 25eda7f commit 68f3310
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 30 deletions.
25 changes: 15 additions & 10 deletions src/utils/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -308,21 +308,23 @@ router.use('/api/:type?/:domain?/', (req, res, next) => {
next();
});

router.get('/api/scams', (req, res) => res.json({ success: true, result: db.read().scams }));
router.get('/api/addresses', (req, res) =>
router.get('/api/v1/scams', (req, res) => res.json({ success: true, result: db.read().scams }));
router.get('/api/v1/addresses', (req, res) =>
res.json({ success: true, result: db.read().index.addresses })
);
router.get('/api/ips', (req, res) => res.json({ success: true, result: db.read().index.ips }));
router.get('/api/verified', (req, res) => res.json({ success: true, result: db.read().verified }));
router.get('/api/inactives', (req, res) =>
router.get('/api/v1/ips', (req, res) => res.json({ success: true, result: db.read().index.ips }));
router.get('/api/v1/verified', (req, res) =>
res.json({ success: true, result: db.read().verified })
);
router.get('/api/v1/inactives', (req, res) =>
res.json({ success: true, result: db.read().index.inactives })
);
router.get('/api/actives', (req, res) =>
router.get('/api/v1/actives', (req, res) =>
res.json({ success: true, result: db.read().index.actives })
);
router.get('/api/blacklist', (req, res) => res.json(db.read().index.blacklist));
router.get('/api/whitelist', (req, res) => res.json(db.read().index.whitelist));
router.get('/api/abusereport/:domain', (req, res) => {
router.get('/api/v1/blacklist', (req, res) => res.json(db.read().index.blacklist));
router.get('/api/v1/whitelist', (req, res) => res.json(db.read().index.whitelist));
router.get('/api/v1/abusereport/:domain', (req, res) => {
const result = db
.read()
.scams.find(
Expand All @@ -336,7 +338,7 @@ router.get('/api/abusereport/:domain', (req, res) => {
res.json({ success: false, message: "URL wasn't found" });
}
});
router.get('/api/check/:search', (req, res) => {
router.get('/api/v1/check/:search', (req, res) => {
if (/^0x?[0-9A-Fa-f]{40,42}$/.test(req.params.search)) {
/* Searched for an ethereum address */
const whitelistAddresses = db.read().index.whitelistAddresses[
Expand Down Expand Up @@ -445,6 +447,9 @@ router.get('/api/check/:search', (req, res) => {
}
});

/* Redirect old API requests */
router.get('/api/:all*?', (req, res) => res.redirect('/api/v1/' + req.params.all));

/* Incoming Github webhook attempt */
router.post('/update/', (req, res) => {
let body = '';
Expand Down
20 changes: 10 additions & 10 deletions src/views/pages/api.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<h1><i class="settings icon"></i> API</h1>
<div class="ui divider"></div>
<h2>Check</h2>
<b>URL</b>: <div class="ui segment">GET "https://cryptoscamdb.org/api/check/0xDaa29859836D97C810c7F9D350D4A1B3E8CafC9a/" (can be a domain, ethereum address, or ip address)</div><BR>
<b>URL</b>: <div class="ui segment">GET "https://cryptoscamdb.org/api/v1/check/0xDaa29859836D97C810c7F9D350D4A1B3E8CafC9a/" (can be a domain, ethereum address, or ip address)</div><BR>
<b>Response: </b>
<div id="check_segment" class="ui long inverted segment">
<div id="check_loader" class="ui active dimmer">
Expand All @@ -25,7 +25,7 @@
<b>Another example URL</b>: <a target="_blank" href="/report/address/0x0000000000000000000000000000000000000000/">https://cryptoscamdb.org/report/address/0x0000000000000000000000000000000000000000/</a><BR><BR>
All of the values (fake-mycrypto.com and 0x0000000000000000000000000000000000000000) are optional.
<h2>Scams</h2>
<b>URL</b>: <div class="ui segment">GET "https://cryptoscamdb.org/api/scams/"</div><BR>
<b>URL</b>: <div class="ui segment">GET "https://cryptoscamdb.org/api/v1/scams/"</div><BR>
<b>Response: </b>
<div id="scams_segment" class="ui long inverted segment">
<div id="scams_loader" class="ui active dimmer">
Expand All @@ -36,7 +36,7 @@
</pre>
</div>
<h2>Addresses</h2>
<b>URL</b>: <div class="ui segment">GET "https://cryptoscamdb.org/api/addresses/"</div><BR>
<b>URL</b>: <div class="ui segment">GET "https://cryptoscamdb.org/api/v1/addresses/"</div><BR>
<b>Response: </b>
<div id="addresses_segment" class="ui long inverted segment">
<div id="addresses_loader" class="ui active dimmer">
Expand All @@ -47,7 +47,7 @@
</pre>
</div>
<h2>IPs</h2>
<b>URL</b>: <div class="ui segment">GET "https://cryptoscamdb.org/api/ips/"</div><BR>
<b>URL</b>: <div class="ui segment">GET "https://cryptoscamdb.org/api/v1/ips/"</div><BR>
<b>Response: </b>
<div id="ips_segment" class="ui long inverted segment">
<div id="ips_loader" class="ui active dimmer">
Expand All @@ -58,7 +58,7 @@
</pre>
</div>
<h2>Verified</h2>
<b>URL</b>: <div class="ui segment">GET "https://cryptoscamdb.org/api/verified/"</div><BR>
<b>URL</b>: <div class="ui segment">GET "https://cryptoscamdb.org/api/v1/verified/"</div><BR>
<b>Response: </b>
<div id="verified_segment" class="ui long inverted segment">
<div id="verified_loader" class="ui active dimmer">
Expand All @@ -69,7 +69,7 @@
</pre>
</div>
<h2>Blacklist</h2>
<b>URL</b>: <div class="ui segment">GET "https://cryptoscamdb.org/api/blacklist/"</div><BR>
<b>URL</b>: <div class="ui segment">GET "https://cryptoscamdb.org/api/v1/blacklist/"</div><BR>
<b>Response: </b>
<div id="blacklist_segment" class="ui long inverted segment">
<div id="blacklist_loader" class="ui active dimmer">
Expand All @@ -80,7 +80,7 @@
</pre>
</div>
<h2>Whitelist</h2>
<b>URL</b>: <div class="ui segment">GET "https://cryptoscamdb.org/api/whitelist/"</div><BR>
<b>URL</b>: <div class="ui segment">GET "https://cryptoscamdb.org/api/v1/whitelist/"</div><BR>
<b>Response: </b>
<div id="whitelist_segment" class="ui long inverted segment">
<div id="whitelist_loader" class="ui active dimmer">
Expand All @@ -92,7 +92,7 @@
</div>

<h2>Inactives</h2>
<b>URL</b>: <div class="ui segment">GET "https://cryptoscamdb.org/api/inactives/"</div><BR>
<b>URL</b>: <div class="ui segment">GET "https://cryptoscamdb.org/api/v1/inactives/"</div><BR>
<b>Response: </b>
<div id="inactives_segment" class="ui long inverted segment">
<div id="inactives_loader" class="ui active dimmer">
Expand All @@ -104,7 +104,7 @@
</div>

<h2>Actives</h2>
<b>URL</b>: <div class="ui segment">GET "https://cryptoscamdb.org/api/actives/"</div><BR>
<b>URL</b>: <div class="ui segment">GET "https://cryptoscamdb.org/api/v1/actives/"</div><BR>
<b>Response: </b>
<div id="actives_segment" class="ui long inverted segment">
<div id="actives_loader" class="ui active dimmer">
Expand All @@ -116,7 +116,7 @@
</div>

<h2>Abuse report</h2>
<b>URL</b>: <div class="ui segment">GET "https://cryptoscamdb.org/api/abusereport/changellyli.com/"</div><BR>
<b>URL</b>: <div class="ui segment">GET "https://cryptoscamdb.org/api/v1/abusereport/changellyli.com/"</div><BR>
<b>Response: </b>
<div id="abusereport_segment" class="ui long inverted segment">
<div id="abusereport_loader" class="ui active dimmer">
Expand Down
20 changes: 10 additions & 10 deletions src/views/static/js/api.js
Original file line number Diff line number Diff line change
@@ -1,59 +1,59 @@
window.addEventListener("load", function() {
$.getJSON("/api/check/0xDaa29859836D97C810c7F9D350D4A1B3E8CafC9a",function(data) {
$.getJSON("/api/v1/check/0xDaa29859836D97C810c7F9D350D4A1B3E8CafC9a",function(data) {
data = JSON.stringify(data, null, 2);
$("#check_loader").remove();
$("#check_segment").css("overflow","scroll");
$(".check_response").html(data);
});
$.getJSON("/api/scams/",function(data) {
$.getJSON("/api/v1/scams/",function(data) {
data = JSON.stringify(data, null, 2);
$("#scams_loader").remove();
$("#scams_segment").css("overflow","scroll");
$(".scams_response").html(data);
});
$.getJSON("/api/addresses/",function(data) {
$.getJSON("/api/v1/addresses/",function(data) {
data = JSON.stringify(data, null, 2);
$("#addresses_loader").remove();
$("#addresses_segment").css("overflow","scroll");
$(".addresses_response").html(data);
});
$.getJSON("/api/ips/",function(data) {
$.getJSON("/api/v1/ips/",function(data) {
data = JSON.stringify(data, null, 2);
$("#ips_loader").remove();
$("#ips_segment").css("overflow","scroll");
$(".ips_response").html(data);
});
$.getJSON("/api/verified/",function(data) {
$.getJSON("/api/v1/verified/",function(data) {
data = JSON.stringify(data, null, 2);
$("#verified_loader").remove();
$("#verified_segment").css("overflow","scroll");
$(".verified_response").html(data);
});
$.getJSON("/api/blacklist/",function(data) {
$.getJSON("/api/v1/blacklist/",function(data) {
data = JSON.stringify(data, null, 2);
$("#blacklist_loader").remove();
$("#blacklist_segment").css("overflow","scroll");
$(".blacklist_response").html(data);
});
$.getJSON("/api/whitelist/",function(data) {
$.getJSON("/api/v1/whitelist/",function(data) {
data = JSON.stringify(data, null, 2);
$("#whitelist_loader").remove();
$("#whitelist_segment").css("overflow","scroll");
$(".whitelist_response").html(data);
});
$.getJSON("/api/inactives/",function(data) {
$.getJSON("/api/v1/inactives/",function(data) {
data = JSON.stringify(data, null, 2);
$("#inactives_loader").remove();
$("#inactives_segment").css("overflow","scroll");
$(".inactives_response").html(data);
});
$.getJSON("/api/actives/",function(data) {
$.getJSON("/api/v1/actives/",function(data) {
data = JSON.stringify(data, null, 2);
$("#actives_loader").remove();
$("#actives_segment").css("overflow","scroll");
$(".actives_response").html(data);
});
$.getJSON("/api/abusereport/changellyli.com",function(data) {
$.getJSON("/api/v1/abusereport/changellyli.com",function(data) {
data = JSON.stringify(data, null, 2);
$("#abusereport_loader").remove();
$("#abusereport_segment").css("overflow","scroll");
Expand Down

0 comments on commit 68f3310

Please sign in to comment.