<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Haaris Iqubal</title>
    <description>The latest articles on DEV Community by Haaris Iqubal (@haarisiqubal).</description>
    <link>https://dev.to/haarisiqubal</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F396902%2F15dbba43-5ac7-4ed9-89aa-f87aa380b28c.png</url>
      <title>DEV Community: Haaris Iqubal</title>
      <link>https://dev.to/haarisiqubal</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/haarisiqubal"/>
    <language>en</language>
    <item>
      <title>Creating a Drawing App using Pencil Kit and Core Data in SwiftUI</title>
      <dc:creator>Haaris Iqubal</dc:creator>
      <pubDate>Tue, 07 Dec 2021 17:34:33 +0000</pubDate>
      <link>https://dev.to/recoding/creating-a-drawing-app-using-pencil-kit-and-core-data-in-swiftui-1n98</link>
      <guid>https://dev.to/recoding/creating-a-drawing-app-using-pencil-kit-and-core-data-in-swiftui-1n98</guid>
      <description>&lt;p&gt;Building app based on Apple Pencil require much cumbersome process but since the introduction of &lt;a href="https://developer.apple.com/documentation/pencilkit"&gt;PencilKit&lt;/a&gt; in WWDC 20 it now easier to add Canvas and Apple Pencil Support to your app. In this article we gonna take a look Apple PencilKit in action along with we’ll also add core data functionality to store our drawing inside the device and for creating the interface we will using Swift UI.&lt;/p&gt;

&lt;p&gt;Our application look somewhat like this after we complete the code.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ZnrgOfR1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g9t736qqe81z0htf8qa1.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ZnrgOfR1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g9t736qqe81z0htf8qa1.gif" alt="Drawing App SwiftUI" width="480" height="340"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In order to create this application new start a new Xcode Project. Select iOS App and then select Application icon. Then type your project name and check out we are using fully SwiftUI with SwiftUI Lifecycle and we also use core data so check mark on it also. Then create the project. Xcode automatically create some boilerplate codes so lets just delete some codes.&lt;/p&gt;

&lt;p&gt;Then inside our xc data model file we need to create a new entity called as Drawing. Then inside it we need to create attributes like ID which of type U U I D. Then Title which is of type String. And canvas Data which is of type Binary Data this will hold our drawing data.&lt;/p&gt;

&lt;p&gt;Then inside our Content View file, we need to fetch the data from the core data using Fetch Request function for this you should need to import Core Data inside the function we need to add our entity which we just created and then we can add variable as drawing which help to refer inside our view this is of type Fetched Result which hold our Drawing Entity.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import CoreData
struct ContentView: View {
...
@FetchRequest(entity: Drawing.entity(), sortDescriptors: []) var drawings: FetchedResults&amp;lt;Drawing&amp;gt;
...
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then inside our View we can crate For Each function this will take our fetched drawings as input and for each drawing it will layout then as Text which will have title as a value.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ForEach(drawings){drawing in                        NavigationLink(destination: DrawingView(id: drawing.id, data: drawing.canvasData, title: drawing.title), label: {                            Text(drawing.title ?? "Untitled")                        })                    }

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then we need to create a Button this button will help us to open a sheet view inside which we create a new canvas for the label we add H Stack inside it we add image and text&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Button(action: {                        
self.showSheet.toggle()                    
}, label: {                        
HStack{                            
Image(systemName: "plus")                            
Text("Add Canvas")}                    
})                    
.foregroundColor(.blue)                    
.sheet(isPresented: $showSheet, content: {                        AddNewCanvasView().environment(\.managedObjectContext, viewContext)                    })
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then for action we just need to toggle our show sheet state which we need to create as State private var show sheet which have initial value as false&lt;/p&gt;

&lt;p&gt;&lt;code&gt;@State private var showSheet = false&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Create a new SwiftUI File as Add New Canvas View. Inside the Canvas View we need to require Environment managed Object Context and Presentation Mode from previous view.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// AddNewCanvasView.Swift
@Environment (\.managedObjectContext) var viewContext    @Environment (\.presentationMode) var presentationMode
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then we wrap our view inside Navigation View and add Form inside it. Then add section inside it add Text Field. Create a State for our Text Field which will be empty string.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// AddNewCanvasView.Swift
@State private var canvasTitle = ""
var body: some View {        
NavigationView{            
Form{                
Section{                    
TextField("Canvas Title", text: $canvasTitle)                
}
}
.navigationViewStyle(StackNavigationViewStyle())            .navigationTitle(Text("Add New Canvas"))}
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then we add Navigation Bar Item both will have Button on the leading we add cancel button this will does action presentation Mode wrapped value dismiss this will close our sheet then add button image as label. While on the trailing side we add create button this will perform saving task. Inside its action we check if the canvas title is not empty the we perform this function. Inside the function we create our drawing context then provide the appropriate data to it then we wrapped our sheet using dismiss function.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// AddNewCanvasView.Swift

Form{                
Section{                    
TextField("Canvas Title", text: $canvasTitle)                }            }            
.navigationViewStyle(StackNavigationViewStyle())            .navigationTitle(Text("Add New Canvas"))            .navigationBarItems(leading: Button(action: {                presentationMode.wrappedValue.dismiss()            }, label: {                Image(systemName: "xmark")            }), 
trailing: Button(action: {                
if !canvasTitle.isEmpty{                    
let drawing = Drawing(context: viewContext)                    drawing.title = canvasTitle
drawing.id = UUID()                                        
do {try viewContext.save()}                    
catch{print(error)}                                        self.presentationMode.wrappedValue.dismiss()                }            }, label: {                
Text("Save")            
}))
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then on the Content View file we add our Add New Canvas View inside our sheet content.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// ContentView.swift
.sheet(isPresented: $showSheet, content: {                        AddNewCanvasView().environment(\.managedObjectContext, viewContext)                    })

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So finally we can see that our data is saving now let tackle the our Canvas for Drawing. We need to create new Folder called as Canvas inside it create a Swift File and named it as Drawing Canvas View Controller. Inside the File import Swift Ui and Pencil Kit.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import SwiftUI
import PencilKit

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then create the class same as file name the class will conform to UI View Controller. Then we create some variable canvas which conform to PK Canvas View Class inside the we create a constant view which will initialize the Pk Canvas View class.&lt;/p&gt;

&lt;p&gt;Then our view will have input policy as any input. Then we can add ability to zoom our canvas to only 1 so we can not zoom in our using pinch gesture. Then finally we negate the translate Auto resizing of the constraint. Then we will return our View. Then create new variable tool Picker which conform to Pk Tool Picker. Then create a constant tool pick which initialize Pk Tool Picker Class . We set the tool picker observer to self.&lt;/p&gt;

&lt;p&gt;As all the view controller have View Did Load Function which will load on view start we add this to super view Did Load function. Before it we need to create the a drawing Data which will initialize our canvas with data. Then then create a variable drawing change which will conform to Data and return to Void data.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// DrawingCanvasViewController.swift
class DrawingCanvasViewController: UIViewController {    
lazy var canvas: PKCanvasView = {        
let view = PKCanvasView()        
view.drawingPolicy = .anyInput        
view.minimumZoomScale = 1        
view.maximumZoomScale = 1        view.translatesAutoresizingMaskIntoConstraints = false        
return view    }()        
lazy var toolPicker: PKToolPicker = {        
let toolPicker = PKToolPicker()        
toolPicker.addObserver(self)        
return toolPicker    }()        
var drawingData = Data()    
var drawingChanged: (Data) -&amp;gt; Void = {_ in}
override func viewDidLoad() {        
super.viewDidLoad()        
view.addSubview(canvas)        
NSLayoutConstraint.activate([                                        canvas.leadingAnchor.constraint(equalTo: view.leadingAnchor),                                        canvas.trailingAnchor.constraint(equalTo: view.trailingAnchor),                                        canvas.topAnchor.constraint(equalTo: view.topAnchor),                                        canvas.bottomAnchor.constraint(equalTo: view.bottomAnchor)])        toolPicker.setVisible(true, forFirstResponder: canvas)        toolPicker.addObserver(canvas)        
canvas.delegate = self        
canvas.becomeFirstResponder()        
if let drawing = try? PKDrawing(data: drawingData){            canvas.drawing = drawing        
}    
}
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We need to extent our Drawing Canvas View Controller Delegate to Pk Tool Picker Observer and PK Canvas View Delegate. Inside it we add out canvas View Drawing Did Change which will take care of all the changes happen inside the view and gives us output which help to know that data has change so we can save the data on the go. Inside the this function we add out Drawing Changed variable inside it will take our canvas drawing data.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// DrawingCanvasViewController.swift
extension DrawingCanvasViewController:PKToolPickerObserver, PKCanvasViewDelegate{    
func canvasViewDrawingDidChange(_ canvasView: PKCanvasView) {        drawingChanged(canvasView.drawing.dataRepresentation())    
}}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then create a new Swift which will contain our Canvas View as UI Representable View.Then create a struct which is conform to UI View Controller Representable. Inside it we will create our managed Object Context as view Context. Then we create some boiler plate function update Ui View and make UI View. Inside the update UI View Controller we set our Ui view controller drawing data to data variable.&lt;/p&gt;

&lt;p&gt;Then create a struct which is conform to UI View Controller Representable. Inside it we will create our managed Object Context as view Context. Then we create some boiler plate function update Ui View and make UI View. Inside the update UI View Controller we set our Ui view controller drawing data to data variable. We make our UI Controller Type as Type alias of Drawing Canvas View Controller. Then we create some variable Data and ID which data require more upper hierarchy view. Then inside our make UI View Controller we can set our View controller to Drawing Canvas View Controller&lt;/p&gt;

&lt;p&gt;Inside it we make request to NS Fetch Request then put inside our Drawing Entity which equals to Drawing dot fetch function. The we can predicate which will matches the id we provide to id inside our core data and then set our NS Fetch request to predicate. Then inside our do try closure we get our result. The result will output as object we set first value which we will get. Then we save the value of only the canvas Data attribute. Then again inside the do try closure we save our changes. Or we catch any error print that error. Then finally return our view controller.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// DrawingCanvasView.swift
import SwiftUI
import CoreData
import PencilKit
struct DrawingCanvasView: UIViewControllerRepresentable { @Environment(\.managedObjectContext) private var viewContext
func updateUIViewController(_ uiViewController: DrawingCanvasViewController,context: Context) { uiViewController.drawingData = data }
typealias UIViewControllerType = DrawingCanvasViewController
var data: Data 
var id: UUID
func makeUIViewController(context: Context) -&amp;gt; DrawingCanvasViewController { 
let viewController = DrawingCanvasViewController()
viewController.drawingData = data viewController.drawingChanged = {data in let request: NSFetchRequest&amp;lt;Drawing&amp;gt; = Drawing.fetchRequest()
let predicate = NSPredicate(format: “id == %@”, id as CVarArg) request.predicate = predicate do{ let result = try
viewContext.fetch(request) let obj = result.first
obj?.setValue(data, forKey: “canvasData”) 
do{ try viewContext.save() } catch{ print(error) } } 
catch{ print(error) } } 
return viewController 
}}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Finally we add our DrawingCanvasView.swift inside our Drawing View Swift file. And when we run our app inside the simulator we can see that our app is working fine.&lt;br&gt;
Code and Video are mentioned below 👇&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/f2SHsHsjTGM"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

</description>
      <category>swift</category>
      <category>ios</category>
    </item>
    <item>
      <title>Deploying Deno App on Heroku Server</title>
      <dc:creator>Haaris Iqubal</dc:creator>
      <pubDate>Tue, 30 Nov 2021 13:05:26 +0000</pubDate>
      <link>https://dev.to/recoding/deploying-deno-app-on-heroku-server-1e2m</link>
      <guid>https://dev.to/recoding/deploying-deno-app-on-heroku-server-1e2m</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--SnCYIUlN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x3q7brto8zi21b2vv3ys.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--SnCYIUlN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x3q7brto8zi21b2vv3ys.jpeg" alt="Deploy Deno Apps on Heroku Server" width="880" height="495"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Today we gonna unravel one of import question regarding Deno Deployment, as we gonna learn how to deploy Deno application inside Heroku Server so without further ado let’s get started.&lt;/p&gt;

&lt;p&gt;First we need to create a template Application on our device so create app.ts file in your directory where you want to create the file.&lt;/p&gt;

&lt;p&gt;To setup our application we gonna require Oak third party for serving our application and Flags from Deno Module which will help to setup our Port.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Importing Module
import {Application, Router} from 'https://deno.land/x/oak/mod.ts';
import * as flags from 'https://deno.land/std/flags/mod.ts';
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;After importing our module we can setup our flags to check our port as if we are using local host then our server will run on localhost:8000, or else when we deploy our application we can use normal URL to access our app.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Setting up port
const {args, exit} = Deno;
const DEFAULT_PORT = 8000;
const argPort = flags.parse(args).port;
const port = argPort ? Number(argPort) : DEFAULT_PORT;
if (isNaN(port)){
console.log("This is not port number");
exit(1);
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;After setting our port we can now take help of Oak to provide application layer to our app. So we need to set our application and router.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Initializing App and Router
const app = new Application();
const router = new Router();
// Set our router to handle request
router.get('/',(ctx) =&amp;gt; {
ctx.response.body = 'This is main page';
})
.get('/home',(ctx)=&amp;gt;{
ctx.response.body = "This is home page";
})
// Passing router inside our application as middleware
app.use(router.routes());
app.use(router.allowedMethods());
// Setting our app to listen to port
await app.listen({port: port});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;After setting our app.ts file its gonna look something like this&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Importing Module
import {Application, Router} from 'https://deno.land/x/oak/mod.ts';
import * as flags from 'https://deno.land/std/flags/mod.ts';
// Setting up port
const {args, exit} = Deno;
const DEFAULT_PORT = 8000;
const argPort = flags.parse(args).port;
const port = argPort ? Number(argPort) : DEFAULT_PORT;
if (isNaN(port)){
console.log("This is not port number");
exit(1);
};
// Initializing App and Router
const app = new Application();
const router = new Router();
// Set our router to handle request
router.get('/',(ctx) =&amp;gt; {
ctx.response.body = 'This is main page';
})
.get('/home',(ctx)=&amp;gt;{
ctx.response.body = "This is home page";
})
// Passing router inside our application as middleware
app.use(router.routes());
app.use(router.allowedMethods());
// Setting our app to listen to port
await app.listen({port: port});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;You can check that our app is working or not inside your device as type “deno run -A app.ts” inside your terminal try to open up your browser type the url as “localhost:8000”.&lt;/p&gt;

&lt;p&gt;Now to server our App on heroku we also need to create a Procfile which will hold our Deno run command and all the flags along with Port.&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;web: deno run --allow-net=:${PORT} --cached-only app.ts --port=${PORT}&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;Now you can add commit your code using git follow these command&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ git init
$ git add .
$ git commit -m "Created a Deno app Deploying on Heroku"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Before deploy your code on Heroku You need to create a buildpack inside your Heroku account as Heroku still not support official Deno deployment to here is some trick to deploy it. Inside your terminal type&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ heroku create --buildpack https://github.com/chibat/heroku-buildpack-deno.git
$ git push heroku master
$ heroku open
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Now you can see that your app is working Fine as you intended. You can clone our code from Github using the link 👇.&lt;/p&gt;


&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--566lAguM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev.to/assets/github-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/recoding-io"&gt;
        recoding-io
      &lt;/a&gt; / &lt;a href="https://github.com/recoding-io/deno-on-heroku-server"&gt;
        deno-on-heroku-server
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      This code will allow to Deploy Deno application on Heroku Server
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="MD"&gt;
&lt;h1&gt;
Deploy Deno on Heroku&lt;/h1&gt;
&lt;p&gt;This is project created on deno and help to deploy code on deno.&lt;/p&gt;
&lt;h2&gt;
Project Intro&lt;/h2&gt;
&lt;p&gt;Inside this project we are using Deno modules like&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://deno.land/x/oak" rel="nofollow"&gt;Oak&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://deno.land/std/flags" rel="nofollow"&gt;Flags&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
Code to Deploy on Heroku Server&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Before deploying you need to initialize Git Repo and Commit your code&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="snippet-clipboard-content position-relative overflow-auto"&gt;&lt;pre&gt;&lt;code&gt;
$ heroku create --buildpack https://github.com/chibat/heroku-buildpack-deno.git
$ git push heroku master
$ heroku open

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h2&gt;
Full step by step tutorial&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/recoding-io/deno-on-heroku-server"&gt;Youtube&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;

  &lt;/div&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/recoding-io/deno-on-heroku-server"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;



&lt;p&gt;While if you like to watch full tutorial you can check our 📹 👇.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/nkBQ6iJBxck"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>deno</category>
      <category>javascript</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Build URL Shortener Using Deno</title>
      <dc:creator>Haaris Iqubal</dc:creator>
      <pubDate>Tue, 30 Jun 2020 15:51:56 +0000</pubDate>
      <link>https://dev.to/recoding/build-url-shortener-using-deno-5a59</link>
      <guid>https://dev.to/recoding/build-url-shortener-using-deno-5a59</guid>
      <description>&lt;p&gt;
Welcome again today we are creating a URL shortener application using Deno. As URL shortener simply create a unique id with respective full length URL you pass. So without further ado let’s get started …

First we need to create our &lt;a href="https://medium.com/recoding/basic-routing-app-in-deno-using-oak-51caa06d2ee5"&gt;Oak application&lt;/a&gt; along with Router so first we need to import our Oak module from its URL inside it pass application and router then we need to initiate our application and router class, after initiating we need to create some route to handle request on some GET and POST method. After create our router we need to pass our router inside our application as middleware and we can let listen our server any port we want. So our final code will look something like.
&lt;/p&gt;

&lt;pre&gt;

// Importing Modules
import {Application, Router} from 'https://deno.land/x/oak/mod.ts';
// Initiating App and Router
const app = new Application();
const router = new Router();
// Handling Requests
router.get('/',async (ctx) =&amp;gt; {
})
.post('/post',async (ctx)=&amp;gt;{
})
.get('/:shortId', async(ctx) =&amp;gt; {
});
// Passing Router as middle ware inside the app
app.use(router.routes());
app.use(router.allowedMethods());
// Logging that server is running at PORT 8000
console.log('App is listening to port 8000');
await app.listen({port: 8000});

&lt;/pre&gt;

&lt;p&gt;
After setting our application we can set view engine inside our Deno app. We are using EJS as our Views, so inside our view engine first we need to import viewEngine, engineFactory and adapterFactory. Then we need to set our engineFactory as EJS Engine and AdapterFactory as OakAdapter. So our code looks something like this …
&lt;/p&gt;

&lt;pre&gt;

// Importing Modules
import {viewEngine,
engineFactory,
adapterFactory} from 'https://deno.land/x/view_engine/mod.ts';
// Setting up View Engine
const ejsEngine = engineFactory.getEjsEngine();
const oakAdapter = adapterFactory.getOakAdapter();
app.use(viewEngine(oakAdapter,ejsEngine));

&lt;/pre&gt;

&lt;p&gt;
Now we can initialize our MongoClient, we are using Mongo local database while our can use online repository from mongo website you just need to pass the URI inside connectWithUri function and you database will work. Inside our application we are setting name of Database as “shortener” and collection as “url” you can change whatever you want.
&lt;/p&gt;

&lt;pre&gt;

import {MongoClient} from 'https://deno.land/x/mongo@v0.8.0/mod.ts';
// Setting up mongo client
const client = new MongoClient();
// Connect Mongo Client to localhost
client.connectWithUri('mongodb://localhost:27017');
// Setting up name of Database
const db = client.database('shortener');
// Setting up name of collection
const urlCollection = db.collection('url');

&lt;/pre&gt;

&lt;p&gt;

We can now setup our views we aren using Bootstrap for styling our application. And we are passing a form input type of text and button with type submit. Our form is method of POST and it has enctype of multipart/form-data. Then we can create our table which can fill when data pass through it. So create a new index.ejs file and pass the following code inside it

&lt;/p&gt;

&lt;pre&gt;

&amp;lt; !DOCTYPE html &amp;gt;
&amp;lt; html lang="en" &amp;gt;
&amp;lt; head &amp;gt;
&amp;lt; meta charset="UTF-8" &amp;gt;
&amp;lt; meta name="viewport" content="width=device-width, initial-scale=1.0" &amp;gt;
&amp;lt; title &amp;gt; URL SHORTENER &amp;lt; /title &amp;gt;
&amp;lt; !-- CSS only -- &amp;gt;
&amp;lt; link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css" integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk" crossorigin="anonymous" &amp;gt;
&amp;lt; /head &amp;gt;
&amp;lt; body &amp;gt;
&amp;lt; div class="container" &amp;gt;
&amp;lt; br / &amp;gt;
&amp;lt; h1 &amp;gt; URL SHORTENER &amp;lt; /h1 &amp;gt;
&amp;lt; form method="POST" enctype="multipart/form-data" action="/post" &amp;gt;
&amp;lt; div class="form-row" &amp;gt;
&amp;lt; div class="col-md-10 mb-3" &amp;gt;
&amp;lt; input type="text" class="form-control" name="url" placeholder="Enter your URL" required&amp;gt;
&amp;lt; /div &amp;gt;
&amp;lt; div class="col-md-2 mb-3" &amp;gt;
&amp;lt; input class="btn btn-primary" type="button" value="Submit" &amp;gt;
&amp;lt; /div &amp;gt;
&amp;lt; /div &amp;gt;
&amp;lt; /form &amp;gt;
&amp;lt; table class="table" &amp;gt;
&lt;thead&gt;
&amp;lt; tr &amp;gt;
&amp;lt; th scope="col"&amp;gt; URL &amp;lt; /th &amp;gt;
&amp;lt; th scope="col"&amp;gt; SHORT &amp;lt; /th &amp;gt;
&amp;lt; th scope="col"&amp;gt; CLICK 
&amp;lt; /tr &amp;gt;
&amp;lt; /thead &amp;gt;
&amp;lt; tbody &amp;gt;
&amp;lt; % for(url of data){ % &amp;gt;
&amp;lt; tr &amp;gt;
&amp;lt; td &amp;gt; &amp;lt; /td &amp;gt;
&amp;lt; td &amp;gt;&lt;a href=""&gt; &lt;/a&gt; 
&amp;lt; td &amp;gt;
&amp;lt; /tr &amp;gt;
&amp;lt; % } % &amp;gt;
&amp;lt; /tbody &amp;gt;
&amp;lt; /table &amp;gt;
&amp;lt; /div &amp;gt;
&amp;lt; !-- JS, Popper.js, and jQuery --&amp;gt;
&amp;lt; script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"&amp;gt;&amp;lt; /script &amp;gt;
&amp;lt; script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"&amp;gt;
&amp;lt; script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js" integrity="sha384-OgVRvuATP1z7JjHLkuOU7Xw704+h835Lr+6QL9UvYjZE3Ipu6Tp75j7Bh/kR0JKI" crossorigin="anonymous"&amp;gt; 
&amp;lt; /body &amp;gt;
&amp;lt; /html &amp;gt;

&lt;/thead&gt;&lt;/pre&gt;

&lt;p&gt;
As our view has been ready not add our view inside our GET method which at root path as.
&lt;/p&gt;

&lt;pre&gt;
...
router.get('/',async (ctx) =&amp;gt; {
const allURL = await urlCollection.find({})
ctx.render('index.ejs',{data: allURL});
})
...
&lt;/pre&gt;

&lt;p&gt;
Now we can focus on posting of our form first we need to initiate our “UUID” which help to generate unique ID, and “multiparser” which help to capture our form data. Inside our app.ts file pass following code
&lt;/p&gt;

&lt;pre&gt;
//Importing UUID and Multiparser
import {multiParser} from 'https://raw.githubusercontent.com/deligenius/multiparser/master/mod.ts';
import ShortUniqueId from 'https://cdn.jsdelivr.net/npm/short-unique-id@latest/short_uuid/mod.ts';
...
// Initiating UUID
const UUID = new ShortUniqueId();
...
&lt;/pre&gt;

&lt;p&gt;
Now we can handle our POST method first we need to capture our form data then we need to create a unique ID and then save our Full URL and Short ID inside our database. We can also track our click so pass initial value 0.
&lt;/p&gt;

&lt;pre&gt;
...
.post('/post',async (ctx)=&amp;gt;{
const formData:any = await multiParser(ctx.request.serverRequest);
const urlObject = {
fullURL: formData.url,
shortURL: UUID(),
click: 0
}
await urlCollection.insertOne(urlObject);
ctx.response.redirect('/')
})
...
&lt;/pre&gt;

&lt;p&gt;
Now after handling our post request we can also handle our get request as soon as we pass our url and short ID it will redirect to full url so our code looks something like this.
&lt;/p&gt;

&lt;pre&gt;
...
.get('/:shortId', async(ctx) =&amp;gt; {
const shortURLId = ctx.params.shortId;
const isURL = await urlCollection.findOne({shortURL: shortURLId});
if(isURL) {
ctx.response.status = 301;
await urlCollection.updateOne({_id: isURL._id},{$set: {click: isURL.click+1}})
ctx.response.redirect(`${isURL.fullURL}`);
}else{
ctx.response.status = 404;
ctx.response.body = "Sorry no page found";
}
})
...
&lt;/pre&gt;

&lt;p&gt;
So now first start you application using Denon or Deno and open up your browser with “localhost:8000” and it will work. In case if you miss any code here is full code inside app.ts
&lt;/p&gt;

&lt;pre&gt;
// Importing Modules
import {Application, Router} from 'https://deno.land/x/oak/mod.ts';
import {viewEngine,
engineFactory,
adapterFactory} from 'https://deno.land/x/view_engine/mod.ts';
import {multiParser} from 'https://raw.githubusercontent.com/deligenius/multiparser/master/mod.ts';
import {MongoClient} from 'https://deno.land/x/mongo@v0.7.0/mod.ts';
import ShortUniqueId from 'https://cdn.jsdelivr.net/npm/short-unique-id@latest/short_uuid/mod.ts';
// Initiating App and Router
const app = new Application();
const router = new Router();
// Setting up View Engine
const ejsEngine = engineFactory.getEjsEngine();
const oakAdapter = adapterFactory.getOakAdapter();
app.use(viewEngine(oakAdapter,ejsEngine));
// Setting up mongo client
const client = new MongoClient();
client.connectWithUri('mongodb://localhost:27017');
const db = client.database('shortener');
const urlCollection = db.collection('url');
// Initiating UUID
const UUID = new ShortUniqueId();
// Handling Requests
router.get('/',async (ctx) =&amp;gt; {
const allURL = await urlCollection.find({})
ctx.render('index.ejs',{data: allURL});
})
.post('/post',async (ctx)=&amp;gt;{
const formData:any = await multiParser(ctx.request.serverRequest);
const urlObject = {
fullURL: formData.url,
shortURL: UUID(),
click: 0
}
await urlCollection.insertOne(urlObject);
ctx.response.redirect('/')
})
.get('/:shortId', async(ctx) =&amp;gt; {
const shortURLId = ctx.params.shortId;
const isURL = await urlCollection.findOne({shortURL: shortURLId});
if(isURL) {
ctx.response.status = 301;
await urlCollection.updateOne({_id: isURL._id},{$set: {click: isURL.click+1}})
ctx.response.redirect(`${isURL.fullURL}`);
}else{
ctx.response.status = 404;
ctx.response.body = "Sorry no page found";
}
});
// Passing Router as middle ware inside the app
app.use(router.routes());
app.use(router.allowedMethods());
// Logging that server is running at PORT 8000
console.log('App is listening to port 8000');
await app.listen({port: 8000});
&lt;/pre&gt;


&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--i3JOwpme--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev.to/assets/github-logo-ba8488d21cd8ee1fee097b8410db9deaa41d0ca30b004c0c63de0a479114156f.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/recoding-io"&gt;
        recoding-io
      &lt;/a&gt; / &lt;a href="https://github.com/recoding-io/deno-todo-app"&gt;
        deno-todo-app
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      A To-Do app created using Deno
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;h1&gt;
Deno To-Do List App&lt;/h1&gt;
&lt;p&gt;This is project created on deno which is a to-do application only using Deno and its libraries.&lt;/p&gt;
&lt;h2&gt;
Project Intro&lt;/h2&gt;
&lt;p&gt;Inside this project we are using Deno modules like&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://deno.land/x/oak" rel="nofollow"&gt;Oak&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://deno.land/x/mongo" rel="nofollow"&gt;Mongo&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://deno.land/x/view_engine" rel="nofollow"&gt;View Engine&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
Command To Run The Project&lt;/h2&gt;
&lt;div class="snippet-clipboard-content position-relative"&gt;&lt;pre&gt;&lt;code&gt;
deno run --allow-net --allow-read --allow-write --allow-plugin --unstable app.ts

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;Note - Unstable tag is used because the Mongo module is still in developing phase by the time when this code has been created.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
Full step by step tutorial&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://youtu.be/xADFwCF6ECA" rel="nofollow"&gt;Create To Do List App using Deno, Oak, MongoDB and View Engine - Part-1&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://youtu.be/dRamdHD2UWU" rel="nofollow"&gt;Create To Do List App using Deno, Oak, MongoDB and View Engine - Part-2&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;



&lt;/div&gt;
&lt;br&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/recoding-io/deno-todo-app"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;br&gt;
&lt;/div&gt;
&lt;br&gt;
&lt;br&gt;&lt;br&gt;
&lt;iframe&gt;
  width="710"&lt;br&gt;
  height="399"&lt;br&gt;
  src="https://www.youtube.com/embed/sZCa2eHoLZ4"&lt;br&gt;
  allowfullscreen&lt;br&gt;
  loading="lazy"&amp;gt;&lt;br&gt;
&lt;/iframe&gt;&lt;br&gt;


</description>
      <category>deno</category>
      <category>javascript</category>
      <category>typescript</category>
    </item>
    <item>
      <title>How to Upload File and Images Inside Deno Server</title>
      <dc:creator>Haaris Iqubal</dc:creator>
      <pubDate>Wed, 24 Jun 2020 16:33:20 +0000</pubDate>
      <link>https://dev.to/recoding/how-to-upload-file-and-images-inside-deno-server-4cja</link>
      <guid>https://dev.to/recoding/how-to-upload-file-and-images-inside-deno-server-4cja</guid>
      <description>&lt;p&gt;

Welcome again to my blog, today we gonna learn how to upload files or images inside Deno, as uploading files or images inside Node can be handled with Multer but in Deno handling file upload is still a mystery so let unwrap this…
&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fe75v3prrnxg2olr32bzw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fe75v3prrnxg2olr32bzw.png" alt="Getting Started"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;
For uploading our we gonna need Oak Middleware Upload module from Deno‘s website. We also add other modules inside our project which include Oak and View Engine to server our webpage and manage our application. So let’s set our &lt;a href="https://medium.com/recoding/rendering-html-css-in-deno-using-view-engine-e07469613598" rel="noopener noreferrer"&gt;View Engine boilerplate codes&lt;/a&gt;&lt;a&gt;.

&lt;/a&gt;&lt;/p&gt;

&lt;pre&gt;

// Importing Module
import {Application, Router} from 'https://deno.land/x/oak/mod.ts';
import {viewEngine,
engineFactory,
adapterFactory} from 'https://deno.land/x/view_engine/mod.ts';
import {upload} from 'https://deno.land/x/upload_middleware_for_oak_framework/mod.ts';
// Setting up our view Engine
const ejsEngine = engineFactory.getEjsEngine();
const oakAdapter = adapterFactory.getOakAdapter();
// Initiate our Application and Router
const app = new Application();
const router = new Router();
app.use(viewEngine(oakAdapter, ejsEngine));
// Setting our router to handle request
router
 .get('/', (ctx) =&amp;gt; {
  ctx.render('index.ejs')
 });
// Passing Router as middleware
app.use(router.routes());
app.use(router.allowedMethods());
// Server our app
console.log('App is listening on PORT 8000');
await app.listen({port: 8000});

&lt;/pre&gt;

&lt;p&gt;

Now inside our &lt;b&gt;“index.ejs”&lt;/b&gt; let’s a basic form which has a method of “POST” to the path “/upload” and enctype as “multipart/form-data”. Inside the form, tag adds an input tag which is type of “file” and name as “fileName” you can set anything you want. Our index.ejs file gonna look something like.

&lt;/p&gt;

&lt;pre&gt;

&amp;lt;body&amp;gt;
&amp;lt;form method="POST" enctype="multipart/form-data" action="/validated"&amp;gt;
 &amp;lt;input type="file" name="fileName" multiple&amp;gt; &amp;lt;br&amp;gt;
 &amp;lt;input type="submit" value="submit"&amp;gt;
&amp;lt;/form&amp;gt;
&amp;lt;/body&amp;gt;

&lt;/pre&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Ft6cjm87ywl6hznwzq9n9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Ft6cjm87ywl6hznwzq9n9.png" alt="Form Style"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;
Now inside our app.ts file let’s create a method to handle POST request as
&lt;/p&gt;

&lt;pre&gt;
.post('/upload', upload('uploads'), async(context: any, next: any)=&amp;gt;{
 const file = context.uploadedFiles;
 console.log(file);
 context.response.redirect('/');
})
&lt;/pre&gt;

&lt;p&gt;
Now save your file and open the browser and check if your application is working or not. When you submit the form inside the root file where your application is stored a file upload will be created and you can see that file you have uploaded finally submit.

Our app.ts file finally looks something like this in case you miss something.
&lt;/p&gt;

&lt;pre&gt;

// Importing Module
import {Application, Router} from 'https://deno.land/x/oak/mod.ts';
import {viewEngine,
engineFactory,
adapterFactory} from 'https://deno.land/x/view_engine/mod.ts';
import {upload} from 'https://deno.land/x/upload_middleware_for_oak_framework/mod.ts';
// Setting up our view Engine
const ejsEngine = engineFactory.getEjsEngine();
const oakAdapter = adapterFactory.getOakAdapter();
// Initiate our Application and Router
const app = new Application();
const router = new Router();
app.use(viewEngine(oakAdapter, ejsEngine));
// Setting our router to handle request
router
.get('/', (ctx) =&amp;gt; {
ctx.render('index.ejs')
})
.post('/upload', upload('uploads'), async(context: any, next: any)=&amp;gt;{
const file = context.uploadedFiles;
console.log(file);
context.response.redirect('/');
});
// Passing Router as middleware
app.use(router.routes());
app.use(router.allowedMethods());
// Server our app
console.log('App is listening on PORT 8000');
await app.listen({port: 8000});

&lt;/pre&gt;

&lt;p&gt;

So finally we have implemented our uploading file inside the deno server so 😉.

Check our video if you want to prefer to follow our video…
&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/bQgC9LQx97c"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Ftuwd55eezmnevn9tb5jo.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Ftuwd55eezmnevn9tb5jo.gif" alt="Good Bye"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>deno</category>
      <category>typescript</category>
      <category>codenewbie</category>
    </item>
    <item>
      <title>Creating Registration Form In Deno : MongoDB Setup, Saving Data</title>
      <dc:creator>Haaris Iqubal</dc:creator>
      <pubDate>Sat, 20 Jun 2020 17:08:02 +0000</pubDate>
      <link>https://dev.to/recoding/building-registration-form-in-deno-part-2-mongodb-setup-saving-data-36jc</link>
      <guid>https://dev.to/recoding/building-registration-form-in-deno-part-2-mongodb-setup-saving-data-36jc</guid>
      <description>&lt;p&gt;

Welcome again in the second series of our Building Registration form, in previous post we have added functionality of View Engine, Form Request now in this post we gonna setup our MongoDB and save our form data so without further ado, let’s get started …

First we need to create some file, so our file structure will look like.

&lt;/p&gt;

&lt;pre&gt;

./
|-index.ejs
|-app.ts
|-static/
   |-style.css

&lt;/pre&gt;

&lt;p&gt;

For our form styling, you can check our video

&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/awboDcBudYQ"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;&amp;gt;

Inside our “index.ejs” our file gonna look like this

&lt;/p&gt;

&lt;pre&gt;

&amp;lt;head&amp;gt;
&amp;lt;link rel="stylesheet" href="/style.css"&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
&amp;lt;div class="container"&amp;gt;
&amp;lt;h1&amp;gt;Hello 
 &amp;lt;form method="POST" enctype="multipart/form-data" action="/post"&amp;gt;
  &amp;lt;div class="form-container"&amp;gt;
 &amp;lt;input type="email" class="form-input" name="email" required&amp;gt;
  &amp;lt;label class="form-input-label"&amp;gt;Email
 &amp;lt;span class="form-input-bar"&amp;gt;
&amp;lt;/div&amp;gt;
&amp;lt;div class="form-container"&amp;gt;
  &amp;lt;input type="password" class="form-input" name="password" required&amp;gt;
  &amp;lt;label class="form-input-label"&amp;gt;Password&amp;lt;/label&amp;gt;
 &amp;lt;span class="form-input-bar"&amp;gt;&amp;lt;/span&amp;gt;
&amp;lt;/div&amp;gt;
&amp;lt;div class='form-container'&amp;gt;
&amp;lt;input type="submit" value="Submit"&amp;gt;
&amp;lt;/div&amp;gt;
&amp;lt;/form&amp;gt;
&amp;lt;/div&amp;gt;
&amp;lt;/body&amp;gt;

&lt;/pre&gt;

&lt;p&gt;

And our “style.css” will look like

&lt;/p&gt;

&lt;pre&gt;

body{
font-family: Arial, Helvetica, sans-serif;
margin: 0;
padding: 0;
height: 100vh;
}
.container{
position: absolute;
top: 50%;
left: 50%;
transform: translateX(-50%) translateY(-50%);
}
.form-container{
position: relative;
margin-bottom: 45px;
}
.form-input{
background: none;
background-color: white;
color: black;
font-size: 18px;
padding: 10px;
display: block;
border: none;
border-bottom: 1px solid #F8BBD0;
border-radius: 0px;
}
.form-input:focus{
outline: none;
border-bottom: none;
}
.form-input-label{
color: #F8BBD0;
font-size: 18px;
font-weight: normal;
position: absolute;
pointer-events: none;
left: 5px;
top: 1px;
transition: 0.2s ease all;
-webkit-transition: 0.2s ease all;
}
.form-input:focus ~ .form-input-label,.form-input:valid ~ .form-input-label{
top:-20px;
color: #E91E63;
}
.form-input-bar{
position: relative;
display: block;
width: 100%;
}
.form-input-bar:before,.form-input-bar:after{
content: '';
height: 2px;
width: 0;
bottom: 1px;
position: absolute;
background-color: #E91E63;
transition: 0.2s ease all;
-webkit-transition: 0.2s ease all;
}
.form-input-bar:before{
left: 50%;
}
.form-input-bar:after{
right: 50%;
}
.form-input:focus ~ .form-input-bar:before,
.form-input:focus ~ .form-input-bar:after{
width: 50%;
}

&lt;/pre&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--UZWwX9ae--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/fsbhk2b0efr4fsiykg8y.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--UZWwX9ae--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/fsbhk2b0efr4fsiykg8y.png" alt="Image Styling looks something like this"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;

Now let’s send our static so that web browser, first we need to import Send function from Oak module.

&lt;/p&gt;

&lt;pre&gt;

import {Application, Router, send} from 'https://deno.land/x/oak/mod.ts';
.
.
.
// Sending Static file as Middleware
app.use(async (ctx,next) =&amp;gt; {
 await send(ctx, ctx.request.url.pathname, {
  root: `${Deno.cwd()}/static`
 });
 next();
});

&lt;/pre&gt;

&lt;p&gt;

Here we send our static file as middleware, using upper statement. Now let’s setup database, for our database we gonna use MongoDB for this we import our module as


&lt;/p&gt;

&lt;pre&gt;

import {MongoClient} from ‘https://deno.land/x/mongo@v0.8.0/mod.ts';

&lt;/pre&gt;

&lt;p&gt;

Let initiate our MongoClient class and setup our URI, for this example we are using local mongoDB data you can use mongoDB server from its website just copy the URL and paste inside clientURI.

&lt;/p&gt;

&lt;pre&gt;

const client = new MongoClient();

client.connectWithUri("mongodb://localhost:27017");

&lt;/pre&gt;

&lt;p&gt;

After initiating our mongoDB, Now create our collection and database as


&lt;/p&gt;

&lt;pre&gt;

const db = client.database("registrationDB");
const dataCollection = db.collection('data');

&lt;/pre&gt;

&lt;p&gt;

As our Boilerplate code for Database has finally finish let now save our data inside our POST method add following statement.

&lt;/p&gt;

&lt;pre&gt;

.post('/post', async (ctx) =&amp;gt; {
const form = JSON.stringify(await multiParser(ctx.request.serverRequest));
const parse = JSON.parse(form);
const dataSaved = dataCollection.insertOne(parse);
ctx.render('index.ejs',{data:{msg: parse.email}});
})


&lt;/pre&gt;

&lt;p&gt;

Now open the browser and check our application is working or not.

In case you missed any part here is the full code.

app.ts

&lt;/p&gt;

&lt;pre&gt;

// Importing our modules
import {Application, Router, send} from 'https://deno.land/x/oak/mod.ts';
import {viewEngine,
engineFactory,
adapterFactory} from 'https://deno.land/x/view_engine/mod.ts';
import {multiParser} from 'https://raw.githubusercontent.com/deligenius/multiparser/master/mod.ts';
import {MongoClient} from 'https://deno.land/x/mongo@v0.8.0/mod.ts';

const ejsEngine = engineFactory.getEjsEngine();
const oakAdapter = adapterFactory.getOakAdapter();
// Setting up mongoDB
const client = new MongoClient();
client.connectWithUri("mongodb://localhost:27017");
const db = client.database("registrationDB");
const dataCollection = db.collection('data');
// Initiate our app and router
const app = new Application();
const router = new Router();
// Send View Engine as middleware
app.use(viewEngine(oakAdapter, ejsEngine));
// Handling request inside router
router
.get('/', async (ctx) =&amp;gt; {
ctx.render('index.ejs',{data: {msg: 'World'}});
})
.post('/post', async (ctx) =&amp;gt; {
const form = JSON.stringify(await multiParser(ctx.request.serverRequest));
const parse = JSON.parse(form);
const dataSaved = dataCollection.insertOne(parse);
ctx.render('index.ejs',{data:{msg: parse.email}});
})
;
// Send our router as middleware
app.use(router.routes());
app.use(router.allowedMethods());
// Send our Static folder as middleware
app.use(async (ctx,next) =&amp;gt; {
await send(ctx, ctx.request.url.pathname, {
root: `${Deno.cwd()}/static`
});
next();
});
// Listening to database
console.log('App is listening on Port 8000');
await app.listen({port: 8000})

&lt;/pre&gt;

&lt;p&gt;

Now open you terminal and type command as “deno run — allow-net — allow-read — allow-write — allow-plugin — unstable app.ts” or your can use Denon.

Now type your email and password inside form element.

&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--erGcDnKx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/f3otijy4w7srgzo3grb3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--erGcDnKx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/f3otijy4w7srgzo3grb3.png" alt="Example Showing Email and Password Pass inside the server"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;
And our database gonna look like this
&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--aKS43mg_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/5o75d2xiyq9xzt0i9p6p.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--aKS43mg_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/5o75d2xiyq9xzt0i9p6p.png" alt="MongoDB data save inside the database"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;
So hope you like our post see in future posts until then 👋.
&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/RwFLpBJY2Es"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

</description>
      <category>deno</category>
      <category>mongodb</category>
      <category>typescript</category>
    </item>
    <item>
      <title>Creating Registration Form In Deno : Setting Up Project</title>
      <dc:creator>Haaris Iqubal</dc:creator>
      <pubDate>Tue, 16 Jun 2020 17:14:01 +0000</pubDate>
      <link>https://dev.to/recoding/creating-registration-form-in-deno-setting-up-project-1e45</link>
      <guid>https://dev.to/recoding/creating-registration-form-in-deno-setting-up-project-1e45</guid>
      <description>&lt;p&gt;
Hi guys welcome today we gonna learn how to build a registration form in Deno. As you might have seen this basic building block of Server coding to handle request and save it inside the database this article will truly help you understand how to handle request, retrieve data from user and save it inside the database. So without further ado let’s get started…
&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--gafjMURD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/u5gqtneg8puydjb4o3qq.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--gafjMURD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/u5gqtneg8puydjb4o3qq.gif" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;
Our file setup gonna look like as following.
&lt;/p&gt;

&lt;pre&gt;

./
|-index.ejs
|-app.ts

&lt;/pre&gt;

&lt;p&gt;
For the starter we gonna import our module for this project we gonna require Oak, view_engine and multiparser.
&lt;/p&gt;

&lt;pre&gt;

// Importing modules
import {Application, Router} from 'https://deno.land/x/oak/mod.ts';
import {viewEngine,
engineFactory,
adapterFactory} from 'https://deno.land/x/view_engine/mod.ts';
import {multiParser} from 'https://raw.githubusercontent.com/deligenius/multiparser/master/mod.ts';

&lt;/pre&gt;

&lt;p&gt;
Now we need to set our adapter and engine, for adapter we are using oak and for engine we are using EJS.
&lt;/p&gt;

&lt;pre&gt;

// Setting Engine and Adapter
const ejsEngine = engineFactory.getEjsEngine();
const oakAdapter = adapterFactory.getOakAdapter();

&lt;/pre&gt;

&lt;p&gt;
After setting our &lt;a href="https://medium.com/recoding/rendering-html-css-in-deno-using-view-engine-e07469613598"&gt;View Engine boilerplate&lt;/a&gt; lets now initiate our app.&lt;/p&gt;

&lt;pre&gt;

// Initiating Application and Router
const app = new Application();
const router = new Router();
// Passing our view engine as middleware
app.use(viewEngine(oakAdapter, ejsEngine));
router
 .get('/',(ctx) =&amp;gt; {
  ctx.render('index.ejs',{data:{msg: 'world'}});
  });
// Passing Router as Middleware
app.use(router.routes());
app.use(router.allowedMethods());
// Setting our App to listen the Port
console.log('App is listening on Port 8000');
await app.listen({port: 8000});

&lt;/pre&gt;

&lt;p&gt;

Now inside our “index.ejs” add the following code.

&lt;/p&gt;

&lt;pre&gt;


 &amp;lt;h1&amp;gt;Hello &amp;lt;%= data.msg %&amp;gt;&amp;lt;/h1&amp;gt;


&lt;/pre&gt;

&lt;p&gt;

Now let’s run our application as “denon run — allow-net — allow-read — allow-write app.ts”. Open your browser type localhost:8000/ in the URL and your app is up and running.

Now inside our “index.ejs” file make a form which handles a POST request to the path “localhost:8000/post” as following.

&lt;/p&gt;

&lt;pre&gt;


 &amp;lt;h1&amp;gt;Hello &amp;lt;%= data.msg %&amp;gt;&amp;lt;/h1&amp;gt;
 &amp;lt;form method="POST" enctype="multipart/form-data" action="/post"&amp;gt;
  &amp;lt;label&amp;gt;Email&amp;lt;/label&amp;gt;
  &amp;lt;input type="email" name="email" placeholder="Enter email"&amp;gt;
 &amp;lt;/form&amp;gt;
&amp;lt;/body&amp;gt;

&lt;/pre&gt;

&lt;p&gt;

After adding form inside your “index.ejs” your web page now looks something like this.

&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--TtKtK9BZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/sqygbcz9ts0xmpl08phz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--TtKtK9BZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/sqygbcz9ts0xmpl08phz.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;

After adding Form inside the our app.ts now let's handle our form request which uses POST method on “localhost:8000/post” path.

&lt;/p&gt;

&lt;pre&gt;

router
 .get('/',(ctx) =&amp;gt; {
  ctx.render('index.ejs',{data:{msg: 'world'}});
  })
 .post('/post', async (ctx) =&amp;gt; { 
  const form = JSON.stringify(await          multiParser(ctx.request.serverRequest));
  const parse = JSON.parse(form);
  ctx.render('index.ejs',{data: {msg: parse.email}});
  });

&lt;/pre&gt;

&lt;p&gt;
Inside our POST handler we request server to give any form data after that we convert this request into JSON form so we can parse the data pretty easily. After parsing data we than return data inside our render function as object.

After adding our POST handler not run our app and check if its working or not.
&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--0POb5-wB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/tj8eulfatppznzly9708.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--0POb5-wB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/tj8eulfatppznzly9708.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;
So finally our POST handling is working fine. So hope you like this post we gonna add more functionality in the next post so stay tune 😉.
&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/IXNFb61dXgg"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

</description>
      <category>deno</category>
    </item>
    <item>
      <title>Intro to Deno Express JS</title>
      <dc:creator>Haaris Iqubal</dc:creator>
      <pubDate>Fri, 12 Jun 2020 04:36:45 +0000</pubDate>
      <link>https://dev.to/recoding/intro-to-deno-express-js-2fpc</link>
      <guid>https://dev.to/recoding/intro-to-deno-express-js-2fpc</guid>
      <description>&lt;p&gt;Express JS is one of the best application interface for Node.JS, Express provide middleware over our raw application so its user can build routes, middleware, and much more. Express also gives a whole new aspect of development by building MEAN, MERN, MEVN stacks.

So can Express JS be used in Deno 🧐?
Deno third-party module Deno Train has implemented some of the features which resemble the Express in node. So without wasting much time let’s get started… 

First we need to create app.ts, after creating let’s import the Deno Train using import syntax as
&lt;/p&gt;

&lt;pre&gt;

// Importing Deno Train
import { Application, Router } from "https://deno.land/x/denotrain@v0.5.0/mod.ts";

&lt;/pre&gt;

&lt;p&gt;

After importing we need to initialize our application class and router class so we can implement our app as well as create routing path which perform according to user request.

&lt;/p&gt;

&lt;pre&gt;

// Initialization of App and Router

const app = new Application();

const router = new Router();

&lt;/pre&gt;

&lt;p&gt;

Now we need to set our router to perform action, we can set which type of request we send to our server like (GET,POST,DELETE or etc).

&lt;/p&gt;

&lt;pre&gt;

// Setting up get request in base path

router.get("/get", ({req,res})=&amp;gt; {
 // Implement your logic
 return "Hello World Deno is awesome 👏 "
});

router.post("/post", ({req,res})=&amp;gt; {
 // You can request submitted form data by just requesting the body
 const formData = req.body;
 return "This is post submit any thing you want 🍉"
});

router.delete("/delete", ({req,res})=&amp;gt; {
 // Implement your logic
 return {"msg": "Your item has been deleted ❌"} // Returning a json
});

router.patch("/get", ({req,res})=&amp;gt; {
 return "Your application is updated"
});


&lt;/pre&gt;

&lt;p&gt;

So this how we can handle the requests using our Deno Train not lets make this router available to application as we need to pass it as a middleware then we need to start our app.

&lt;/p&gt;

&lt;pre&gt;

// Pushing our router inside our application as a middleware

app.use("/url-path", router);
// Now let our app to run on port 3000 by default we can change if we want

await app.run();

&lt;/pre&gt;

&lt;p&gt;

Now open up Post Man and tries to send each request and check your application is working or not. Use this url “localhost:3000/url-path/get” for the get request we can similarly apply for Delete, Update and Post request.

Our final application will look something like this.

&lt;/p&gt;

&lt;pre&gt;

// Importing Deno Train
import { Application, Router } from "https://deno.land/x/denotrain@v0.5.0/mod.ts";

// Initialization of App and Router

const app = new Application();

const router = new Router();

// Setting up get request in base path

router.get("/get", ({req,res})=&amp;gt; {
 // Implement your logic
 return "Hello World Deno is awesome 👏 "
});

router.post("/post", ({req,res})=&amp;gt; {
 // You can request submitted form data by just requesting the body
 const formData = req.body;
 return "This is post submit any thing you want 🍉"
});

router.delete("/delete", ({req,res})=&amp;gt; {
 // Implement your logic
 return {"msg": "Your item has been deleted ❌"} // Returning a json
});

router.patch("/get", ({req,res})=&amp;gt; {
 return "Your application is updated"
});
// Pushing our router inside our application as a middleware

app.use("/url-path", router);
// Now let our app to run on port 3000 by default we can change if we want

await app.run();

&lt;/pre&gt;

&lt;p&gt;

So we finally implement Express like application inside Deno using Deno Train hope your may like it. And if we make our application using Deno, Mongo, Express and Javascript Front-End library then their acronym will be MERD, MEVD &amp;amp; MEAD.

&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--bdrk6IYO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/z5p9oa84nnm3c6xxvjkv.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--bdrk6IYO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/z5p9oa84nnm3c6xxvjkv.gif" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>deno</category>
    </item>
    <item>
      <title>Deno REST API with CRUD Operation using MongoDB : 1 Setting-up Project</title>
      <dc:creator>Haaris Iqubal</dc:creator>
      <pubDate>Wed, 03 Jun 2020 16:12:27 +0000</pubDate>
      <link>https://dev.to/recoding/deno-rest-api-with-crud-operation-using-mongodb-1-setting-up-project-5346</link>
      <guid>https://dev.to/recoding/deno-rest-api-with-crud-operation-using-mongodb-1-setting-up-project-5346</guid>
      <description>&lt;p&gt;

This tutorial is focusing creating a simple REST API using Deno. By the latest introduction of Deno one of the most interesting thing to do with it is to perform CRUD operation with your Deno app. As Deno doesn't have any database associated with it so we need use other databases like SQL, PostgreSQL, SQLite or MongoDB. For the sake of this example we gonna use MongoDB. So without further ado let's setup our project.

For our Deno app we are going to Oak which provides us app layer while Mongo Module which provides use interfacing command for CRUD in mongoDB.

Our RestAPI will support MVC (Model View Controller) architecture. So our file structure gonna look like this. View will not be implemented in this tutorial, as this is only as RestAPI you can implement in your iOS, Android, Windows or macOS apps easily.

&lt;/p&gt;

&lt;pre&gt;

./
|-index.html
|-app.ts
|-models/
   |-user.ts
   |-mongo.ts
|-controllers/
   |-users.ts
|-routes/
   |-users.ts

&lt;/pre&gt;

&lt;p&gt;

Let type some of our boiler plate codes inside app.ts.

&lt;/p&gt;

&lt;pre&gt;

// Requiring modules 
import { Application, Router,send } from "https://deno.land/x/oak/mod.ts";
// Setting ENV variables
const env = Deno.env.toObject();
const PORT = env.PORT || 8000;
const HOST = env.HOST || 'localhost';
// Initiate
 
const app = new Application();
const router = new Router();
// Here we can setup our logger and timer
app.use(async (ctx,next)=&amp;gt; {
await next();
const rt = ctx.response.headers.get("X-Response-Time");
console.log(`${ctx.request.method} ${ctx.request.url} - ${rt}`);
})
app.use(async (ctx,next)=&amp;gt; {
const start = Date.now();
await next();
const ms = Date.now();
ctx.response.headers.set("X-Response-Time",`${ms}ms`);
})
// Starting our server
console.log(`App is listening to ${PORT} PORT`);
app.listen(`${HOST}:${PORT}`);


&lt;/pre&gt;

&lt;p&gt;

Now we need to create our Routes so inside our routes folder open users.ts file. Inside it we need to pass our request we want it might be “GET”, “POST”, “DELETE” or any other.

&lt;/p&gt;

&lt;pre&gt;

import {Router} from 'https://deno.land/x/oak/mod.ts';
const router = new Router({prefix: '/user'});
router
 .get('/allUsers', console.log("All user Path"))
 .post('/sign-up', console.log("Sign-Up User"))
 .post('/sign-in',console.log("Sign-In User"))
 .delete('/delete/:userId', console.log("Delete User"))
 .patch('/update/:userId', console.log("Update User"));

&lt;/pre&gt;

&lt;p&gt;

As our route has been prepared let import these routes inside our app.ts file so our file finally look like.

&lt;/p&gt;

&lt;pre&gt;

//Importing our modules
import {Application} from 'https://deno.land/x/oak/mod.ts';
import UserRoute from './routes/users.ts';
// Setting ENV variables
const env = Deno.env.toObject();
const PORT = env.PORT || 8000;
const HOST = env.HOST || 'localhost';
//Setting our application and router
const app = new Application();
//Here we can setup our logger and timer
app.use(async (ctx,next)=&amp;gt; {
await next();
const rt = ctx.response.headers.get("X-Response-Time");
console.log(`${ctx.request.method} ${ctx.request.url} - ${rt}`);
})
app.use(async (ctx,next)=&amp;gt; {
const start = Date.now();
await next();
const ms = Date.now();
ctx.response.headers.set("X-Response-Time",`${ms}ms`);
})
//Now we can pass UserRoute as middleware to app
app.use(UserRoute.routes());
app.use(UserRoute.allowedMethods());
// Starting our server
console.log(`App is listening to ${PORT} PORT`);
app.listen(`${HOST}:${PORT}`);

&lt;/pre&gt;

&lt;p&gt;

Now our app.ts has been setup let check our application is running our for checking we need to use &lt;a href="https://medium.com/recoding/creating-hot-reload-or-live-reload-in-deno-app-using-denom-a62c58e0b878"&gt;Denon&lt;/a&gt; for live loading of app. Type the command

&lt;/p&gt;

&lt;pre&gt;

denon run --allow-net --allow-flag --allow-read --allow-write app.ts

&lt;/pre&gt;

&lt;p&gt;

Now open PostMan check our API we have created is working or not.

Inside Post Man try to send a “GET” request at “localhost:8000/users/allUsers”. If you get comment on your console you have written above then our path is working.

So we have created our project structure for and implemented boilerplate. We gonna implement DB Setup and our Controller in our next post until then stay tune.

&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/FR6vgRoa6lc"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

</description>
      <category>deno</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Hashing your Data in Deno Using Bcrypt</title>
      <dc:creator>Haaris Iqubal</dc:creator>
      <pubDate>Mon, 01 Jun 2020 05:49:59 +0000</pubDate>
      <link>https://dev.to/recoding/hashing-your-data-in-deno-using-bcrypt-15jj</link>
      <guid>https://dev.to/recoding/hashing-your-data-in-deno-using-bcrypt-15jj</guid>
      <description>&lt;p&gt;
Encryption has always been important aspect of Human Life as it help use to send data from one part of then world to another through different agent but its secret will not reveled. So how would your implement encryption into Deno app let unwrap this enigma…

We are using &lt;a href="https://deno.land/x/bcrypt"&gt;bcrypt&lt;/a&gt; module from Deno Third Parties library, so the show its working we are going to implement a Deno application so create app.ts file and type the following Boilerplate code to start your application up and running.
&lt;/p&gt;

&lt;pre&gt;

import { Application, Router } from "https://deno.land/x/oak/mod.ts";const app = new Application();
const router = new Router();
 router
  .get("/",(ctx) =&amp;gt; {
   ctx.response.body = "Router has been created";
   // Implement your code
   })
  .post("/addPost", (ctx) =&amp;gt; {
   ctx.response.body = "This is port request";
   // Implement your code   
   });
app.use(router.routes());
app.use(router.allowedMethods());
console.log('App is listening to 8000 PORT');
app.listen({port: 8000});

&lt;/pre&gt;

&lt;p&gt;

After writing boiler plate code we need to require our bcrypt module as

&lt;/p&gt;

&lt;pre&gt;

import * as bcrypt from "https://deno.land/x/bcrypt/mod.ts";

&lt;/pre&gt;

&lt;p&gt;

After importing bcrypt we can now use it as bcrypt every where we want so lets just add bcrypt into our “POST” request path as mentioned below

&lt;/p&gt;

&lt;pre&gt;

.post("/addPost", (ctx) =&amp;gt; { 
 const salt = bcrypt.genSaltSync(8);
 const hash = bcrypt.hashSync("Type Data you want to hash", salt);
 console.log(hash);
 })

&lt;/pre&gt;

&lt;p&gt;
Our final result gonna look like this
&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--EyB_WQjB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/onuri3nmvutssg5yn31u.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--EyB_WQjB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/onuri3nmvutssg5yn31u.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;

This bcrypt function can also implement as async function as mentioned below

&lt;/p&gt;

&lt;pre&gt;

.post("/addPost", async (ctx) =&amp;gt; { 
 const salt = await bcrypt.genSaltSync(8);
 const hash = await bcrypt.hashSync("Type Data you want to hash", salt);
 console.log(hash);
 })

&lt;/pre&gt;

&lt;p&gt;

So this how we can implement hashing inside Deno Application. Here is our final code gonna look like.

&lt;/p&gt;

&lt;pre&gt;

import { Application, Router } from "https://deno.land/x/oak/mod.ts";

const app = new Application();

const router = new Router();

 router
  .get("/",(ctx) =&amp;gt; {
   ctx.response.body = "Router has been created";
   // Implement your code
   })
  .post("/addPost", async (ctx) =&amp;gt; { 
    const salt = await bcrypt.genSaltSync(8);
    const hash = await bcrypt.hashSync("Type Data you want to hash", salt);
  console.log(hash);
  })

app.use(router.routes());

app.use(router.allowedMethods());

console.log('App is listening to 8000 PORT');

app.listen({port: 8000});

&lt;/pre&gt;

</description>
      <category>deno</category>
      <category>typescript</category>
      <category>encryption</category>
    </item>
    <item>
      <title>Basic Routing App in Deno using Oak</title>
      <dc:creator>Haaris Iqubal</dc:creator>
      <pubDate>Sat, 30 May 2020 16:44:19 +0000</pubDate>
      <link>https://dev.to/recoding/basic-routing-app-in-deno-using-oak-54d5</link>
      <guid>https://dev.to/recoding/basic-routing-app-in-deno-using-oak-54d5</guid>
      <description>&lt;p&gt;Routing your Internet application is one of most important thing developer has to know about, Routing help use to keep our application safe as we can pass many authentication middleware, Routing also help our Internet application to have different pages for different purposes. Sometime implementing routing become more tedious job to implement if we want to use internal modules so how we will implement that let us think about!!!

As Deno support Third Party module like Oak which will provide us a “application layer” as well as “routing layer”. With using these two classes we can implement our routing application. So without further ado let’s just do it.

First of all we need to create our “app.ts” file our working directory will look like this.&lt;/p&gt;

&lt;pre&gt;

-app.ts

&lt;/pre&gt;

&lt;p&gt;
Now we have to import our module we gonna use Oak so we will copy its link and write our import statement.
&lt;/p&gt;

&lt;pre&gt;
import { Application, Router } from "https://deno.land/x/oak/mod.ts";
&lt;/pre&gt;

&lt;p&gt;
After importing our Application Class and Router Class we now need to initialize both of our module using following statement.
&lt;/p&gt;

&lt;pre&gt;

const app = new Application();

const router = new Router();

&lt;/pre&gt;

&lt;p&gt;
After initializing our router we can now setup what request we want to do with server and how will actually the router and what function they gonna provide. Request can be of many type like “GET”, “POST” ,“DELETE” etc… &lt;/p&gt;

&lt;pre&gt;

router
  .get("/",(ctx) =&amp;gt; {
   ctx.response.body = "Router has been created";
   // Implement your code
   })
  .post("/addPost", (ctx) =&amp;gt; {
   ctx.response.body = "This is port request";
   // Implement your code   
   });

&lt;/pre&gt;

&lt;p&gt;
Our router has been setup now we have then these router path to our application, we can implement this by passing our router as a middleware to our application.

&lt;/p&gt;

&lt;pre&gt;
app.use(router.routes());

app.use(router.allowedMethods());

&lt;/pre&gt;

&lt;p&gt;

For the final step we just need to make our server listen to Port 8000 or any thing you want.

&lt;/p&gt;

&lt;pre&gt;

app.listen({port: 8000});

&lt;/pre&gt;

&lt;p&gt;
So this is how we can build a Deno Routing application pretty easily. Our final code will look this in app.ts file.

&lt;/p&gt;

&lt;pre&gt;
import { Application, Router } from "https://deno.land/x/oak/mod.ts";
const app = new Application();
const router = new Router();
router
  .get("/",(ctx) =&amp;gt; {
   ctx.response.body = "Router has been created";
   // Implement your code
   })
  .post("/addPost", (ctx) =&amp;gt; {
   ctx.response.body = "This is port request";
   // Implement your code   
   });
app.use(router.routes());
app.use(router.allowedMethods());;
app.listen({port: 8000});

&lt;/pre&gt;

&lt;p&gt;

So have fun with Deno and enjoy Deno with Oak 👍.

&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--QXfxRHZi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/h2bh3jwc3osf2byoqinj.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--QXfxRHZi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/h2bh3jwc3osf2byoqinj.gif" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/2ozuUpNGwSE"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

</description>
      <category>deno</category>
      <category>webdev</category>
      <category>typescript</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Nodemon Like Reloader 🔄 in Deno (Denon)</title>
      <dc:creator>Haaris Iqubal</dc:creator>
      <pubDate>Thu, 28 May 2020 05:17:49 +0000</pubDate>
      <link>https://dev.to/recoding/nodemon-like-reloader-in-deno-denon-187e</link>
      <guid>https://dev.to/recoding/nodemon-like-reloader-in-deno-denon-187e</guid>
      <description>&lt;p&gt;It might be frustrating to always close your Deno server and restart it again. As Deno doesn't provide "Hot Reload" out of the box but still there is a way to do it, so no more closing your server and restart it again or banging your head to a desk 😅. &lt;/p&gt;

&lt;p&gt;
For the sake of this example we gonna make little Deno application into "app.ts" file
&lt;/p&gt; 

&lt;pre&gt;

import { serve } from "https://deno.land/std@0.52.0/http/server.ts";
const s = serve({ port: 8000 });
console.log("http://localhost:8000/");
for await (const req of s) {
 req.respond({ body: "Hello World\n" });
}

&lt;/pre&gt;

&lt;p&gt;
After saving the code you need to install Denon. Denon is the deno replacement for nodemon providing a feature-packed and easy to use experience. You need to upgrade Deno v1.0.2 to install the Denon simple type the following command.
&lt;/p&gt;

&lt;pre&gt;

$ deno upgrade

&lt;/pre&gt;

&lt;p&gt;
Now you just need to write the following command into your Terminal or PowerShell and you ready to go.
&lt;/p&gt;

&lt;pre&gt;

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

&lt;/pre&gt;

&lt;p&gt;
Denon uses unstable features of the stdlib, as a result the flag - unstable currently required for the installation.

You can see various other options Denon has provided by simply writing "denon -h" or "denon- help".

For running our app.ts file we need to write denon run then we have to pass the flag so that our app will only pass those options require by the user then we need to type the file name.
&lt;/p&gt;

&lt;pre&gt;

$ denon run -allow-env -allow-net app.ts

&lt;/pre&gt;

&lt;p&gt;
Now enjoy the feature of host reload on the fly whenever you change your file. Just try to change the body msg to "Deno is amazing" and you are done.
&lt;/p&gt;

&lt;p&gt;
You can also follow our video tutorial also on youtube on &lt;a href="https://www.youtube.com/channel/UCnhsNyu4bdDxuW1TT3hg-pg"&gt;Recoding &lt;/a&gt;.
&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/ugRTRLpMQ6U"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

</description>
      <category>deno</category>
      <category>typescript</category>
      <category>node</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>EJS Rendering HTML &amp; CSS in Deno using View Engine 🚀</title>
      <dc:creator>Haaris Iqubal</dc:creator>
      <pubDate>Thu, 28 May 2020 05:01:32 +0000</pubDate>
      <link>https://dev.to/recoding/rendering-html-css-in-deno-using-view-engine-2o38</link>
      <guid>https://dev.to/recoding/rendering-html-css-in-deno-using-view-engine-2o38</guid>
      <description>&lt;p&gt;Rendering HTML or CSS might a cumbersome process as Deno is still in its initial release and there not many plugins to use to serve HTML or CSS files. So still only a few libraries support full rendering support one of them is &lt;a href="https://deno.land/x/view_engine"&gt;view-engine&lt;/a&gt;. View engines provide view-engine middleware so users could pass this middleware into their application server and easily render the HTML and CSS. So without further ado lets get started… &lt;/p&gt;

&lt;p&gt;
First of all, we need to create three files "app.ts", "index.ejs", "./static/style.css". Our file structure gonna look like this.
&lt;/p&gt; 

&lt;pre&gt;
./
|-index.html
|-app.ts
|-static/
   |-style.css
&lt;/pre&gt;

&lt;p&gt;
First, we set up our app we need to write the following code inside the app.ts file.

We need to import some libraries for this example we are going to import Oak which provides a server layer for our application and view-engine which provides a layout to paint our website.
&lt;/p&gt;

&lt;pre&gt;
import { Application, Router,send } from "https://deno.land/x/oak/mod.ts";
import {viewEngine,engineFactory,
adapterFactory} from "https://deno.land/x/view_engine/mod.ts";
&lt;/pre&gt;

&lt;p&gt;
In the first statement of where we require oak in which we are calling "Application" class which provides application-layer like middleware and listen to a port. While the "Router" Class will provide routes layer so we can create many routers and easily segregate the URL as we want. The "send" will help us to provide and the static file we want to serve.

After importing we need to initialize our Application and Router by using this code.
&lt;/p&gt;

&lt;pre&gt;
const app = new Application();
const router = new Router();
&lt;/pre&gt;

&lt;p&gt;
After initializing the application we need to configure our application to use view engine for the sake of this post we are using EJS templating engine to server HTML. You can also use other rendering engines like Denjuck or Handlebars if you prefer.
&lt;/p&gt;

&lt;pre&gt;
const ejsEngine = await engineFactory.getEjsEngine();
const oakAdapter = await adapterFactory.getOakAdapter();
&lt;/pre&gt;

&lt;p&gt;
After setting our view engine boilerplates we need to pass a middleware for serving static folder inside our web browser.
&lt;/p&gt;

&lt;pre&gt;

app.use(async (ctx,next) =&amp;gt; {
 await send(ctx, ctx.request.url.pathname,{
  root: `${Deno.cwd()}/static`
   })
 next();
});

&lt;/pre&gt;

&lt;p&gt;
Now we can pass view engine as middleware in our app with following code:
&lt;/p&gt;

&lt;pre&gt;

app.use(viewEngine(oakAdapter,ejsEngine));

&lt;/pre&gt;

&lt;p&gt;
The major portion of our boilerplate has been completed now we can set up our router for this example we only use one route to the root of the URL can serve any other route you want.
&lt;/p&gt;

&lt;pre&gt;

router.get("/",(ctx)=&amp;gt;{
 ctx.render('index.ejs',{data: {msg:"World"}}
 });

//Adding middleware to require our router
app.use(router.routes());
app.use(router.allowedMethods());

&lt;/pre&gt;

&lt;p&gt;
Our app.ts file is finally completed we only need to serve our app using the following statement :
&lt;/p&gt;

&lt;pre&gt;
console.log('App is listening to port: 8000');
await app.listen({port:8000});
&lt;/pre&gt;

&lt;p&gt;
If you miss any step or don't able to follow our code here is the full code we have written so far in the "app.ts" file.
&lt;/p&gt;

&lt;pre&gt;

// Requiring modules 

import { Application, Router,send } from "https://deno.land/x/oak/mod.ts";

import {viewEngine,engineFactory,
adapterFactory} from "https://deno.land/x/view_engine/mod.ts";

// Initiate app

const app = new Application();

const router = new Router();

// Setting up boilerplate for view-engine

const ejsEngine = await engineFactory.getEjsEngine();

const oakAdapter = await adapterFactory.getOakAdapter();

// Allowing Static file to fetch from server

app.use(async (ctx,next) =&amp;gt; {
 await send(ctx, ctx.request.url.pathname,{
  root: `${Deno.cwd()}/static`
   })
 next()
});

// Passing view-engine as middleware

app.use(viewEngine(oakAdapter,ejsEngine));

// Creating Routes

router.get("/",(ctx)=&amp;gt;{
 ctx.render('index.ejs',{data: {msg:"World"}}
 });

// Adding middleware to require our router

app.use(router.routes());

app.use(router.allowedMethods());

// Making app to listen to port

console.log('App is listening to port: 8000');

await app.listen({port:8000});

&lt;/pre&gt;

&lt;p&gt;
For our "index.ejs" file we can simply add HTML tags into it which looks finally like :
&lt;/p&gt;

&lt;pre&gt;
&amp;lt;html&amp;gt;
 &amp;lt;head&amp;gt;
  &amp;lt;link rel="stylesheet" href="/style.css"&amp;gt;
  &amp;lt;title&amp;gt; Serving HTML and CSS &amp;lt;/title&amp;gt; 
 &amp;lt;/head&amp;gt;
 &amp;lt;body&amp;gt;
  &amp;lt;h1&amp;gt; Hello &amp;lt;%= data.msg %&amp;gt;&amp;lt;/h1&amp;gt; 
 &amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/pre&gt;

&lt;p&gt;
In EJS the object msg we passed in the app.ts file we can require this by using EJS syntax .

For our final step, we need to create a style.css file inside the static file and you can code anything you want inside it relating to CSS.
&lt;/p&gt;

&lt;pre&gt;

body{
 background-color: red;
}

&lt;/pre&gt;

&lt;p&gt;
Now we have to test our application to write this code inside the terminal.&lt;/p&gt;

&lt;pre&gt;
deno run --allow-net --allow-read app.ts
&lt;/pre&gt;

&lt;p&gt;
We need to - allow-net so that our module can be download and - allow-read tag so that our server could able to send the static file. So finally we create a deno application that will serve HTML as well as CSS using View Template Engine.
&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/awboDcBudYQ"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

</description>
      <category>deno</category>
      <category>webdev</category>
      <category>node</category>
    </item>
  </channel>
</rss>
