Coder Social home page Coder Social logo

nest-backend-bianca's Introduction

Running the container

# start the container // remember to put the .env file in the root directory
$ yarn up

# stop the container
$ yarn down

Use on browser

http://localhost:3008/

Test

# unit tests
$ yarn run test

# e2e tests
$ yarn run test:e2e

# test coverage
$ yarn run test:cov

mySQL Database Connection Instructions:

# copy the .env.template file to .env
$ cp .env.template .env

# edit the .env file and set the mySQL configuration variables

# make sure Docker Desktop is running, then start the container if it's not already running
$ yarn up

# start the application and connect to the database
$ yarn start:dev

API Paths

The API has the following paths:

/sum

This path accepts a POST request with a JSON body containing two numbers, number1 and number2. The API returns the sum of the two numbers.

Example request body:

{
  "number1": 40,
  "number2": 2
}

Example response body:

{
  "result": 42
}

/notes

This path accepts GET, POST, PATCH, and DELETE requests for managing notes. The API returns a list of notes in JSON format.

Example response body:

[
  {
    "id": 1,
    "title": "Note 1",
    "content": "This is the content of note 1"
  },
  {
    "id": 2,
    "title": "Note 2",
    "content": "This is the content of note 2"
  }
]

GET /notes

This path returns a list of all notes.

GET /notes/:id

This path returns the note with the given ID.

Example response body:

{
  "id": 1,
  "title": "Note 1",
  "content": "This is the content of note 1"
}

POST /notes

This path creates a new note with the given title and content.

Example request body:

{
  "title": "Note 3",
  "content": "This is the content of note 3"
}

PATCH /notes/:id

This path updates the note with the given ID with the new title and content.

Example request body:

{
  "title": "Note 3 (updated)",
  "content": "This is the updated content of note 3"
}

DELETE /notes/:id

This path deletes the note with the given ID.

Tasks

  • clone this repo
  • create a new local branch git switch -c alice-task-1 changing alice with your name
  • run yarn test and correct the error in the test file
  • add a POST controller that accepts a json {"number1": 40, "number2": 2} and returns the sum
    • important: the controller doesn't know how to sum, but a new service does. So write the sum service in the proper place
  • write a new test for this POST controller, testing different numbers
  • when done use git status to check that your changes are ok. Then use git add * and git commit -m "<put a short explanation here>" and git push
  • then go to the github project. You will see a button to make a new Pull Request out of your last commit. Do it and put me as the reviewer

nest-backend-bianca's People

Contributors

biancafrancini avatar all-well-it avatar nickstershovel avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.