Assignment description is in REQUIREMENTS.md.
Browserable API-UI is available at /docs endpoint.
Sample deployment is also available at https://qvik-assignment.efistokl.me/docs/ (with access to qvik.fi/qvik.com gmail users)
$ npm install
# development
$ npm run start
# watch mode
$ npm run start:dev
# production mode
$ npm run build
$ npm run start:prod
# docker
$ docker build -t qvik-api:test .
$ docker run --init -p 3000:3000 qvik-api:testNavigate to http://localhost:3000/docs to browse Swagger UI
# unit tests
$ npm run test
# e2e tests
$ npm run test:e2e
# test coverage
$ npm run test:cov-
GET /channel
-
GET /channel/:id
Gets the specific channel and also lists the articles for the channel
-
POST /channel
-
PATCH /channel/:id
-
DELETE /channel/:id
Channel-Article is a Many-To-Many relation.
-
PUT /channel/:id/postArticle/:articleId
-
PUT /channel/:id/unpostArticle/:articleId
When adding articles, only the URL is required. The Application will fetch the URL and calculate the word count (HTML tags stripped). Fetching the URLs and counting the words is to be done in the background after the article URL has been received.
-
POST /article
Returns newly created article object, word counting started in the background
-
GET /article/:id
wordCount property will be set if the word count was completed
- GET /article?minWordCount=...&maxWordCount=...
- Create articles and channels using POST /channel, POST /article
- Bind a few channels and articles using PUT /channel/:id/postArticle/:articleId
- Check bindings by querying data using GET /channel/:id, GET /article/:id
- Check word count values by querying articles using GET /article
- Search for articles by word range using GET /article with query params
-
In case the word count fails the current behavior is set to delete the "faulty" article. The "correct" behavior is not defined.
-
If the database is changed to something other than in-memory:
-
Add unit/e2e tests for graceful shutdown if word-counting is in progress.
-
Consider making "create article" + "word count" a transaction.
-
Website Word count services compared:
- This API
- https://wordcounter.net/website-word-count
- https://www.searchbloom.com/tools/bulk-web-page-word-count-checker/
| Article\Service | 1 | 2 | 3 |
|---|---|---|---|
| https://medium.com/@denys.pozniak/voice-transcoding-with-kamailio-and-rtpengine-241754a55894 | 468 | 416 | 430 |
| https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet | 1780 | 1752 | 1852 |
| https://staffeng.com/ | 382 | 367 | 376 |
| https://yle.fi/uutiset/osasto/news/at-home_covid_tests_to_hit_shops/11920645 | 1684 | 1538 | 1580 |
| https://www3.nhk.or.jp/nhkworld/ja/radio/ | 333 | 361 | 8 |