1.8.0 • Published 3 years ago

@jonreader/notes v1.8.0

Weekly downloads
-
License
ISC
Repository
github
Last release
3 years ago

Commitizen friendly semantic-release

Notes - Microservices Skill Test

Message for reviewer

Thanks for taking the time to review this test.

Whilst this app is a fully functioning API, some parts of the application are not as extensive as they would be in a real-world scenario (to avoid bloating the test).

The authentication middleware is mocked to function but does not use any external services. The unit tests (1 / 2) provide an example of working tests but are not application-wide.

Please note: To avoid convoluting this test the application requires a Mongodb database running locally on the default port of 27017 when developing or testing. You can run the application via docker to spin up a database if required (see below).

Semantic versioning

This repo makes use of both semantic commits and versioning.

Releases are automatically versioned via the commit messages using CI.

Running git commit or npm run commit will bring up an interactive commit helper in the console.

Run application (Docker)

  1. Clone the this repo
  2. cd into the repo directory
  3. Run docker-compose up

Spins up the node application and mongodb database. Runs port 80.

Development

  1. Clone the this repo
  2. cd into the repo directory
  3. Run npm install
  4. Run npm run dev

The application runs on a default port of 3000 when developing.

Testing

This application uses Jest to perform unit-testing and gather code coverage reports.

In a real-world scenario, this would be run per commit on release branches via CI.

  1. Clone the this repo
  2. cd into the repo directory
  3. Run npm test

API

Auth

The REST API requires an authorization Bearer token of 3.14159.

This can be seen in the examples below.

Create

Route

URIVerbDescription
/notePOSTCreates a note for a user

Data

PropertyTypeRequiredDescription
titlestringtrueNote title
descriptionstringtrueNote description
ownerstringtrueUUID of note owner

Example request:

curl \
	--location --request POST 'http://0.0.0.0/note' \
	--header 'Authorization: Bearer 3.14159' \
	--header 'Content-Type: application/json' \
	--data-raw '{
		"title": "Feed dog",
		"description": "Must remember to feed dog his food",
		"owner": "facb1e6d-381f-445d-ab72-46559f8adb24"
	}'

Example response:

{
  "message": "OK",
  "status": 200
}

Update

Route

URIVerbDescription
/note/{noteid}PATCHUpdates an existing note

Data

PropertyTypeRequiredDescription
titlestringoptionalNote title update
descriptionstringoptionalNote description update

Example request:

curl \
	--location --request PATCH '0.0.0.0/note/{noteid}' \
	--header 'Authorization: Bearer 3.14159' \
	--header 'Content-Type: application/json' \
	--data-raw '{"title":"Feed cat"}'

Example response:

{
  "message": "OK",
  "status": 200
}

List

Route

URIVerbDescription
/note/{userid}GETLists all notes belonging to an user

Example request:

curl \
	--location --request GET 'http://0.0.0.0/note/{userid}' \
	--header 'Authorization: Bearer 3.14159'

Example successful response:

{
  "message": "OK",
  "status": 200,
  "data": [
    {
      "_id": "612a42c1417683c61561b7dc",
      "title": "Feed cat",
      "description": "Must remember to feed cat her food",
      "owner": "facb1e6d-381f-445d-ab72-46559f8adb24",
      "created": 1630159553538,
      "updated": 1630160984723
    },
    {
      "_id": "612a4070417683c61561b7db",
      "title": "Feed dog",
      "description": "Must remember to feed dog his food",
      "owner": "facb1e6d-381f-445d-ab72-46559f8adb24",
      "created": 1630158960406,
      "updated": 1630158960406
    }
  ]
}

Example failure response

{
  "message": "Note with id {noteid} not found.",
  "status": 404
}

Delete

Route

URIVerbDescription
/note/{noteid}DELETEDeletes an existing note

Example request:

curl \
	--location --request DELETE '0.0.0.0/note/{noteid}' \
	--header 'Authorization: Bearer 3.14159'

Example successful response:

{
  "message": "OK",
  "status": 200
}

Example failure response:

{
  "message": "Note with id {noteid} not found.",
  "status": 404
}
1.8.0

3 years ago

1.7.3

3 years ago

1.7.2

3 years ago

1.7.1

3 years ago

1.7.0

3 years ago

1.6.0

3 years ago

1.5.0

3 years ago

1.4.0

3 years ago

1.3.0

3 years ago

1.2.0

3 years ago

1.1.0

3 years ago