Skip to content

amrimuf/basic-crud-rest-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🛠 Getting Started

# Clone this repository
git clone https://github.com/amrimuf/basic-crud-rest-api <folder-name>
cd <folder-name>

# Install dependencies for server
npm install

🚀 Configure Database

  • Create .env file in the main folder
  • Create DATABASE variable and assign your MongoDB Database URI value into it.
# Then, run the Express server
npm start

# Server runs on http:https://localhost:3000

🪟 Schema

const PostsSchema = new mongoose.Schema({
  title: {
    type: String,
  },
  author: {
    type: String,
  },
  desc: {
    type: String,
  },
})

📍 Endpoints

Get All Posts

GET api/posts

Get Single Post

GET api/posts/{id}

Delete Post

DELETE api/posts/{id}

Create Post

POST api/posts

# Request sample
# {
#   "title":"Lorem ipsum",
#   "author":"Andre",
#   "desc":"selamat membaca post ini"
# }

Update Post

PUT api/posts/{id}

# Request sample
# {
#   "title":"Updated Title",
#   "author":"Andre",
#   "desc":"selamat membaca post ini"
# }

About

using Node.js, Express, MongoDB + Postman

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published