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 amqp, { Message } from 'amqplib/callback_api' | |
const createMQConsumer = (amqpURl: string, queueName: string) => { | |
console.log('Connecting to RabbitMQ...') | |
return () => { | |
amqp.connect(amqpURl, (errConn, conn) => { | |
if (errConn) { | |
throw errConn | |
} |
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 amqp, { Connection } from 'amqplib/callback_api' | |
const createMQProducer = (amqpUrl: string, queueName: string) => { | |
console.log('Connecting to RabbitMQ...') | |
let ch: any | |
amqp.connect(amqpUrl, (errorConnect: Error, connection: Connection) => { | |
if (errorConnect) { | |
console.log('Error connecting to RabbitMQ: ', errorConnect) | |
return | |
} |
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 bodyParser from 'body-parser' | |
import express, { Request, Response } from 'express' | |
const PORT = 3001 | |
const app = express() | |
app.use(bodyParser.json()) | |
app.get('/', (req: Request, res: Response) => { |
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 bodyParser from 'body-parser' | |
import express, { Request, Response } from 'express' | |
const PORT = 3000 | |
const app = express() | |
app.use(bodyParser.json()) | |
app.post('/register', (req: Request, res: Response) => { |
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
Show hidden characters
{ | |
"compilerOptions": { | |
/* Visit https://aka.ms/tsconfig.json to read more about this file */ | |
/* Language and Environment */ | |
"target": "es6", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */ | |
/* Modules */ | |
"module": "commonjs", /* Specify what module code is generated. */ | |
"rootDir": "./src", /* Specify the root folder within your source files. */ |
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
# Base image | |
FROM python:3.9 | |
# Set environment varibles | |
ENV PYTHONDONTWRITEBYTECODE 1 | |
ENV PYTHONUNBUFFERED 1 | |
WORKDIR /app | |
COPY requirements.txt /app/requirements.txt |
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
from fastapi import FastAPI | |
app = FastAPI() | |
@app.get('/') | |
def index(): | |
return '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
import os | |
import boto3 | |
import pathlib | |
from dotenv import load_dotenv | |
from boto3.resources.base import ServiceResource | |
base_dir = pathlib.Path(__file__).parent.parent.parent | |
load_dotenv(base_dir.joinpath('.env')) |
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
DB_REGION_NAME=<REGION_NAME> | |
DB_ACCESS_KEY_ID=<ACCESS_KEY_ID> | |
DB_SECRET_ACCESS_KEY=<SECRET_ACCESS_KEY> |
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 boto3 | |
def generate_table(ddb): | |
ddb = boto3.resource('dynamodb', | |
endpoint_url='http://localhost:8000', | |
region_name='example', # note that if you create a table using different region name and aws key | |
aws_access_key_id='example', # you won't see this table on the admin app | |
aws_secret_access_key='example') | |
ddb.create_table( |