diff --git a/src/airtable-upload.ts b/src/airtable-upload.ts index c6f2bc7..bea1097 100644 --- a/src/airtable-upload.ts +++ b/src/airtable-upload.ts @@ -1,6 +1,4 @@ -import "https://deno.land/x/dotenv@v3.1.0/load.ts"; - -import { AirtableError, AirtableResp, RecordData } from "./typings.d.ts"; +import { AirtableError, AirtableResp, RecordData } from './typings.d.ts'; /** * Upload podcast record object to Airtable @@ -16,10 +14,10 @@ export const airtableUpload = async ( record: RecordData ): Promise => { const options: RequestInit = { - method: "POST", + method: 'POST', headers: { - Authorization: `Bearer ${Deno.env.get("AIRTABLE_API")}`, - "Content-Type": "application/json", + Authorization: `Bearer ${AIRTABLE_API}`, + 'Content-Type': 'application/json', }, body: JSON.stringify({ records: [ @@ -34,7 +32,7 @@ export const airtableUpload = async ( try { const response: Response = await fetch( - `${Deno.env.get("AIRTABLE_BOOKMARKS_ENDPOINT")}/${table}`, + `${AIRTABLE_BOOKMARKS_ENDPOINT}/${table}`, options ); const results: AirtableResp | AirtableError = await response.json(); @@ -50,7 +48,7 @@ export const airtableUpload = async ( const recordFields = (results as AirtableResp).records[0].fields; return ( - (recordFields.title || recordFields.tweet || recordFields.content) ?? "" + (recordFields.title || recordFields.tweet || recordFields.content) ?? '' ); } catch (error) { throw new Error(`Uploading repos to Airtable: \n ${error}`); diff --git a/src/bookmark-page.ts b/src/bookmark-page.ts index 5add563..d66463a 100644 --- a/src/bookmark-page.ts +++ b/src/bookmark-page.ts @@ -1,6 +1,6 @@ -import { airtableUpload } from "./airtable-upload.ts"; +import { airtableUpload } from './airtable-upload.ts'; -import { BookmarkingResponse } from "./typings.d.ts"; +import { BookmarkingResponse } from './typings.d.ts'; /** * Upload article|comic to Airtable. @@ -29,8 +29,8 @@ export const bookmarkPage = async ( tags, }); - return { success: true, message: airtableResp, source: "bookmarkPage" }; + return { success: true, message: airtableResp, source: 'bookmarkPage' }; } catch (error) { - return { success: false, message: error, source: "bookmarkPage" }; + return { success: false, message: error, source: 'bookmarkPage' }; } }; diff --git a/src/bookmark-podcasts.ts b/src/bookmark-podcasts.ts index 3fc9652..1c7505a 100644 --- a/src/bookmark-podcasts.ts +++ b/src/bookmark-podcasts.ts @@ -1,46 +1,46 @@ -import { airtableUpload } from "./airtable-upload.ts"; +import { airtableUpload } from './airtable-upload.ts'; import { BookmarkingResponse, ParsingPatterns, ParsingService, - BookmarkData , -} from "./typings.d.ts"; + BookmarkData, +} from './typings.d.ts'; // list of regular expressions to find and replace const parsing: ParsingPatterns = { castro: { - title: new RegExp(/

(.*)<\/h1>/, "g"), - creator: new RegExp(/

(.*)<\/a><\/h2>/, "g"), - url: new RegExp(//, "g"), + title: new RegExp(/

(.*)<\/h1>/, 'g'), + creator: new RegExp(/

(.*)<\/a><\/h2>/, 'g'), + url: new RegExp(//, 'g'), }, overcast: { title: new RegExp( /(.*)<\/h2>/, - "g" + 'g' ), - creator: new RegExp(/(.*)<\/a>/, "g"), - url: new RegExp(//, "g"), + creator: new RegExp(/(.*)<\/a>/, 'g'), + url: new RegExp(//, 'g'), }, title: [ - new RegExp(/^S\d+\s/, "g"), - new RegExp(/^Ep\.\d{1,3}\s?/, "g"), - new RegExp(/^([a-zA-Z\D\s]+)?#\d{1,3}:?\s/, "g"), - new RegExp(/^Hasty Treat\s-\s/, "g"), - new RegExp(/^(Bonus|BONUS):\s?/, "g"), - new RegExp(/^Ep\.\s/, "g"), - new RegExp(/\sā€”\sOvercast/, "g"), - new RegExp(/\s-\sYouTube/, "g"), - new RegExp(/\s+on Vimeo/, "g"), - new RegExp(/\s-\sEp\.?\s\d+$/, "g"), - new RegExp(/:\sArticles\sof\sInterest\s#\d+$/, "g"), - new RegExp(/\s\D\s([0-9A-Za-z]+\s)+\D\s(Overcast)/, "g"), + new RegExp(/^S\d+\s/, 'g'), + new RegExp(/^Ep\.\d{1,3}\s?/, 'g'), + new RegExp(/^([a-zA-Z\D\s]+)?#\d{1,3}:?\s/, 'g'), + new RegExp(/^Hasty Treat\s-\s/, 'g'), + new RegExp(/^(Bonus|BONUS):\s?/, 'g'), + new RegExp(/^Ep\.\s/, 'g'), + new RegExp(/\sā€”\sOvercast/, 'g'), + new RegExp(/\s-\sYouTube/, 'g'), + new RegExp(/\s+on Vimeo/, 'g'), + new RegExp(/\s-\sEp\.?\s\d+$/, 'g'), + new RegExp(/:\sArticles\sof\sInterest\s#\d+$/, 'g'), + new RegExp(/\s\D\s([0-9A-Za-z]+\s)+\D\s(Overcast)/, 'g'), new RegExp( /(\D\d{1,3}\s\D\s)|(\d{1,3}\s\D\s)|(\w\d\D\w\d\s\D\s)|(\w+\s\d{1,3}\D\s)|(\d{1,3}\D\s)/, - "g" + 'g' ), - new RegExp(/\s(ā€”)(\s[A-Za-z]+)+/, "g"), - new RegExp(/\s$/, "g"), + new RegExp(/\s(ā€”)(\s[A-Za-z]+)+/, 'g'), + new RegExp(/\s$/, 'g'), ], }; @@ -56,9 +56,9 @@ const paramCleaner = (data: string, pattern: RegExp): string => { const match = data.match(pattern); if (match && match?.length > 0) { - return match[0].replace(pattern, "$1"); + return match[0].replace(pattern, '$1'); } - const error = "Param Cleaner: Unable to find match."; + const error = 'Param Cleaner: Unable to find match.'; console.error(error); throw new Error(error); @@ -73,8 +73,8 @@ const paramCleaner = (data: string, pattern: RegExp): string => { */ const escapedString = (str: string): string => str - .replace(/(["':]+)/g, "\\$1") - .replace(/([,]+)/g, "\\$1") + .replace(/(["':]+)/g, '\\$1') + .replace(/([,]+)/g, '\\$1') .replace(/"/g, '"'); /** @@ -88,8 +88,8 @@ const escapedString = (str: string): string => const titleCleaner = (string: string, patterns: RegExp[]): string => { let cleanTitle = string; - patterns.forEach((regexp) => { - cleanTitle = cleanTitle.replace(regexp, ""); + patterns.forEach(regexp => { + cleanTitle = cleanTitle.replace(regexp, ''); }); return escapedString(cleanTitle); @@ -107,23 +107,23 @@ const titleCleaner = (string: string, patterns: RegExp[]): string => { const getPodcastDetails = async ( url: string, source: string -): Promise => { +): Promise => { const request = await fetch(url); try { const response = await request.text(); // flatten doc; remove breakpoints and excessive spaces const post = response - .replace(/\n\s+/g, "") - .replace(/\n/g, "") - .replace(/\s+/g, " "); + .replace(/\n\s+/g, '') + .replace(/\n/g, '') + .replace(/\s+/g, ' '); // extract details from doc const service = parsing[source] as ParsingService; const title = paramCleaner(post, service.title); const creator = paramCleaner(post, service.creator); const link = paramCleaner(post, service.url).replace( /^(.*)\.(mp3).*/g, - "$1.$2" + '$1.$2' ); return { @@ -150,14 +150,14 @@ export const bookmarkPodcasts = async ( tags: string[] ): Promise => { try { - const podcastData = await getPodcastDetails(url, "castro"); - const airtableResp = await airtableUpload("Podcasts", { + const podcastData = await getPodcastDetails(url, 'castro'); + const airtableResp = await airtableUpload('Podcasts', { ...podcastData, tags, }); - return { success: true, message: airtableResp, source: "bookmarkPodcasts" }; + return { success: true, message: airtableResp, source: 'bookmarkPodcasts' }; } catch (error) { - return { success: false, message: error, source: "bookmarkPodcasts" }; + return { success: false, message: error, source: 'bookmarkPodcasts' }; } }; diff --git a/src/bookmark-reddits.ts b/src/bookmark-reddits.ts index ce515fb..1a8bace 100644 --- a/src/bookmark-reddits.ts +++ b/src/bookmark-reddits.ts @@ -1,6 +1,6 @@ -import { airtableUpload } from "./airtable-upload.ts"; +import { airtableUpload } from './airtable-upload.ts'; -import { BookmarkingResponse, RedditData } from "./typings.d.ts"; +import { BookmarkingResponse, RedditData } from './typings.d.ts'; /** * Get post details via Reddit API. @@ -43,13 +43,13 @@ export const bookmarkReddits = async ( ): Promise => { try { const redditData = await getRedditDetails(url); - const airtableResp = await airtableUpload("Reddits", { + const airtableResp = await airtableUpload('Reddits', { ...redditData, tags, }); - return { success: true, message: airtableResp, source: "bookmarkReddits" }; + return { success: true, message: airtableResp, source: 'bookmarkReddits' }; } catch (error) { - return { success: false, message: error, source: "bookmarkReddits" }; + return { success: false, message: error, source: 'bookmarkReddits' }; } }; diff --git a/src/bookmark-tweets.ts b/src/bookmark-tweets.ts index 79c91f0..64db706 100644 --- a/src/bookmark-tweets.ts +++ b/src/bookmark-tweets.ts @@ -1,12 +1,10 @@ -import "https://deno.land/x/dotenv@v3.1.0/load.ts"; - -import { airtableUpload } from "./airtable-upload.ts"; +import { airtableUpload } from './airtable-upload.ts'; import { BookmarkingResponse, TwitterData, TwitterResponse, -} from "./typings.d.ts"; +} from './typings.d.ts'; // Match unicode and convert to emoji code const emojiRange = new RegExp( @@ -66,7 +64,7 @@ const expandLinks = async (url: string): Promise => { if (!request.url) { console.error({ - message: "Expand Links: unable to expand URL.", + message: 'Expand Links: unable to expand URL.', status: request.status, }); @@ -93,7 +91,7 @@ const expandShortLink = async (str: string, regex: RegExp): Promise => { const promises: Promise[] = []; const pattern = new RegExp(regex); - // deno-lint-ignore no-unused-vars + // eslint-disable-next-line no-unused-vars str.replace(pattern, (match, ...args) => { const promise = expandLinks(match); promises.push(promise); @@ -102,7 +100,7 @@ const expandShortLink = async (str: string, regex: RegExp): Promise => { }); const data = await Promise.all(promises); - const replacer = () => data.shift() ?? ""; + const replacer = () => data.shift() ?? ''; return str.replace(regex, replacer); } catch (error) { @@ -119,10 +117,10 @@ const expandShortLink = async (str: string, regex: RegExp): Promise => { */ const cleanUrl = (url: string): string => { const updatedStr = url - .replace(/(https\:\/\/([a-z]+\.)?twitter\.com\/)/g, "") + .replace(/(https:\/\/([a-z]+\.)?twitter\.com\/)/g, '') .replace( /.*\/status\/([0-9]+)(.*)?/g, - "https://api.twitter.com/2/tweets/$1" + 'https://api.twitter.com/2/tweets/$1' ); return updatedStr; @@ -144,8 +142,8 @@ const getTweetDetails = async (url: string): Promise => { `${endpoint}?tweet.fields=created_at&user.fields=username&expansions=author_id`, { headers: { - Authorization: `Bearer ${Deno.env.get("TWITTER_KEY")}`, - "Content-Type": "application/json", + Authorization: `Bearer ${TWITTER_KEY}`, + 'Content-Type': 'application/json', }, } ); @@ -182,13 +180,13 @@ export const bookmarkTweets = async ( ): Promise => { try { const tweetData = await getTweetDetails(url); - const airtableResp = await airtableUpload("Tweets", { + const airtableResp = await airtableUpload('Tweets', { ...tweetData, tags, }); - return { success: true, message: airtableResp, source: "bookmarkTweets" }; + return { success: true, message: airtableResp, source: 'bookmarkTweets' }; } catch (error) { - return { success: false, message: error, source: "bookmarkTweets" }; + return { success: false, message: error, source: 'bookmarkTweets' }; } }; diff --git a/src/bookmark-vimeos.ts b/src/bookmark-vimeos.ts index 9d5fc44..85a405e 100644 --- a/src/bookmark-vimeos.ts +++ b/src/bookmark-vimeos.ts @@ -1,12 +1,10 @@ -import "https://deno.land/x/dotenv@v3.1.0/load.ts"; - -import { airtableUpload } from "./airtable-upload.ts"; +import { airtableUpload } from './airtable-upload.ts'; import { BookmarkData, BookmarkingResponse, VimeoResponse, -} from "./typings.d.ts"; +} from './typings.d.ts'; /** * Convert video url to API ready endpoint. Extracts video ID. @@ -18,7 +16,7 @@ import { const cleanUrl = (url: string): string => { const updatedStr = url.replace( /(https:\/\/vimeo\.com\/)(.*)/g, - "https://api.vimeo.com/videos/$2" + 'https://api.vimeo.com/videos/$2' ); return updatedStr; @@ -38,7 +36,7 @@ const getVimeoDetails = async (url: string): Promise => { const endpoint = cleanUrl(url); const request = await fetch(endpoint, { headers: { - Authorization: `Bearer ${Deno.env.get("VIMEO_KEY")}`, + Authorization: `Bearer ${VIMEO_KEY}`, }, }); const response: VimeoResponse = await request.json(); @@ -68,13 +66,13 @@ export const bookmarkVimeo = async ( ): Promise => { try { const vimeoData = await getVimeoDetails(url); - const airtableResp = await airtableUpload("Videos", { + const airtableResp = await airtableUpload('Videos', { ...vimeoData, tags, }); - return { success: true, message: airtableResp, source: "bookmarkVimeo" }; + return { success: true, message: airtableResp, source: 'bookmarkVimeo' }; } catch (error) { - return { success: false, message: error, source: "bookmarkVimeo" }; + return { success: false, message: error, source: 'bookmarkVimeo' }; } }; diff --git a/src/bookmark-youtubes.ts b/src/bookmark-youtubes.ts index 0f26b81..8be0f62 100644 --- a/src/bookmark-youtubes.ts +++ b/src/bookmark-youtubes.ts @@ -1,13 +1,11 @@ -import "https://deno.land/x/dotenv@v3.1.0/load.ts"; - -import { airtableUpload } from "./airtable-upload.ts"; +import { airtableUpload } from './airtable-upload.ts'; import { BookmarkData, BookmarkingResponse, YouTubeAPIEndpoint, YouTubeResponse, -} from "./typings.d.ts"; +} from './typings.d.ts'; /** * Convert video url to API ready endpoint. Extracts youtube ID. @@ -18,8 +16,8 @@ import { */ const cleanUrl = (url: string): YouTubeAPIEndpoint => { const extractedID = url - .replace(/(https\:\/\/)(youtu.*)\.(be|com)\/(watch\?v=)?/g, "") - .replace("&feature=share", ""); + .replace(/(https:\/\/)(youtu.*)\.(be|com)\/(watch\?v=)?/g, '') + .replace('&feature=share', ''); const endpoint = `https://youtube.googleapis.com/youtube/v3/videos?id=${extractedID}`; const link = `https://youtu.be/${extractedID}`; @@ -38,9 +36,7 @@ const cleanUrl = (url: string): YouTubeAPIEndpoint => { const getYouTubeDetails = async (url: string): Promise => { try { const { endpoint, link } = cleanUrl(url); - const request = await fetch( - `${endpoint}&key=${Deno.env.get("YOUTUBE_KEY")}` - ); + const request = await fetch(`${endpoint}&key=${YOUTUBE_KEY}`); const response: YouTubeResponse = await request.json(); const video = response.items[0].snippet; @@ -69,13 +65,13 @@ export const bookmarkYouTube = async ( ): Promise => { try { const youtTubeData = await getYouTubeDetails(url); - const airtableResp = await airtableUpload("Videos", { + const airtableResp = await airtableUpload('Videos', { ...youtTubeData, tags, }); - return { success: true, message: airtableResp, source: "bookmarkYouTube" }; + return { success: true, message: airtableResp, source: 'bookmarkYouTube' }; } catch (error) { - return { success: false, message: error, source: "bookmarkYouTube" }; + return { success: false, message: error, source: 'bookmarkYouTube' }; } }; diff --git a/src/handler.ts b/src/handler.ts new file mode 100644 index 0000000..c345944 --- /dev/null +++ b/src/handler.ts @@ -0,0 +1,155 @@ +import { bookmarkPage } from './bookmark-page.ts'; +import { bookmarkPodcasts } from './bookmark-podcasts.ts'; +import { bookmarkReddits } from './bookmark-reddits.ts'; +import { bookmarkTweets } from './bookmark-tweets.ts'; +import { bookmarkVimeo } from './bookmark-vimeos.ts'; +import { bookmarkYouTube } from './bookmark-youtubes.ts'; + +import { BookmarkingResponse, RequestPayload } from './typings.d.ts'; + +const responseInit = { + headers: { + 'Content-Type': 'application/json; charset=utf-8', + }, +}; +const badReqBody = { + status: 400, + statusText: 'Bad Request', + ...responseInit, +}; +const errReqBody = { + status: 500, + statusText: 'Internal Error', + ...responseInit, +}; +const noAuthReqBody = { + status: 401, + statusText: 'Unauthorized', + ...responseInit, +}; + +const handleAction = async (payload: RequestPayload): Promise => { + try { + let response: BookmarkingResponse; + + switch (true) { + case payload.table === 'Podcasts': { + response = await bookmarkPodcasts(payload.url, payload.tags); + break; + } + case payload.table === 'Reddits': { + response = await bookmarkReddits(payload.url, payload.tags); + break; + } + case payload.table === 'Tweets': { + response = await bookmarkTweets(payload.url, payload.tags); + break; + } + case payload.table === 'Videos': { + if (payload.url.includes('vimeo')) { + response = await bookmarkVimeo(payload.url, payload.tags); + } else { + response = await bookmarkYouTube(payload.url, payload.tags); + } + break; + } + default: { + response = await bookmarkPage( + payload.table, + payload.data?.title ?? '', + payload.data?.creator ?? '', + payload.url, + payload.tags + ); + break; + } + } + + if (!response.success) { + return new Response( + JSON.stringify({ error: response.message, location: response.source }), + responseInit + ); + } + + return new Response( + JSON.stringify({ message: response.message, location: payload.table }), + responseInit + ); + } catch (error) { + return new Response( + JSON.stringify({ error, location: payload.table }), + errReqBody + ); + } +}; + +export const handleRequest = async (request: Request): Promise => { + if (request.method !== 'POST') { + return new Response(null, { + status: 405, + statusText: 'Method Not Allowed', + }); + } + + if (!request.headers.has('content-type')) { + return new Response( + JSON.stringify({ error: "Please provide 'content-type' header." }), + badReqBody + ); + } + + const contentType = request.headers.get('content-type'); + + if (contentType?.includes('application/json')) { + const payload: RequestPayload = await request.json(); + + switch (true) { + case !payload.table: + return new Response( + JSON.stringify({ error: "Missing 'table' parameter." }), + badReqBody + ); + case payload.table === 'Articles' && !payload.data?.title: + return new Response( + JSON.stringify({ error: "Missing 'data.title' parameter." }), + badReqBody + ); + case payload.table === 'Comics' && !payload.data?.creator: + return new Response( + JSON.stringify({ error: "Missing 'data.creator' parameter." }), + badReqBody + ); + case !payload.url: + return new Response( + JSON.stringify({ error: "Missing 'url' parameter." }), + badReqBody + ); + case payload.tags.length === 0 || !Array.isArray(payload.tags): + return new Response( + JSON.stringify({ error: "Missing 'tags' parameter." }), + badReqBody + ); + case !payload.key: + return new Response( + JSON.stringify({ error: "Missing 'key' parameter." }), + noAuthReqBody + ); + case payload.key !== AUTH_KEY: + return new Response( + JSON.stringify({ + error: "You're not authorized to access this API.", + }), + noAuthReqBody + ); + default: { + return handleAction(payload); + } + } + } + + return new Response(null, { + status: 415, + statusText: 'Unsupported Media Type', + }); +}; diff --git a/src/index.ts b/src/index.ts index 2fdbcc6..b442882 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,160 +1,6 @@ -import "https://deno.land/x/dotenv@v3.1.0/load.ts"; -import { listenAndServe } from "https://deno.land/std@0.111.0/http/server.ts"; +/* eslint-disable no-restricted-globals */ +import { handleRequest } from './handler.ts'; -import { bookmarkPage } from "./bookmark-page.ts"; -import { bookmarkPodcasts } from "./bookmark-podcasts.ts"; -import { bookmarkReddits } from "./bookmark-reddits.ts"; -import { bookmarkTweets } from "./bookmark-tweets.ts"; -import { bookmarkVimeo } from "./bookmark-vimeos.ts"; -import { bookmarkYouTube } from "./bookmark-youtubes.ts"; - -import { BookmarkingResponse, RequestPayload } from "./typings.d.ts"; - -const responseInit = { - headers: { - "Content-Type": "application/json; charset=utf-8", - }, -}; -const badReqBody = { - status: 400, - statusText: "Bad Request", - ...responseInit, -}; -const errReqBody = { - status: 500, - statusText: "Internal Error", - ...responseInit, -}; -const noAuthReqBody = { - status: 401, - statusText: "Unauthorized", - ...responseInit, -}; - -const handleAction = async (payload: RequestPayload): Promise => { - try { - let response: BookmarkingResponse; - - switch (true) { - case payload.table === "Podcasts": { - response = await bookmarkPodcasts(payload.url, payload.tags); - break; - } - case payload.table === "Reddits": { - response = await bookmarkReddits(payload.url, payload.tags); - break; - } - case payload.table === "Tweets": { - response = await bookmarkTweets(payload.url, payload.tags); - break; - } - case payload.table === "Videos": { - if (payload.url.includes("vimeo")) { - response = await bookmarkVimeo(payload.url, payload.tags); - } else { - response = await bookmarkYouTube(payload.url, payload.tags); - } - break; - } - default: { - response = await bookmarkPage( - payload.table, - payload.data?.title ?? "", - payload.data?.creator ?? "", - payload.url, - payload.tags - ); - break; - } - } - - if (!response.success) { - return new Response( - JSON.stringify({ error: response.message, location: response.source }), - responseInit - ); - } - - return new Response( - JSON.stringify({ message: response.message, location: payload.table }), - responseInit - ); - } catch (error) { - return new Response( - JSON.stringify({ error, location: payload.table }), - errReqBody - ); - } -}; - -const handleRequest = async (request: Request) => { - if (request.method !== "POST") { - return new Response(null, { - status: 405, - statusText: "Method Not Allowed", - }); - } - - if (!request.headers.has("content-type")) { - return new Response( - JSON.stringify({ error: "Please provide 'content-type' header." }), - badReqBody - ); - } - - const contentType = request.headers.get("content-type"); - - if (contentType?.includes("application/json")) { - const payload: RequestPayload = await request.json(); - - switch (true) { - case !payload.table: - return new Response( - JSON.stringify({ error: "Missing 'table' parameter." }), - badReqBody - ); - case payload.table === "Articles" && !payload.data?.title: - return new Response( - JSON.stringify({ error: "Missing 'data.title' parameter." }), - badReqBody - ); - case payload.table === "Comics" && !payload.data?.creator: - return new Response( - JSON.stringify({ error: "Missing 'data.creator' parameter." }), - badReqBody - ); - case !payload.url: - return new Response( - JSON.stringify({ error: "Missing 'url' parameter." }), - badReqBody - ); - case payload.tags.length === 0 || !Array.isArray(payload.tags): - return new Response( - JSON.stringify({ error: "Missing 'tags' parameter." }), - badReqBody - ); - case !payload.key: - return new Response( - JSON.stringify({ error: "Missing 'key' parameter." }), - noAuthReqBody - ); - case payload.key !== Deno.env.get("AUTH_KEY"): - return new Response( - JSON.stringify({ - error: "You're not authorized to access this API.", - }), - noAuthReqBody - ); - default: { - return handleAction(payload); - } - } - } - - return new Response(null, { - status: 415, - statusText: "Unsupported Media Type", - }); -}; - -await listenAndServe(":8080", handleRequest); +addEventListener('fetch', event => { + event.respondWith(handleRequest(event.request)); +}); diff --git a/src/typings.d.ts b/src/typings.d.ts index 58a2d3e..691cb59 100644 --- a/src/typings.d.ts +++ b/src/typings.d.ts @@ -1,4 +1,4 @@ -// deno-lint-ignore-file camelcase +/* eslint-disable camelcase */ export interface BookmarkData { title: string; creator: string; @@ -691,7 +691,7 @@ export interface VimeoResponse { }; }; resource_key: string; - short_bio: "This is a short biography about me!"; + short_bio: 'This is a short biography about me!'; skills: { name: string; uri: string;