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
| // Fetch Watson Tone Analyzer. Use basic key authentocation | |
| // Get key and url here: https://www.ibm.com/watson/services/tone-analyzer/ | |
| const sentimentAnalysis = async (text: string): Promise<any> => { | |
| const env = Deno.env.toObject(); | |
| const SENTIMENT_KEY = env.SENTIMENT_KEY || "sentish"; | |
| const SENTIMENT_URI = env.SENTIMENT_URI || "localhost"; | |
| const response = await fetch( | |
| `${SENTIMENT_URI}&text=${encodeURI(text)}`, | |
| { |
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 { MongoClient } from "https://deno.land/x/[email protected]/mod.ts"; | |
| interface Course { | |
| _id: { $oid: string }; | |
| title: string; | |
| author: string; | |
| rating: number; | |
| } | |
| const client = new MongoClient(); |
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 { Course } from "../models/course.ts"; | |
| import { courses } from "../data/data.ts"; | |
| // deno-lint-ignore no-explicit-any | |
| export const getCourses = ({ response }: { response: any }) => { | |
| response.body = courses; | |
| }; | |
| export const getCourse = ({ | |
| params, |
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 { assertEquals } from "https://deno.land/std/testing/asserts.ts"; | |
| Deno.test("deno test", () => { | |
| const name = "Jana"; | |
| const surname = "Bergant"; | |
| const fullname = `${name} ${surname}`; | |
| assertEquals(fullname, "Jana Bergant"); | |
| }); |
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 { Application, Router } from "https://deno.land/x/oak/mod.ts"; | |
| const app = new Application(); | |
| const router = new Router(); | |
| const PORT = 8000; | |
| const HOST = "localhost"; | |
| export const getHome = ({ response }: { response: any }) => { | |
| response.body = "Home page"; | |
| }; |
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 { Application, Router } from "https://deno.land/x/oak/mod.ts"; | |
| const env = Deno.env.toObject(); | |
| const PORT = Number(env.PORT) || 8000; | |
| const HOST = env.HOST || "localhost"; | |
| interface Course { | |
| title: string; | |
| author: string; | |
| rating: 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
| import { serve } from "https://deno.land/std/http/server.ts"; | |
| const env = Deno.env.toObject(); | |
| const PORT = Number(env.PORT) || 8000; | |
| const HOST = env.HOST || "localhost"; | |
| const server = serve({ hostname: HOST, port: PORT }); | |
| console.log(`http://${HOST}:${PORT}`); | |
| for await (const req of server) { |
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 { serve } from "https://deno.land/std/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" }); | |
| } |