An open API service indexing awesome lists of open source software.

https://github.com/wpcodevo/deno-mongodb

In this tutorial, we'll cover how to build a Deno API that supports CRUD operations and stores data in a MongoDB database. The example API will run on an Oak middleware framework that will include routes to create, retrieve, update, and delete documents in the database.
https://github.com/wpcodevo/deno-mongodb

crud crud-api deno denoapi mongodb oak oakframework rest-api restful zod

Last synced: 15 days ago
JSON representation

In this tutorial, we'll cover how to build a Deno API that supports CRUD operations and stores data in a MongoDB database. The example API will run on an Oak middleware framework that will include routes to create, retrieve, update, and delete documents in the database.

Awesome Lists containing this project

README

        

# RESTful API with Deno, Oak, and MongoDB

## 1. How to Setup and Use MongoDB with Deno

![How to Setup and Use MongoDB with Deno](https://codevoweb.com/wp-content/uploads/2022/09/How-to-Setup-and-Use-MongoDB-with-Deno.webp)

When it comes to learning a new framework or language, the first thing that comes to our mind is creating a Todo app that has all the basic CRUD functionalities. So in this article, we will create a Todo CRUD RESTful API in a Deno environment that runs on an Oak middleware server and uses a MongoDB database.

### Topics Covered

- What is Deno Oak Middleware Framework?
- Installing Deno
- Setup Oak Middleware and Routing
- Setup MongoDB Server with Docker
- Connect Deno to MongoDB Server
- Create the MongoDB Database Models
- Create the Request Validation Schemas
- Create the Route Controllers
- Add the Dependency Imports
- Create Document Controller
- Update Document Controller
- Read a Single Document Controller
- Read All Documents Controller
- Delete Document Controller
- Export the Controllers
- Create/Merge the API Routes with Oak
- Test the Deno API with Postman
- Create a new document
- Update an existing document
- Get a single document
- Get all the documents
- Delete a document

Read the entire article here: [https://codevoweb.com/setup-and-use-mongodb-with-deno](https://codevoweb.com/setup-and-use-mongodb-with-deno)

## 2. How to Setup and Use MongoDB with Deno

![How to Setup and Use MongoDB with Deno](https://codevoweb.com/wp-content/uploads/2022/09/How-to-Setup-and-Use-MongoDB-with-Deno.webp)

When it comes to learning a new framework or language, the first thing that comes to our mind is creating a Todo app that has all the basic CRUD functionalities. So in this article, we will create a Todo CRUD RESTful API in a Deno environment that runs on an Oak middleware server and uses a MongoDB database.

### Topics Covered

- What is Deno Oak Middleware Framework?
- Installing Deno
- Setup Oak Middleware and Routing
- Setup MongoDB Server with Docker
- Connect Deno to MongoDB Server
- Create the MongoDB Database Models
- Create the Request Validation Schemas
- Create the Route Controllers
- Add the Dependency Imports
- Create Document Controller
- Update Document Controller
- Read a Single Document Controller
- Read All Documents Controller
- Delete Document Controller
- Export the Controllers
- Create/Merge the API Routes with Oak
- Test the Deno API with Postman
- Create a new document
- Update an existing document
- Get a single document
- Get all the documents
- Delete a document

Read the entire article here: [https://codevoweb.com/setup-and-use-mongodb-with-deno](https://codevoweb.com/setup-and-use-mongodb-with-deno)

## 3. Authentication with Bcrypt, JWT, and Cookies in Deno

![ Authentication with Bcrypt, JWT, and Cookies in Deno](https://codevoweb.com/wp-content/uploads/2022/09/Authentication-with-Bcrypt-JWT-and-Cookies-in-Deno.webp)

To demonstrate how JWT authentication works in Deno, we'll build an API that runs on an Oak middleware server and uses a MongoDB database. Then, we'll add an authentication guard where only users with a valid JSON Web Token will be able to access the protected routes. Also, we'll make the passwords secure by hashing them with the Bcrypt library.

### Topics Covered

- Setup the API Project
- Create the Database Model with MongoDB
- Create the Validation Schemas with Zod
- Load the Environment Variables in Deno
- Create Utility Functions
- Function to Sign and Verify the JSON Web Token
- Function to Hash and Verify the Passwords
- Function to Omit Fields from an Object
- Create the API Route Controllers
- Register User Controller
- Login User Controller
- Logout User Controller
- Request Authenticated User's Profile Controller
- Create the Middleware Guard
- Create the API Routes
- Add the Routes to the Deno Application

Read the entire article here: [https://codevoweb.com/authentication-with-bcrypt-jwt-and-cookies-in-deno](https://codevoweb.com/authentication-with-bcrypt-jwt-and-cookies-in-deno)

## 4. Build a Complete Deno CRUD RESTful API with MongoDB

![Build a Complete Deno CRUD RESTful API with MongoDB](https://codevoweb.com/wp-content/uploads/2022/09/Build-a-Complete-Deno-CRUD-RESTful-API-with-MongoDB.webp)

In this tutorial, we'll cover how to build a Deno API that supports CRUD operations and stores data in a MongoDB database. The example API will run on an Oak middleware framework that will include routes to create, retrieve, update, and delete documents in the database.

### Topics Covered

- Run the Deno + MongoDB CRUD API Locally
- Setup the Deno CRUD API
- Create the MongoDB Model
- Create the Validation Schemas with Zod
- Create the Oak Middleware Route Handlers
- Add document handler
- Update document handler
- Get a single document handler
- Get all documents handler
- Delete a document handler
- Create the Oak Middleware Routes
- Register the API Routes

Read the entire article here: [https://codevoweb.com/deno-crud-restful-api-with-mongodb](https://codevoweb.com/deno-crud-restful-api-with-mongodb)