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
<div class="container not-loaded"> | |
<div class="night"></div> | |
<div class="flowers"> | |
<div class="flower flower--1"> | |
<div class="flower__leafs flower__leafs--1"> | |
<div class="flower__leaf flower__leaf--1"></div> | |
<div class="flower__leaf flower__leaf--2"></div> | |
<div class="flower__leaf flower__leaf--3"></div> | |
<div class="flower__leaf flower__leaf--4"></div> | |
<div class="flower__white-circle"></div> |
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
<div class="wrapper"> | |
<div class="bg"> | |
<div class="load"></div> | |
</div> | |
</div> | |
<div class ="text"> Loading... </div> |
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>Code The World - IO</title> | |
<link rel="stylesheet" href="style.css"></style> | |
</head> |
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 { getLinksByQuery } from './utils/scraper'; | |
import { consume } from './utils/scraper-queue'; | |
import { updateTransactionToDone, updateTransactionToProcessing } from './utils/scraper-transaction'; | |
(async () => { | |
await consume(async (item) => { | |
await updateTransactionToProcessing(item.transactionId.toString()); | |
const links = await getLinksByQuery(item.query); |
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 { ISearchResult, ITransaction } from './interfaces'; | |
import getRedisClient from './redis'; | |
export async function addTransaction(transactionId: string): Promise<void> { | |
const redisClient = await getRedisClient(); | |
await redisClient.set( | |
transactionId, | |
JSON.stringify({ status: 'ON_QUEUE' } as ITransaction), | |
{ EX: 15 * 60 }, |
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 { | |
Channel, | |
connect, | |
Connection, | |
} from 'amqplib'; | |
import environments from './environments'; | |
let connection: Connection; | |
const channels: Record<string, Channel> = {}; |
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
export interface ILink { | |
title: string; | |
link: string; | |
} | |
export interface ISearchResult { | |
query: string; | |
took: number; | |
links: ILink[]; | |
} |
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 environments from './environments'; | |
import { IQueueItem } from './interfaces'; | |
import getChannel from './rabbitmq'; | |
export async function sendQueryToQueue(item: IQueueItem): Promise<boolean> { | |
const channel = await getChannel(environments.rabbitMQScraperQueue); | |
const message = JSON.stringify(item); | |
return channel.sendToQueue(environments.rabbitMQScraperQueue, Buffer.from(message)); | |
} |
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
/* eslint-disable no-console */ | |
import express from 'express'; | |
import environments from './utils/environments'; | |
import { sendQueryToQueue } from './utils/scraper-queue'; | |
import { addTransaction, getTransactionResult } from './utils/scraper-transaction'; | |
const app = express(); | |
app.get('/', (req, res) => { | |
res.json({ message: 'Hello World!' }); |
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
diff --git a/docker-compose.yml b/docker-compose.yml | |
index 94302ff..19dff7a 100644 | |
--- a/docker-compose.yml | |
+++ b/docker-compose.yml | |
@@ -1,7 +1,7 @@ | |
version: '3.9' | |
services: | |
api: | |
- build: . | |
+ build: node:latest |
NewerOlder