Created by gh-md-toc
Create a minimal expression (from your perspective) of a blogging platform. (Only the backend)
Full detailed instructions here: challenge-node-js.pdf
The different technologies that we used in the project are:
- Node JS
- Express JS
- MongoDB
Additional to those techs, we add some components and development dependencies:
- Nodemon as development server.
- Awilix to handle DI ascross the app layers.
- Mocha as a testing framework.
- Mongoose for object data modeling.
- ESLint to improve code quality.
- Other depdencies: CodeCov, supertest, dotenv, etc.
To run the project locally cover this topics.
- Node version v10.x.x. (v10.15.3 was used)
- Yarn
- MongoDB. (get from here)
- Some sort of REST Client. (Advance REST Client, Insomnia, etc)
Look for .env.example
, copy and rename to .env
, and replace the values with these values:
REST_API_PORT=3000
MONGODB_HOST=localhost
MONGODB_PORT=27017
MONGODB_DBNAME=blog
TEST_MONGODB_HOST=localhost
TEST_MONGODB_PORT=27017
TEST_MONGODB_DBNAME=blog-test
๐พJust run yarn
command and thats it.
๐ Here is the list of commands available for the project.
Name | Command | Description |
---|---|---|
start | yarn start |
Starts the /api endpoint, go open your http://localhost:3000 and enjoy. ๐ |
lint | yarn run lint |
Runs the linter task to look for code smells and improvements. ๐น |
test | yarn run test |
Runs the test suite for the blogging app. ๐ค |
๐ฐ For the MVP of the Blogging App we cover these requirements:
- Http server developed in Node.
-
/api/posts
endpoints that basic REST operations.
๐ข /api/posts
REST operations.
Endoint | Type | Description | Params/Body | Response |
---|---|---|---|---|
/api/posts |
GET | Get the list of posts. | Param: ?q= (optional) |
List of filtered posts. |
/api/posts |
POST | Create a new post. | Body: <Post object> |
Persisted post object. |
/api/posts/:id |
GET | Get a post by id. | Param: :id |
Post object. |
/api/posts/:id |
DELETE | Remove a post. | Param: :id |
Remove post object. |
/api/posts/:id |
PUT | Update a post. | - Param: :id |
Update post object. |
Body: <attrs object> |
๐พ The blog
database contains a single collection with the post
definition.
Field | Type | Description |
---|---|---|
title | String | The title |
text | String | The text |
author | String | The status enum: draft, private, public |
๐ถ For additional flavor to the blogging app we add these:
- A built-in enum attribute on mongoose, to support the post status. #๏ธโฃ
- Mocha tests to cover the blog post CRUD operations. โ๏ธ
- Linter to look for code smells and improvements. ๐น
- Text search across all of the post attributes. (single
q=
param to rule them all. ๐)
๐ฆ For future steps we can consider these items:
- Add more tests to cover the diferent layers of the app. (services, models)
- Create a UI, maybe in React, to use the
/api
endpoint. - Add security and user identification.