This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | [ | |
| { | |
| "code": "AED", | |
| "name": "UAE Dirham", | |
| "country": "United Arab Emirates", | |
| "countryCode": "AE", | |
| "flag": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAACXBIWXMAAAsTAAALEwEAmpwYAAAAIGNIUk0AAHolAACAgwAA+f8AAIDpAAB1MAAA6mAAADqYAAAXb5JfxUYAAAG5SURBVHja7JdLihRBEEBfVqUU6rQNggiCFxA8gswFRNy49gAeQdx4G8HbuHDvRkRUnKxPZ2dGhous6Y9TtavPZmITtYggXsWPSKOqrCkFK8stgAFKoOr1kiKAt8CD76/f/KYYj//u7bPpU28Mn199eGiBLabg7uWLUePLp08mB/j66xvA1gKVSkK9J/29guuxNCZrVX60905qZlD0xvd5XbPvmN22uo+XCFDZXI2Idjt0txuk9TFM+ve7Yk9MAkAPIKSuI3XdoEMX/aQAd4qSfYpHAI0RbVt0FGA/KYAtyvMMaBTUObRpBh2a0E3cgspewkkJQkDqGm3bQfNPL9/PtIQ+cmjC5OqbTaj9qppRcglCAFej3h9H8P9xnBUgCtRNBllYDj0QmxbWAkgxggiktFjg60PosAeMJnQtAIkRq7poBlIfK5cgRBQdzYC1dtLgVVVRluUJgEQo7XH0RminlBDCKUDK99AIwByXs4gcb0JJafaFc7aCjTlktQBIqpiVAPIYas5AcXEx6LCRzaxjKAn4465GjZ1zs13GBngMPAceLbyFfwJfTP8m2PR6SfGAM7eP07UB/g0Aw73uXdMbeJMAAAAASUVORK5CYII=" | |
| }, | |
| { | |
| "code": "AFN", | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | [ | |
| { | |
| "name": "Afghanistan", | |
| "code": "AF", | |
| "capital": "Kabul", | |
| "region": "AS", | |
| "currency": { | |
| "code": "AFN", | |
| "name": "Afghan afghani", | |
| "symbol": "؋" | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | import * as expressive from "https://raw.githubusercontent.com/NMathar/deno-express/master/mod.ts"; | |
| import { | |
| getProducts, | |
| getProduct, | |
| addProduct, | |
| updateProduct, | |
| deleteProduct, | |
| } from "./controllers/products.ts"; | |
| (async () => { | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | import { v4 } from "http://deno.land/std/uuid/mod.ts"; | |
| import { Product } from "../types/types.ts"; | |
| let products: Product[] = [ | |
| { | |
| id: "1", | |
| name: "Product 1", | |
| description: "This is product 1", | |
| price: 18.89, | |
| }, | |
| { | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | const deleteProduct = async (request: any, response: any) => { | |
| const id_param = await request.params.id; | |
| products = products.filter((p) => p.id !== id_param); | |
| response.json({ | |
| error: false, | |
| message: "Product Deleted", | |
| data: products, | |
| }); | |
| }; | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | const updateProduct = async (request: any, response: any) => { | |
| const id_param = await request.params.id; | |
| const data = await request.data; | |
| const product: Product | undefined = products.find((p) => p.id === id_param); | |
| if (product) { | |
| const updateData: { | |
| name?: string; | |
| description?: string; | |
| price?: number; | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | const addProduct = async (request: any, response: any) => { | |
| // console.log(await request.data); | |
| if (!request.data) { | |
| response.status = 400; | |
| response.json({ | |
| error: true, | |
| message: "No data", | |
| }); | |
| } else { | |
| const product: Product = await request.data; | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | const getProducts = async (request: any, response: any) => { | |
| await response.json({ | |
| error: false, | |
| data: products, | |
| }); | |
| }; | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | const getProduct = async (request: any, response: any) => { | |
| console.log(request.params); | |
| const product: Product | undefined = products.find( | |
| (p) => p.id === request.params.id | |
| ); | |
| if (product) { | |
| await response.json({ | |
| error: false, | |
| data: product, | |
| }); | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | import { v4 } from "http://deno.land/std/uuid/mod.ts"; | |
| import { Product } from "../types/types.ts"; | |
| let products: Product[] = [ | |
| { | |
| id: "1", | |
| name: "Scott Bike", | |
| description: "scott's products", | |
| price: 18.89, | |
| }, | |
| { | 
NewerOlder