Rest API's using deno runtime
What is deno?
- Deno is secure run time for javascript & typescript
- Create a simple todo rest api.
- Use oak middleware for routing etc,
- Expose routes for GET, POST, DELETE and PUT methods.
GET
- /GET
- /todosPOST
- /todos (form data)PUT
- /todos/:id (form data)DELETE
- /todos/:id
.
βββ 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
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
Deployed using https://fly.io/ with docker.