Android project added

- Android can now send messages over RabbitMQ to the backend.
This commit is contained in:
2020-10-19 22:19:28 +02:00
parent 48140f557b
commit f722ee9595
56 changed files with 1522 additions and 12 deletions

View File

@@ -1,27 +1,29 @@
import bodyParser = require('body-parser');
import { bold } from 'chalk';
import { config as dconfig } from 'dotenv';
import * as express from 'express';
import * as figlet from 'figlet';
import * as mongoose from 'mongoose';
import { exit } from 'process';
import { hash } from 'argon2';
import { config as dconfig } from 'dotenv';
import * as winston from 'winston';
import * as express from 'express';
import { RabbitMQ } from './lib/rabbit';
import { User } from './models/user/user.model';
import { UserType } from './models/user/user.interface';
import bodyParser = require('body-parser');
import { config } from './config';
import { DeleteUser, GetUser, LoginUser, MW_User, PatchUser } from './endpoints/user';
import { hashPassword, randomPepper, randomString } from './lib/crypto';
import { config } from './config';
import { UserType } from './models/user/user.interface';
import { User } from './models/user/user.model';
// Load .env
dconfig({ debug: true, encoding: 'UTF-8' });
export const MONGO_URI = process.env.MONGO_URI || "";
export const JWT_SECRET = process.env.JWT_SECRET;
export const IS_DEBUG = process.env.DEBUG == 'true'
export const RABBITMQ_URI = process.env.RABBITMQ_URI || "";
export const JWT_SECRET = process.env.JWT_SECRET || "";
export const IS_DEBUG = process.env.DEBUG == 'true';
export let logger: winston.Logger;
export let rabbitmq: RabbitMQ;
async function run() {
const { combine, timestamp, label, printf, prettyPrint } = winston.format;
@@ -74,11 +76,16 @@ async function run() {
logger.info("Debug mode is enabled. Do not use this in production!")
}
if (JWT_SECRET == undefined) {
if (JWT_SECRET == "") {
logger.crit("No JWT secret was provided. Make sure you add JWT_SECRET=YOUR_SECRET to your .env file.");
exit(1);
}
if (RABBITMQ_URI == "") {
logger.crit("No RabbitMQ URI was provided. Make sure you add RABBITMQ_URI=YOUR_URL to your .env file.");
exit(1);
}
/**
* Database connection
*/
@@ -108,6 +115,13 @@ async function run() {
logger.debug("At least one admin user already exists, skip.");
}
/**
* Message broker
*/
rabbitmq = new RabbitMQ();
await rabbitmq.init();
logger.info("Connected with message broker.");
/**
* HTTP server
*/