This is a demo application for building a Node API. In this demo, we will do CRUD operations on Tweets.
Node APIs and MongoDB go hand-in-hand. This demo app uses:
- [Node.js]
- Express - Fast and low overhead web framework
- MongoDB on DigitalOcean
- MongoDB NodeJS Driver - Connect Node to MongoDB
The routes for this app are:
GET /tweets
: Get all tweetsPOST /tweets
: Create a tweetGET /tweets/<tweet_id>
: Get a single tweetPUT /tweets/<tweet_id>
: Update a tweetDELETE /tweets/<tweet_id>
: Delete a tweet
This demo can be deployed using the 1-click button above. If you want to deploy this to your DigitalOcean App Platform, follow these steps:
- Fork this repo so you have this on your GitHub account
- Create a MongoDB Database
- Login to your DigitalOcean App Platform Dashboard
- Click
Create App
- Search for your GitHub repo
- Remove the
npm run build
command from the build setup - Link the MongoDB database you just created
- Follow the steps to deploy
- Add your MongoDB DATABASE_URL to your environment variables
- Add your MongoDB CA_CERT to your environment variables
- Login to your DigitalOcean account
- Go to
Create
->Database
- Create a MongoDB Database
- Grab the connection URL
- Add an environment variable in App Platform called
DATABASE_URL