Created
March 5, 2018 17:12
-
-
Save akhilesh26/ae3bc998f96e592d59a9adbe49103d3c to your computer and use it in GitHub Desktop.
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
//Emample of post reqest to add new publication from client application | |
curl -i -X POST \ | |
-H '{"client_id":"oImVtuuVkDVCiWhANENM", "user_secret":"79461aea-b320-4f46-9978-3b444b3350c3", "Content-Type":"application/json"}' \ | |
https://api.bookbrainz.com/v1/publications/new/ \ | |
-d '{data pf new publication}' | |
//handle | |
router.get('publications/new', async(ctx) => { | |
if(isAuthenticated(ctx.request.header)){ | |
// send data to the database and send response to client with status code. | |
} | |
else{ | |
// send response to the client with authentication failure status code | |
}) | |
// Example fuction for authentication | |
const isAthenticated = (header) =>{ | |
if(header.user_secret == user.token && header.client_id == client.client_id) { | |
return true; | |
} | |
else { | |
return false | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment