This is an API written in express
for the BookSearch app. This api is responsible for
- authenticating users
- get and return responses from the Google Books API
- storing search history in a
MongoDB
database
The api supports following routes:
/
- default route./history
- returns the search history of the current user from the database.User authentication required/verifyToken
- verifies the token sent from the ui againstGoogle Oauth
for authentication. Returns the authenticated user when successfull/logout
- Logs out and terminated the cureent user session.User authentication required/getbooklist/?queryTerm=<queryTerm>
- Searches for thequeryTerm
on Google Books API and returns the response to the ui. It also adds the searches to the database once every 5 searches.User authentication requiredgetbook/?volumeId=<volumeId>
- searches for particular book defined byvolumeId
on the Google Books API and returns the response to the ui.User authentication required
GOOGLE_AUTH_CLIENT_ID
- Client ID for OAuth authenticationGOOGLE_BOOKS_API_KEY
- API key to search over the Google Books APIMONGODB_CONNECTION_STRING
- Connection string to theMongoDb
databaseSESSION_SECRET
- secret key for managing the sessions
NOTE: This is not a standalone application, it needs a React Frontend and a mongodb database to work
- Clone the repository:
git clone https://github.com/ag2byte/Booksearch-api
- Install the dependencies
npm install
- Add the environment variables in a
.env
file - Run the server
npm run dev
By default the server should run onlocalhost:5000