DEV Community

Cover image for Deno REST API / MongoDB or PostgreSQL
Renato
Renato

Posted on

Deno REST API / MongoDB or PostgreSQL

Hi folks! This is my first project working with Deno. It's only a 'getting started' kind of project with a simple Rest API and MongoDB/PostgreSQL connection.

Installation

First we need to instal Deno following this link.
In order to use MongoDB or PostreSQL we include them with Docker implementation (Install Docker and Docker compose). Otherwise you can use your own database engine, and obviously you have to change your connection string.

Features

With this simple project you will be able to test /users endpoints (GET, POST, PUT and DELETE). And you can decide which db use only adding the query string db=mongo or db=postgres.

Running the project

If you will use docker-compose you have to run on the root of the project:

docker-compose -f docker/docker-compose.yaml up
Enter fullscreen mode Exit fullscreen mode

Await a few seconds until databases are ready and then run in another terminal window:

deno run -A --allow-net --allow-write --allow-read --allow-plugin --unstable index.ts
Enter fullscreen mode Exit fullscreen mode

After this the server has to start and you will be able to make requests.

Repository

You can find the repository code here

Note: I'm working on this project and I will be adding more details and explanations. Let me know if you have a doubt.

Top comments (0)