Skip to content

gokulkrishh/rest-api-deno

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

21 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Rest API's using deno runtime

What is deno?

  • Deno is secure run time for javascript & typescript

Goal

  • Create a simple todo rest api.
  • Use oak middleware for routing etc,
  • Expose routes for GET, POST, DELETE and PUT methods.

API list

  • GET - /
  • GET - /todos
  • POST - /todos (form data)
  • PUT - /todos/:id (form data)
  • DELETE - /todos/:id

Project Structure

.
β”œβ”€β”€ Dockerfile
β”œβ”€β”€ LICENSE
β”œβ”€β”€ README.md
β”œβ”€β”€ config.js
β”œβ”€β”€ controllers
β”‚Β Β  └── todos
β”‚Β Β      β”œβ”€β”€ delete.js
β”‚Β Β      β”œβ”€β”€ get.js
β”‚Β Β      β”œβ”€β”€ post.js
β”‚Β Β      └── put.js
β”œβ”€β”€ data
β”‚Β Β  └── todos.json
β”œβ”€β”€ fly.toml
β”œβ”€β”€ index.js
└── router.js

Installation & Run

Step 1: Install

curl -fsSL https://deno.land/x/install/install.sh | sh

Step 2: Run

deno run --allow-net --allow-read --allow-write ./index.js

Note:

--allow-net is to allow network access --allow-read is to allow read access to file system

Step 3: Open https://localhost:8080

Step 4 (optional): denon for deno like nodemon for node

deno install --unstable --allow-read --allow-run -f https://deno.land/x/denon/denon.ts

denon ./index.js

Note:

Denon uses .denonrc.json file in root for configuration

Step 5 (optional): To run using docker

docker build -t app . && docker run -it --init -p 8080:8080 app

Deployment

Deployed using https://fly.io/ with docker.

Deployment Steps

MIT Licensed

@gokulkrishh

About

πŸ¦–Todo list rest API using deno runtime!

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

 

Packages

No packages published