import type {AModel} from "./models/a/a.model";
import schema from './test.json';
import abcd from "./any";
const a: AModel = {
a: schema,
b: 1
};
const AB = 123;
console.log(a, AB, abcd);
var o={A:"B"};var e="Hello module!";var m={a:o,b:1},t=123;console.log(m,t,e);
import * as express from 'express';
import * as http from "http";
import * as path from "path";
import * as dotenv from 'dotenv';
dotenv.config({path: path.resolve(__dirname, './.env')});
import socket_io_listener from "./src/socket.io/socket_io";
import * as cors from 'cors';
import * as fs from "fs";
import {Validator} from "express-json-validator-middleware";
import {validation_middleware} from "./src/controllers/validator.controller";
import {jwt_authentication_controller} from "./src/controllers/jwt_authentication.controller";
import {basic_authentication_controller} from "./src/controllers/basic_authentication.controller";
import {messages_controller} from "./src/controllers/messages.controller";
import {message_controller} from "./src/controllers/message.controller";
import {register_controller} from "./src/controllers/register.controller";
import {authentication_controller} from "./src/controllers/authentication.controller";
import * as ExpressBrute from 'express-brute';
import {users_controller} from "./src/controllers/users.controller";
import {meetings_controller} from "./src/controllers/meetings.controller";
import {user_controller} from "./src/controllers/user.controller";
import {CallController} from "./src/controllers/call.controller";
import {query} from './src/databases/mongodb';
import {ControllerResponseModel} from "./src/models/controllers/response.model";
import {Response} from "express";
const app = express();
const http_server = http.createServer(app);
socket_io_listener(http_server);
const { validate } = new Validator({});
const schema = (file_path: string) => JSON.parse(fs.readFileSync(__dirname + '/src/models' + file_path).toString());
const brute_force_defense = (options: ExpressBrute.Options) => {
const store = new ExpressBrute.MemoryStore();
return new ExpressBrute(store, options).prevent;
}
app.use(express.static(path.resolve(__dirname, '../dist')));
app.use(express.json());
app.use(cors({
origin: ['http://localhost:4200'],
exposedHeaders: ['Authentication']
}));
// app.use(basic_authentication_controller);
app.use(jwt_authentication_controller);
app.use('/auth', brute_force_defense({freeRetries: 1}));
// app.use('/call', brute_force_defense({freeRetries: 1}));
app.use('/register', brute_force_defense({freeRetries: 1}));
app.use('/messages', brute_force_defense({freeRetries: 80}));
query('calls').then(data => {
new CallController(
app,
{
name: '/call',
params: [
'meeting_id?',
'limit?',
'last?'
]
},
data.collection,
data.client,
{
// 'post': validate({body: schema('/controllers/authentication/request.schema.json')}),
}
);
});
app.post('/user', user_controller);
app.post('/meetings', meetings_controller)
app.post('/users', users_controller);
app.post('/auth', validate({body: schema('/controllers/authentication/request.schema.json')}), authentication_controller);
app.post('/register', validate({body: schema('/controllers/register/request.schema.json')}), register_controller);
app.post('/messages', messages_controller);
app.post('/message', message_controller);
app.use(validation_middleware);
http_server.listen(4000, () => {
console.log('Listening on port 4000');
});
const esbuild = require('esbuild');
const { nodeExternalsPlugin } = require('esbuild-node-externals');
esbuild.build({
entryPoints: ['src/main.ts'],
bundle: true,
platform: 'node',
tsconfig: "tsconfig.json",
minify: true,
outfile: 'dist/main.js',
plugins: [nodeExternalsPlugin()],
});
{
"name": "backend",
"version": "1.0.0",
"description": "",
"main": "main.ts",
"scripts": {
"start": "nodemon src/main.ts",
"build": "tsc -noEmit && node build.js",
"schema": "ts-node src/create_schema.ts"
},
"private": false,
"dependencies": {
"argon2": "^0.30.1",
"cors": "^2.8.5",
"dotenv": "^16.0.3",
"express": "^4.18.1",
"express-brute": "^1.0.1",
"express-json-validator-middleware": "^3.0.1",
"jsonwebtoken": "^8.5.1",
"mongodb": "^4.10.0",
"nodemon": "^2.0.19",
"rate-limiter-flexible": "^2.4.1",
"rxjs": "~7.5.0",
"socket.io": "^4.5.1",
"uuid": "^9.0.0"
},
"devDependencies": {
"@types/express-brute": "^1.0.1",
"@types/jsonwebtoken": "^8.5.9",
"@types/uuid": "^8.3.4",
"esbuild-node-externals": "^1.6.0",
"typescript": "~4.9.4"
},
"author": "",
"license": "ISC"
}
{
"compilerOptions": {
"baseUrl": "./",
"outDir": "./dist/",
"noImplicitAny": true,
"module": "commonjs",
"target": "ES2015",
"allowJs": true,
"moduleResolution": "node",
"resolveJsonModule": true,
"esModuleInterop": true,
"isolatedModules": true
},
"exclude": [
"node_modules",
"typescript-json-schema",
"src/**/*.model.ts"
]
}