DEV Community

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

Posted on

3

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.

Heroku

Simplify your DevOps and maximize your time.

Since 2007, Heroku has been the go-to platform for developers as it monitors uptime, performance, and infrastructure concerns, allowing you to focus on writing code.

Learn More

Top comments (0)

Billboard image

Create up to 10 Postgres Databases on Neon's free plan.

If you're starting a new project, Neon has got your databases covered. No credit cards. No trials. No getting in your way.

Try Neon for Free →

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay