atomkraft
Dead simple blog engine based on YAML atoms.
Last updated a year ago by kxpvcr .
AGPL-3.0 · Original npm · Tarball · package.json
$ cnpm install atomkraft 
SYNC missed versions from official npm registry.

Conrad Connect challenge

The backend will expose an HTTP API to search for GitHub repositories. This can be done with the GitHub API which is described here.

Getting started

After 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

Note that 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 POST and DELETE requests easier to test.

Authentication

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 API_X_CLIENT_KEY.

Endpoints

  • 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.

Bonus features

  • [x] Add an endpoint to remove a bookmark.
  • [x] Add basic authentication.
  • [x] Document the API.
  • [x] Test the /bookmarks route.
  • [ ] Test the /search route.
  • [ ] Can you write tests that don't rely on the GitHub API being available?
    • Use their schema with offline files?
    • Intercept requests with nock?

Docs

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.

Notes

  • npm run generate-x-client-key isn't a proper random method, in a real world scenario it wouldn't make sense.
  • I thought about using a tool like Swagger/Apiary/Slate to document the API, but I'm fond of JSDoc, so went with it.
  • I try to follow 12factor and nodebestpractices as much as possible, and that means I tend to favor my existing project boilerplate.
  • I'm using LevelDB as a fake caching mechanism.

Current Tags

  • 0.0.1                                ...           latest (a year ago)

1 Versions

  • 0.0.1                                ...           a year ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 1
Last Day 0
Last Week 0
Last Month 0
Dependencies (9)
Dev Dependencies (10)
Dependents (0)
None

Copyright 2014 - 2017 © taobao.org |