Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
 
 

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

README.md

Outline

Serverless MongoDB HTTP API with Mongoose and Bluebird Promises

This example demonstrate how to use a MongoDB database with aws and serverless.

Using Mongoose ODM and Bluebird for Promises.

Use Cases

  • NoSQL CRUD API

Setup

npm install
serverless deploy

Usage

In handler.js update the mongoString with your mongoDB url.

Create

curl -XPOST -H "Content-type: application/json" -d '{
   "name" : "John",
   "firstname" : "Doe",
   "city" : "Toronto",
   "birth" : "01/01/1990"
}' 'https://2c8cx5whk0.execute-api.us-east-1.amazonaws.com/user/'
{"id": "590b52ff086041000142cedd"}

READ

curl -XGET -H "Content-type: application/json" 'https://2c8cx5whk0.execute-api.us-east-1.amazonaws.com/user/590b52ff086041000142cedd'
[
  {
    "_id": "5905e2fbdb55f20001334b3e",
    "name": "John",
    "firstname": "Doe",
    "birth": null,
    "city": "Toronto",
    "ip": "01/01/1990",
    "__v": 0
  }
]

UPDATE

curl -XPUT -H "Content-type: application/json" -d '{
   "name" : "William",
   "firstname" : "Smith",
   "city" : "Miami",
   "birth" : "01/01/2000"
}' 'https://2c8cx5whk0.execute-api.us-east-1.amazonaws.com/user/590b52ff086041000142cedd'
"Ok"

DELETE

curl -XDELETE -H "Content-type: application/json" 'https://2c8cx5whk0.execute-api.us-east-1.amazonaws.com/user/590b52ff086041000142cedd'
"Ok"
Morty Proxy This is a proxified and sanitized view of the page, visit original site.