The backend will expose an HTTP API to search for GitHub repositories. This can be done with the GitHub API which is described here.
npm install, create a
variables.env file in the project's root directory. Normally, environment variables aren't committed, and in fact they're ignored in
.gitignore. However, just for testing, you can add the following to that file's contents:
API_RATE_LIMIT_PER_MINUTE=100 API_X_CLIENT_KEY=YWIxOGU5ZWY0ZDAzZjdmNjA1YTUxNGM3ZWFiNWI5MDA3OTFmYTFlMmY3N2JiNzZj GITHUB_API_TOKEN= NODE_ENV=development PORT=3000
API_RATE_LIMIT_PER_MINUTE is being ignored at the moment since we're not rate limited by GitHub in this test scenario.
GITHUB_API_TOKEN can be empty as well.
Now you're ready to
npm start, which runs
nodemon bin/www/. Use Insomnia/Postman or maybe cURL to interact with the server, as that makes
DELETE requests easier to test.
HTTP Basic Authentication is being used in its simplest form. To pass validation, use the test credentials:
username: test password: test
As an alternative, you can include the HTTP header
X-Client-Key in every request, with the same value as specific in the environment variable
GET /search/<search-keywords>: takes a search term and returns a list of repositories (don't implement pagination).
POST /bookmarks/<repository-id>: allows the bookmarking of a repository by its id. The bookmark could be simply saved locally.
GET /bookmarks: gets all bookmarked repositories.
DELETE /bookmarks/<repository-id>: delete a bookmark (bonus feature).
Note that bookmarks are global, we don't need a concept of different users.
Documentation is automatically generated from the inlined JSDoc comments. Run
npm run docs and then open the
docs/index.html file to see the documentation for the 2 modules.
npm run generate-x-client-keyisn't a proper random method, in a real world scenario it wouldn't make sense.