Skip to content

Commit

Permalink
⚡ feat(images): Added feature to upload images to a region
Browse files Browse the repository at this point in the history
  • Loading branch information
Nachwahl committed Jan 28, 2023
1 parent e39bce5 commit a39c0b8
Show file tree
Hide file tree
Showing 24 changed files with 2,040 additions and 1,001 deletions.
3 changes: 1 addition & 2 deletions backend/cli/convert.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
/******************************************************************************
* convert.ts *
* *
* Copyright (c) 2022 Robin Ferch *
* Copyright (c) 2022-2023 Robin Ferch *
* https://robinferch.me *
* This project is released under the MIT license. *
******************************************************************************/

import * as fs from 'fs/promises';
import {PrismaClient} from "@prisma/client";
import axios from "axios";
import {log} from "util";

let prisma = new PrismaClient();

Expand Down
8 changes: 5 additions & 3 deletions backend/index.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
/******************************************************************************
* index.ts *
* *
* Copyright (c) 2022 Robin Ferch *
* Copyright (c) 2022-2023 Robin Ferch *
* https://robinferch.me *
* This project is released under the MIT license. *
******************************************************************************/

import Core from './src/Core';
import Core from './src/Core.js';

require('dotenv').config();
import * as dotenv from 'dotenv'

dotenv.config()

const core = new Core();
core.getLogger().info('Starting Polymap backend');
Expand Down
26 changes: 18 additions & 8 deletions backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,25 @@
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "babel-node index.js",
"start-nodemon": "nodemon --exec babel-node index.js",
"start:migrate": "npx prisma migrate deploy && node index.js"
"start": "node index.js",
"start-nodemon": "nodemon index.js",
"start:migrate": "npx prisma migrate deploy && node index.js",
"build": "tsc"
},
"type": "module",
"author": "",
"devDependencies": {
"@babel/cli": "^7.14.3",
"@babel/core": "^7.14.5",
"@babel/node": "^7.14.5",
"@babel/preset-env": "^7.13.5",
"@types/express": "^4.17.11",
"@types/express-fileupload": "^1.4.1",
"@types/express-session": "^1.17.4",
"@types/imagemin": "^8.0.0",
"@types/imagemin-webp": "^7.0.0",
"@types/jsonwebtoken": "^8.5.2",
"@types/minio": "^7.0.14",
"@types/node": "^15.6.1",
"@types/validator": "^13.1.3",
"@typescript-eslint/eslint-plugin": "^4.27.0",
Expand All @@ -25,33 +32,36 @@
"eslint-config-airbnb-base": "^14.2.1",
"eslint-plugin-import": "^2.23.4",
"prisma": "^3.15.2",
"ts-node": "^10.7.0"
"ts-node": "^10.7.0",
"typescript": "^4.9.4"
},
"dependencies": {
"@keycloak/keycloak-admin-client": "^17.0.0",
"@keycloak/keycloak-admin-client": "^20.0.3",
"@prisma/client": "^3.15.2",
"@turf/center": "^6.5.0",
"@turf/turf": "^6.5.0",
"@types/express-session": "^1.17.4",
"@types/minio": "^7.0.14",
"body-parser": "^1.19.0",
"chalk": "^4.1.2",
"discord.js": "^13.6.0",
"dotenv": "^10.0.0",
"express": "^4.17.1",
"express-fileupload": "^1.4.0",
"express-session": "^1.17.2",
"express-validator": "^6.14.0",
"express-yup-middleware": "^1.1.3",
"imagemin": "^8.0.1",
"imagemin-webp": "^8.0.0",
"inquirer": "^8.0.0",
"jsonwebtoken": "^8.5.1",
"keycloak-connect": "^17.0.0",
"keycloak-connect": "^20.0.3",
"log4js": "^6.3.0",
"meilisearch": "^0.30.0",
"minio": "^7.0.32",
"reflect-metadata": "^0.1.13",
"rfdc": "^1.3.0",
"socket.io": "^4.5.1",
"supercluster": "^7.1.5",
"winston": "^3.8.2",
"yup": "^0.32.11"
},
"prisma": {
Expand Down
50 changes: 37 additions & 13 deletions backend/src/Core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@
* This project is released under the MIT license. *
******************************************************************************/

import {configure, getLogger, Logger} from 'log4js';
import Web from './web/Web';
import * as Keycloak from "keycloak-connect";
import Web from './web/Web.js';
import * as session from "express-session";
import KeycloakAdmin from "./util/KeycloakAdmin";
import KeycloakAdmin from "./util/KeycloakAdmin.js";
import {PrismaClient} from "@prisma/client";
import DiscordIntegration from "./util/DiscordIntegration";
import S3Controller from "./util/S3Controller";
import SearchController from "./util/SearchController";
import DiscordIntegration from "./util/DiscordIntegration.js";
import S3Controller from "./util/S3Controller.js";
import SearchController from "./util/SearchController.js";
import {MeiliSearch} from "meilisearch";
import * as winston from "winston";
import Keycloak from "keycloak-connect";

class Core {
web: Web;
Expand All @@ -25,8 +25,8 @@ class Core {
prisma: PrismaClient;
discord: DiscordIntegration;
s3: S3Controller;

search: SearchController;
logger: winston.Logger;


constructor() {
Expand All @@ -45,21 +45,45 @@ class Core {
this.discord = new DiscordIntegration(this);
this.s3 = new S3Controller(this);
this.search = new SearchController(this);

}

private setUpLogger(): void {
const logger = this.getLogger();
logger.level = process.env.LOGLEVEL;
const logger = winston.createLogger({
level: process.env.LOGLEVEL,
format: winston.format.combine(
winston.format.timestamp(),
winston.format.json(),
),
transports: [
new winston.transports.File({filename: 'logs/error.log', level: 'error'}),
new winston.transports.File({filename: 'logs/combined.log'}),
],
});

if (process.env.NODE_ENV !== 'production') {
const consoleFormat = winston.format.printf(({level, message, timestamp}) => {
return `${timestamp} | ${level} » ${message}`;
});

logger.add(new winston.transports.Console({
format: winston.format.combine(
winston.format.colorize(),
winston.format.simple(),
consoleFormat
),
}));
}

this.logger = logger;
}

public getLogger = (): Logger => getLogger();
public getLogger = (): winston.Logger => this.logger;
public getKeycloak = (): Keycloak.Keycloak => this.keycloak;
public getKeycloakAdmin = (): KeycloakAdmin => this.keycloakAdmin;
public getPrisma = (): PrismaClient => this.prisma;
public getDiscord = (): DiscordIntegration => this.discord;
public getWeb = (): Web => this.web;
public getS3 = (): S3Controller => this.s3.getMinioInstance();
public getS3 = (): S3Controller => this.s3;
public getSearch = (): MeiliSearch => this.search.getMeiliInstance();

}
Expand Down
5 changes: 3 additions & 2 deletions backend/src/controllers/AdminController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
* This project is released under the MIT license. *
******************************************************************************/

import Core from "../Core";
import axios from "axios";
import Core from "../Core.js";
import {response} from "express";
import {centerOfMass, polygon} from "@turf/turf";
import axios from "axios";


class AdminController {
private core: Core;
Expand Down
12 changes: 2 additions & 10 deletions backend/src/controllers/InteractiveBuildingsController.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,12 @@
/******************************************************************************
* InteractiveBuildingsController.ts *
* *
* Copyright (c) 2022 Robin Ferch *
* Copyright (c) 2022-2023 Robin Ferch *
* https://robinferch.me *
* This project is released under the MIT license. *
******************************************************************************/

import Core from "../Core";

/******************************************************************************
* InteractiveBuildingsController.ts *
* *
* Copyright (c) 2022 Robin Ferch *
* https://robinferch.me *
* This project is released under the MIT license. *
******************************************************************************/
import Core from "../Core.js";

import {Request, Response} from "express";

Expand Down
Loading

0 comments on commit a39c0b8

Please sign in to comment.