Skip to content

fahadtejani/RESTful-API-design

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RESTful-API-design

Designing a RESTful API that interacts with a MongoDB database, using Mongoose, based on the HTTP verbs passed to it.

Technologies learned and used:

  • Node.js
  • Express.js
  • MongoDB using Mongoose
  • Postman for testing
  • Body parser for incoming post requests
  • EJS for dynamic rendering
  • Express.js parameters for dynamic routing

Note to self:

  • HTTP verb => CRUD Operation:

    • GET => READ
    • POST => CREATE
    • PUT & PATCH => UPDATE
    • DELETE => DELETE
  • PUT creates a new entry into the database while PATCH just modifies the old entry rather than replacing it.

  • Define a mongoose schema before calling mongoose methods => " const articlesSchema = new mongoose.Schema({ title: String, content: String });"

  • The new collection's name passed through mongoose must be defined using a "Singular" name. Mongoose will update the name in the dadabase to "Plural" automatically. Fun fact, it uses Lodash package to do the singular to plural conversation in the background.
    For example "Article" becomes "Articles" and "Person" becomes "People"
    "const Article = mongoose.model('Article', articlesSchema);"

About

Designing a RESTful API

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published