From 5deaf7375d36a346e7457d7518466584b91e4ab7 Mon Sep 17 00:00:00 2001 From: bill bittner Date: Wed, 29 Nov 2017 12:41:53 -0800 Subject: [PATCH] updated route names --- README.md | 4 ++-- routes/api-routes.js | 9 ++++----- routes/serve-routes.js | 2 +- views/partials/asset.handlebars | 4 ++-- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index f27c9835..e2ddcdea 100644 --- a/README.md +++ b/README.md @@ -26,8 +26,8 @@ spee.ch is a single-serving site that reads and publishes images and videos to a #### GET * /api/resolve/:name * example: `curl https://spee.ch/api/resolve/doitlive` -* /api/claim_list/:name - * example: `curl https://spee.ch/api/claim_list/doitlive` +* /api/claim-list/:name + * example: `curl https://spee.ch/api/claim-list/doitlive` * /api/isClaimAvailable/:name (returns `true`/`false` for whether a name is available through spee.ch) * example: `curl https://spee.ch/api/isClaimAvailable/doitlive` diff --git a/routes/api-routes.js b/routes/api-routes.js index 0127e0e7..3a2f481e 100644 --- a/routes/api-routes.js +++ b/routes/api-routes.js @@ -32,7 +32,7 @@ function createFileData ({ name, claimId, outpoint, height, address, nsfw, conte module.exports = (app) => { // route to run a claim_list request on the daemon - app.get('/api/claim_list/:name', ({ ip, originalUrl, params }, res) => { + app.get('/api/claim-list/:name', ({ ip, originalUrl, params }, res) => { getClaimList(params.name) .then(claimsList => { postToStats('serve', originalUrl, ip, null, null, 'success'); @@ -43,7 +43,7 @@ module.exports = (app) => { }); }); // route to see if asset is available locally - app.get('/api/check_local_claim/:name/:claimId', ({ ip, originalUrl, params }, res) => { + app.get('/api/check-local-claim/:name/:claimId', ({ ip, originalUrl, params }, res) => { const name = params.name; const claimId = params.claimId; let isLocalFileAvailable = false; @@ -59,7 +59,7 @@ module.exports = (app) => { }); }); // route to get an asset - app.get('/api/get_claim/:name/:claimId', ({ ip, originalUrl, params }, res) => { + app.get('/api/get-claim/:name/:claimId', ({ ip, originalUrl, params }, res) => { // resolve the claim db.Claim.resolveClaim(params.name, params.claimId) .then(resolveResult => { @@ -73,11 +73,10 @@ module.exports = (app) => { }) .then(([ fileData, getResult ]) => { fileData = addGetResultsToFileData(fileData, getResult); - return Promise.all([db.File.create(fileData), getResult]); // insert a record for the claim into the File table + return Promise.all([db.File.create(fileData), getResult]); // note: should be upsert }) .then(([ fileRecord, {message, completed} ]) => { res.status(200).json({ status: 'success', message, completed }); - logger.debug('File record successfully created'); }) .catch(error => { errorHandlers.handleApiError('get', originalUrl, ip, error, res); diff --git a/routes/serve-routes.js b/routes/serve-routes.js index 5002a6c1..43aced6e 100644 --- a/routes/serve-routes.js +++ b/routes/serve-routes.js @@ -200,7 +200,7 @@ function serveAssetToClient (claimId, name, res) { .then(fileInfo => { logger.debug('fileInfo:', fileInfo); if (fileInfo === NO_FILE) { - res.status(307).redirect(`/api/get_claim/${name}/${claimId}`); + res.status(307).redirect(`/api/get-claim/${name}/${claimId}`); } else { return serveHelpers.serveFile(fileInfo, claimId, name, res); } diff --git a/views/partials/asset.handlebars b/views/partials/asset.handlebars index 4a820cdc..98edd41e 100644 --- a/views/partials/asset.handlebars +++ b/views/partials/asset.handlebars @@ -67,7 +67,7 @@ }, checkClaimAvailability: function (claimName, claimId) { console.log(`checking local availability for ${claimName}#${claimId}`) - var uri = `/api/check_local_claim/${claimName}/${claimId}`; + var uri = `/api/check-local-claim/${claimName}/${claimId}`; var xhr = new XMLHttpRequest(); var that = this; xhr.open("GET", uri, true); @@ -95,7 +95,7 @@ }, getAsset: function(claimName, claimId) { console.log(`getting ${claimName}#${claimId}`) - var uri = `/api/get_claim/${claimName}/${claimId}`; + var uri = `/api/get-claim/${claimName}/${claimId}`; var xhr = new XMLHttpRequest(); var that = this; xhr.open("GET", uri, true);