From aa6643e02379785bc272e8f257089e05c2bec874 Mon Sep 17 00:00:00 2001 From: Filip Rojek Date: Mon, 29 Apr 2024 20:44:19 +0200 Subject: [PATCH] Zmena planu --- api/.githooks/pre-push | 59 -------- api/.gitignore | 3 - api/.prettierrc | 15 -- api/README.md | 1 - api/norkconfig.json | 12 -- api/package.json | 73 ---------- api/setup-repo.sh | 5 - api/src/.env.example | 26 ---- api/src/app.ts | 42 ------ api/src/config/database.ts | 49 ------- api/src/config/environment.ts | 59 -------- api/src/config/sequelize.config.ts | 10 -- api/src/controllers/rootController.ts | 6 - api/src/interfaces/globalInterface.ts | 4 - api/src/middlewares/authMiddleware.ts | 63 --------- api/src/middlewares/handleValidation.ts | 16 --- api/src/middlewares/index.ts | 6 - api/src/middlewares/sayHiMiddleware.ts | 9 -- api/src/models/User.ts | 35 ----- api/src/public/expressjs.png | Bin 5032 -> 0 bytes api/src/public/nodejs_logo.svg | 1 - api/src/routes/index.ts | 11 -- api/src/routes/rootRoutes.ts | 9 -- api/src/server.ts | 24 ---- api/src/services/globalService.ts | 173 ------------------------ api/src/services/rootService.ts | 3 - api/src/utils/copyAssets.ts | 7 - api/src/validators/rootValidator.ts | 9 -- api/src/views/home.ejs | 69 ---------- api/tsconfig.json | 63 --------- api/degunewapi.txt => degunewapi.txt | 0 31 files changed, 862 deletions(-) delete mode 100755 api/.githooks/pre-push delete mode 100644 api/.gitignore delete mode 100644 api/.prettierrc delete mode 100644 api/README.md delete mode 100644 api/norkconfig.json delete mode 100644 api/package.json delete mode 100755 api/setup-repo.sh delete mode 100644 api/src/.env.example delete mode 100644 api/src/app.ts delete mode 100644 api/src/config/database.ts delete mode 100644 api/src/config/environment.ts delete mode 100644 api/src/config/sequelize.config.ts delete mode 100644 api/src/controllers/rootController.ts delete mode 100644 api/src/interfaces/globalInterface.ts delete mode 100644 api/src/middlewares/authMiddleware.ts delete mode 100644 api/src/middlewares/handleValidation.ts delete mode 100644 api/src/middlewares/index.ts delete mode 100644 api/src/middlewares/sayHiMiddleware.ts delete mode 100644 api/src/models/User.ts delete mode 100644 api/src/public/expressjs.png delete mode 100644 api/src/public/nodejs_logo.svg delete mode 100644 api/src/routes/index.ts delete mode 100644 api/src/routes/rootRoutes.ts delete mode 100644 api/src/server.ts delete mode 100644 api/src/services/globalService.ts delete mode 100644 api/src/services/rootService.ts delete mode 100644 api/src/utils/copyAssets.ts delete mode 100644 api/src/validators/rootValidator.ts delete mode 100644 api/src/views/home.ejs delete mode 100644 api/tsconfig.json rename api/degunewapi.txt => degunewapi.txt (100%) diff --git a/api/.githooks/pre-push b/api/.githooks/pre-push deleted file mode 100755 index d751255..0000000 --- a/api/.githooks/pre-push +++ /dev/null @@ -1,59 +0,0 @@ -#!/bin/bash - -# @link https://gist.github.com/mattscilipoti/8424018 -# -# Called by "git push" after it has checked the remote status, -# but before anything has been pushed. -# -# If this script exits with a non-zero status nothing will be pushed. -# -# Steps to install, from the root directory of your repo... -# 1. Copy the file into your repo at `.git/hooks/pre-push` -# 2. Set executable permissions, run `chmod +x .git/hooks/pre-push` -# 3. Or, use `rake hooks:pre_push` to install -# -# Try a push to master, you should get a message `*** [Policy] Never push code directly to...` -# -# The commands below will not be allowed... -# `git push origin master` -# `git push --force origin master` -# `git push --delete origin master` - - -protected_branch='master' - -policy="\n\n[Policy] Never push code directly to the "$protected_branch" branch! (Prevented with pre-push hook.)\n\n" - -current_branch=$(git symbolic-ref HEAD | sed -e 's,.*/\(.*\),\1,') - -push_command=$(ps -ocommand= -p $PPID) - -is_destructive='force|delete|\-f' - -will_remove_protected_branch=':'$protected_branch - -do_exit(){ - echo -e $policy - exit 1 -} - -if [[ $push_command =~ $is_destructive ]] && [ $current_branch = $protected_branch ]; then - do_exit -fi - -if [[ $push_command =~ $is_destructive ]] && [[ $push_command =~ $protected_branch ]]; then - do_exit -fi - -if [[ $push_command =~ $will_remove_protected_branch ]]; then - do_exit -fi - -# Prevent ALL pushes to protected_branch -if [[ $push_command =~ $protected_branch ]] || [ $current_branch = $protected_branch ]; then - do_exit -fi - -unset do_exit - -exit 0 diff --git a/api/.gitignore b/api/.gitignore deleted file mode 100644 index f1b60d3..0000000 --- a/api/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -node_modules/ -package-lock.json -*.env diff --git a/api/.prettierrc b/api/.prettierrc deleted file mode 100644 index d0dd41b..0000000 --- a/api/.prettierrc +++ /dev/null @@ -1,15 +0,0 @@ -{ - "tabWidth": 4, - "useTabs": true, - "singleQuote": true, - "semi": false, - "trailingComma": "none", - "jsxSingleQuote": true, - "jsxBracketSameLine": true, - "printWidth": 200, - "bracketSpacing": true, - "vueIndentScriptAndStyle": true, - "arrowParens": "always", - "bracketSameLine": false, - "endOfLine": "lf" -} diff --git a/api/README.md b/api/README.md deleted file mode 100644 index 420f4d2..0000000 --- a/api/README.md +++ /dev/null @@ -1 +0,0 @@ -# New Project diff --git a/api/norkconfig.json b/api/norkconfig.json deleted file mode 100644 index da26aa4..0000000 --- a/api/norkconfig.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "project_name": "deguapp-api", - "lang": "ts", - "author": "Filip Rojek", - "database": { - "db": "mysql", - "orm": "sequelize" - }, - "website": "http://filiprojek.cz", - "email": "filip@filiprojek.cz", - "version": "3.0.5" -} \ No newline at end of file diff --git a/api/package.json b/api/package.json deleted file mode 100644 index 7355e75..0000000 --- a/api/package.json +++ /dev/null @@ -1,73 +0,0 @@ -{ - "name": "deguapp-api", - "version": "1.0.0", - "description": "", - "main": "dist/server.js", - "private": "true", - "keywords": [], - "author": "Filip Rojek (http://filiprojek.cz)", - "repository": "github:username/repo", - "license": "ISC", - "scripts": { - "start": "node dist/server.js", - "start:dev": "nodemon src/server.ts", - "test": "jest", - "clean": "rimraf dist/*", - "copy-assets": "npx ts-node src/utils/copyAssets", - "tsc": "tsc -p .", - "build": "npm-run-all clean tsc copy-assets", - "format": "npx prettier --write ." - }, - "dependencies": { - "colors": "1.4.0", - "cookie-parser": "^1.4.5", - "cors": "^2.8.5", - "dotenv": "^8.2.0", - "ejs": "^3.1.6", - "express": "^4.17.1", - "express-validator": "^6.14.2", - "fs-extra": "^10.0.0", - "jsonwebtoken": "^8.5.1", - "mongoose": "^5.12.3", - "pg": "^8.7.1", - "pg-hstore": "^2.3.4", - "sequelize": "^6.15.0" - }, - "devDependencies": { - "@types/cookie-parser": "^1.4.2", - "@types/cors": "^2.8.10", - "@types/ejs": "^3.0.6", - "@types/express": "^4.17.11", - "@types/fs-extra": "^9.0.12", - "@types/jest": "^27.5.2", - "@types/jsonwebtoken": "^8.5.8", - "@types/mongoose": "^5.10.5", - "@types/morgan": "^1.9.2", - "@types/node": "^14.14.41", - "@types/shelljs": "^0.8.9", - "jest": "^27.0.6", - "npm-run-all": "^4.1.5", - "rimraf": "^3.0.2", - "shelljs": "^0.8.4", - "ts-jest": "^27.1.5", - "ts-node": "^10.8.1", - "typescript": "^4.2.4", - "morgan": "^1.10.0" - }, - "jest": { - "preset": "ts-jest", - "testEnvironment": "node" - }, - "nodemonConfig": { - "ignore": [ - "**/*.test.ts", - "**/*.spec.ts", - ".git", - "node_modules" - ], - "watch": [ - "src" - ], - "ext": "ts, js" - } -} \ No newline at end of file diff --git a/api/setup-repo.sh b/api/setup-repo.sh deleted file mode 100755 index 20ca20f..0000000 --- a/api/setup-repo.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash - -cp .githooks/* .git/hooks - -echo "hooks have been copied" \ No newline at end of file diff --git a/api/src/.env.example b/api/src/.env.example deleted file mode 100644 index 602b583..0000000 --- a/api/src/.env.example +++ /dev/null @@ -1,26 +0,0 @@ -# General -APP_PORT = 6060 -APP_HOSTNAME = 'localhost' -APP_HOST = 'http://localhost:8080' # frontend url - -# Timezone -TZ = 'Europe/Prague' - -CORS_WHITELIST = http://172.15.46.21:8080;http://192.168.0.1:8080 -JWT_SECRET = '' - -# MongoDB -DB_URI = 'mongodb://username:password@localhost:27017/database?authSource=admin' - -# PostgreSQL -DB_PORT = 5432 -DB_HOST = '127.0.0.1' -DB_USERNAME = '' -DB_PASSWORD = '' -DB_DATABASE = '' - -# SMTP -SMTP_HOST = '' -SMTP_USER = '' -SMTP_PASS = '' -SMTP_FROM = '' diff --git a/api/src/app.ts b/api/src/app.ts deleted file mode 100644 index bb3bc6a..0000000 --- a/api/src/app.ts +++ /dev/null @@ -1,42 +0,0 @@ -import express from 'express' -import morgan from 'morgan' -import path from 'path' -import cors from 'cors' -import cookieParser from 'cookie-parser' -import { router as routes } from './routes' -import { router as middlewares } from './middlewares' -import env from './config/environment' - -export let corsWhitelist: Array -if (env.CORS_WHITELIST != 'undefined') { - corsWhitelist = [...['http://localhost:8080', 'http://localhost:6040'], ...env.CORS_WHITELIST.split(';')] -} else { - corsWhitelist = ['http://localhost:8080', 'http://localhost:6040'] -} -const corsOptions = { - origin: function (origin: any, callback: any) { - if (!origin || corsWhitelist.indexOf(origin) !== -1) { - callback(null, true) - } else { - callback(new Error('Not allowed by CORS')) - } - }, - optionsSuccessStatus: 200, - credentials: true -} - -export const app = express() - -// Middlewares -app.use(middlewares) -app.set('view engine', 'ejs') -app.set('views', path.join(__dirname, 'views')) -app.use(cors(corsOptions)) -app.use(morgan('dev')) -app.use(express.urlencoded({ extended: true })) -app.use(express.json()) -app.use(express.static(path.join(__dirname, 'public'))) -app.use(cookieParser()) - -// Routes -app.use(routes) diff --git a/api/src/config/database.ts b/api/src/config/database.ts deleted file mode 100644 index da0e1cf..0000000 --- a/api/src/config/database.ts +++ /dev/null @@ -1,49 +0,0 @@ -import mongoose from 'mongoose' -import env from './environment' -import { Err, Succ } from '../services/globalService' -import db from './sequelize.config' - -// MongoDB -const dbURI: string = env.DB_URI -function connect() { - if (!env.NORK.database) { - new Err(500, 'no database is in norkcfg.json') - return false - } - - if (env.NORK.database.orm == 'mongoose') { - mongoose - .connect(dbURI, { - useNewUrlParser: true, - useUnifiedTopology: true, - useCreateIndex: true - }) - .then(() => { - new Succ(200, 'connected to db') - return true - }) - .catch((err: any) => { - new Err(500, err) - return false - }) - } - - if (env.NORK.database.orm == 'sequelize') { - db.sync() - .then(() => { - new Succ(200, 'connected to db') - return true - }) - .catch((err: any) => { - new Err(500, `Can't connect to db\n${err}`) - return false - }) - } - - if (env.NORK.database.db.length > 0) { - new Err(500, `unsupported database ${env.NORK.database.db}`) - return false - } -} - -export default connect diff --git a/api/src/config/environment.ts b/api/src/config/environment.ts deleted file mode 100644 index 11d65c4..0000000 --- a/api/src/config/environment.ts +++ /dev/null @@ -1,59 +0,0 @@ -import path from 'path' -import fs from 'fs-extra' -import { Err } from '../services/globalService' -import dotenv from 'dotenv' -const env_path = process.env.NODE_ENV ? `../.env.${process.env.NODE_ENV}` : '../.env' - -dotenv.config({ path: path.join(__dirname, env_path) }) -const norkcfg = fs.readJSONSync(path.join(__dirname, '../../norkconfig.json')) - -if (norkcfg.database) { - if (norkcfg.database.db == 'postgresql') { - if (!process.env.DB_PORT) { - process.env.DB_PORT = '5432' - } - if (!process.env.DB_HOST) { - process.env.DB_HOST = '127.0.0.1' - } - if (!process.env.DB_USERNAME || !process.env.DB_PASSWORD || !process.env.DB_DATABASE) { - new Err(500, 'missing DB parameters in .env file') - process.exit(1) - } - } -} - -if (!fs.existsSync(path.join(__dirname, env_path))) { - console.log('$env_path = ', env_path) - console.log('$__dirname = ', __dirname) - new Err(500, `.env file for ${process.env.NODE_ENV ? process.env.NODE_ENV : ''} environment does not exists`) - process.exit() -} - -if (process.env.JWT_SECRET === undefined || process.env.JWT_SECRET == '') { - new Err(500, 'JWT_SECRET is not set!') - process.exit() -} - -export default { - // General - APP_PORT: Number(process.env.APP_PORT), - APP_HOST: String(process.env.APP_HOST), - APP_HOSTNAME: process.env.APP_HOSTNAME !== undefined ? String(process.env.APP_HOSTNAME) : null, - CORS_WHITELIST: String(process.env.CORS_WHITELIST), - JWT_SECRET: String(process.env.JWT_SECRET), - // MongoDB - DB_URI: String(process.env.DB_URI), - // PostgreSQL - DB_PORT: Number(process.env.DB_PORT), - DB_HOST: String(process.env.DB_HOST), - DB_USERNAME: String(process.env.DB_USERNAME), - DB_PASSWORD: String(process.env.DB_PASSWORD), - DB_DATABASE: String(process.env.DB_DATABASE), - // Nork - NORK: norkcfg, - // SMTP - SMTP_HOST: String(process.env.SMTP_HOST), - SMTP_USER: String(process.env.SMTP_USER), - SMTP_PASS: String(process.env.SMTP_PASS), - SMTP_FROM: String(process.env.SMTP_FROM) -} diff --git a/api/src/config/sequelize.config.ts b/api/src/config/sequelize.config.ts deleted file mode 100644 index b2c05d9..0000000 --- a/api/src/config/sequelize.config.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { Sequelize } from 'sequelize' -import env from './environment' - -const db = new Sequelize(env.DB_DATABASE, env.DB_USERNAME, env.DB_PASSWORD, { - host: env.DB_HOST, - dialect: 'postgres', - logging: false -}) - -export default db diff --git a/api/src/controllers/rootController.ts b/api/src/controllers/rootController.ts deleted file mode 100644 index 1cad825..0000000 --- a/api/src/controllers/rootController.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { Request, Response } from 'express' - -export function root_get(req: Request, res: Response) { - res.render('home') - return true -} diff --git a/api/src/interfaces/globalInterface.ts b/api/src/interfaces/globalInterface.ts deleted file mode 100644 index 4f4e882..0000000 --- a/api/src/interfaces/globalInterface.ts +++ /dev/null @@ -1,4 +0,0 @@ -export interface ErrType { - code: number - message: string -} diff --git a/api/src/middlewares/authMiddleware.ts b/api/src/middlewares/authMiddleware.ts deleted file mode 100644 index f4d0275..0000000 --- a/api/src/middlewares/authMiddleware.ts +++ /dev/null @@ -1,63 +0,0 @@ -import { Request, Response, NextFunction } from 'express' -import jwt from 'jsonwebtoken' -import env from '../config/environment' -import { Err, Succ } from '../services/globalService' -import User from '../models/User' // uncomment this - -export function requireAuth(req: Request, res: Response, next: NextFunction) { - const token = req.cookies.jwt - new Err(500, 'uncomment code in authMiddleware before using!') - if (token) { - jwt.verify(token, env.JWT_SECRET, async (err: any, decodedToken: any) => { - if (err) { - // console.error(err.message) - res.status(401).json(new Err(401, 'user is not authenticated')) - } - if (!err) { - const user = (async () => { - if (env.NORK.db.orm) { - if (env.NORK.db.orm == 'sequelize') { - return await User.findByPk(decodedToken.id) - } - if (env.NORK.db.orm == 'mongoose') { - return await User.findById(decodedToken.id) - } - } else { - return null - } - })() - - if (user === null) { - res.status(401).json(new Err(401, 'user is not authenticated')) - return - } - - res.locals.user = user - new Succ(100, 'user is authenticated') - next() - } - }) - } - - if (!token) { - res.status(401).json(new Err(401, 'user is not authenticated')) - } -} - -export function requireVerified(req: Request, res: Response, next: NextFunction) { - if (res.locals.user._id) { - if (res.locals.user.verified) { - new Succ(100, 'user is verified') - next() - return - } - - res.status(403).json(new Err(403, 'user is not verified')) - return - } - - if (!res.locals.user._id) { - res.status(401).json(new Err(401, 'user is not authenticated')) - return - } -} diff --git a/api/src/middlewares/handleValidation.ts b/api/src/middlewares/handleValidation.ts deleted file mode 100644 index 43c5ef8..0000000 --- a/api/src/middlewares/handleValidation.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { Request, Response, NextFunction } from 'express' -import { validationResult } from 'express-validator' -import { Err } from '../services/globalService' - -class Middleware { - handleValidationError(req: Request, res: Response, next: NextFunction) { - const error = validationResult(req) - if (!error.isEmpty()) { - new Err(400, error) - return res.status(400).json(new Err(400, 'validation error', error.array()[0])) - } - next() - } -} - -export default new Middleware() diff --git a/api/src/middlewares/index.ts b/api/src/middlewares/index.ts deleted file mode 100644 index ded99aa..0000000 --- a/api/src/middlewares/index.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { Router } from 'express' -import { router as sayHiMiddleware } from '../middlewares/sayHiMiddleware' - -export const router = Router() - -// router.use(sayHiMiddleware) diff --git a/api/src/middlewares/sayHiMiddleware.ts b/api/src/middlewares/sayHiMiddleware.ts deleted file mode 100644 index bc3a6e1..0000000 --- a/api/src/middlewares/sayHiMiddleware.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { Router, Request, Response, NextFunction } from 'express' - -export const router = Router() - -router.use((req: Request, res: Response, next: NextFunction) => { - console.log('Hi :)') - - next() -}) diff --git a/api/src/models/User.ts b/api/src/models/User.ts deleted file mode 100644 index 49b8051..0000000 --- a/api/src/models/User.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { DataTypes, Model } from 'sequelize' -import path from 'path' -import db from '../config/sequelize.config.ts' - -class Instance extends Model {} - -Instance.init( - { - _id: { - type: DataTypes.UUID, - primaryKey: true, - allowNull: false, - unique: true, - }, - username: { - type: DataTypes.STRING, - allowNull: false, - }, - password: { - type: DataTypes.STRING, - allowNull: false, - }, - email: { - type: DataTypes.STRING, - allowNull: false, - unique: true, - }, - }, - { - sequelize: db, - tableName: path.basename(__filename).split('.')[0].toLowerCase(), - }, -) - -export default Instance diff --git a/api/src/public/expressjs.png b/api/src/public/expressjs.png deleted file mode 100644 index 487c5a83af37b9b93507a08a761c0788c764b169..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 5032 zcmbtXXEYp8lpdlaYJ!kNM5JhwFnSk#)X^DYL>WEW7+tg|(Su-&(Ty5JNrY(8joy1_ zm?+UZS^IN;?4I4T@0|C(ci(;AJKsI8og1MA0aH^vq5uE@)GEpfIsgFC&`m$)_N|+C zf&E+j4UpK#YRCcr6>*f8=A<|FQ%hwX4FJFq1pv6k0szx$06@qR0N}R+08HMv`NaSL z79Qlc>bC#@@rIVVp5niM|Mm|KF0Zcs?(Xd$9G;z@-{8^F@%j11_Re4Y24Q7w{owGZ zXJGj3?5uBSw7Yk3X=QD8e(C!98rL^?a(X&CF}1L?@@I2~?_>JR}lljHvi;Ih~ z$(e!Sv5h~Qxc;H7oxi;U!<*YX!()?k3rm|@+kJy06Vr1$e|HI+TZ1FxH;QNG7yF0D z)(L+KN-KjR;@^7&7+SoS(=?V)){})8>zmozx%qtvi;YjsEGnyR@9s^)@Miz4Dt?*8G@YKESHpF*M&TRVHAzodQpUYC-Qr>tkDZDQje9`_|JyRoIC z;dgssS=EikpAElblQ2p;rZx4=&23$I#osiIt+Y(6y@DdbS&C2)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YW!aRSp6K|O6oB39rANU=FYWwz( zwlkuV!!G3uvknuKO@Rx=xft*s`~%lb(`7&(`>U`!brhqy zxu$D^sb^=~WDLSgxeV&u38_kJIUH;%RSTof%o1xk_vN=OgbP>+byvhi1+%o_jXuX) zg(70^ylv3@f!Ca}Rm>Q7tXT`4RzK*V^SZ=oA*XC_^vY3>Ii2d21Hm02VgWn9)_FA%zfwdw zLjP0NTfKF$a1C?&JMgn#??J(__-+jdYpZKvmA!;wg5&C;ddG|DpqKD;6k;r&b&J>9WAMEf{hHN*S{p{Lo)}ln_ zsBL%+y!o;VB4RM6M%u4cV`+^THHJWriSOebwJ%CKPDC30=O4-19I&)I2}1?`)Wo0KN`@8Iuajk}8?*CP(Yy8mFzwIfMz-Mm7 z_&x-pf<@?bDmdIDg*Y=j!XPrg$6%k3+&6e_ZG`NkZeI=M{eHnsvLnNG;ry(ZO!{l_ zf}Z~?91)$)KuLLfbCZ*3pmf+dl-`~A zqvfM|K0nQ}%H4gtl`)duSOh)~-&Klx=e8-p3oL#+m!oDJ*5{=IKX(7pT#ygDTmyWz{l#4z4E=>u*Q zZ$X}L$agW72wxt42zzDOAt{^rHo3FI#Mfla*>%nZ!cL##+Zg^YO1z zmH#n|O?b5UFFLUaC1}8Ybdz_#L@Gj&aC4-UxFy2s1_1mZK9ScT!Pop^dLVvrkg&J_ p|7(zlI0)3Nd(QY@2#(HhJ8SR%o=`y}SA0VNs3<}d%H+&~{{wT0#Ss7i diff --git a/api/src/public/nodejs_logo.svg b/api/src/public/nodejs_logo.svg deleted file mode 100644 index 41d044a..0000000 --- a/api/src/public/nodejs_logo.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/api/src/routes/index.ts b/api/src/routes/index.ts deleted file mode 100644 index fec3481..0000000 --- a/api/src/routes/index.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { Request, Response, Router } from 'express' -import { router as rootRoutes } from './rootRoutes' - -export const router = Router() - -router.use(rootRoutes) - -// 404 -router.use((req: Request, res: Response) => { - res.status(404).send('E404') -}) diff --git a/api/src/routes/rootRoutes.ts b/api/src/routes/rootRoutes.ts deleted file mode 100644 index e13cea1..0000000 --- a/api/src/routes/rootRoutes.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { Router } from 'express' -import * as rootController from '../controllers/rootController' -import rootValidator from '../validators/rootValidator' -import handleValidation from '../middlewares/handleValidation' - -export const router = Router() -const mws = [handleValidation.handleValidationError] - -router.get('/', rootValidator.checkRootGet(), mws, rootController.root_get) diff --git a/api/src/server.ts b/api/src/server.ts deleted file mode 100644 index 0128b12..0000000 --- a/api/src/server.ts +++ /dev/null @@ -1,24 +0,0 @@ -import http from 'http' -import { app } from './app' -import env from './config/environment' -import { Succ } from './services/globalService' -import database from './config/database' -const port: number = env.APP_PORT || 8080 -const hostname: string = env.APP_HOSTNAME || 'localhost' -export const server = http.createServer(app) - -// Server -export function runServer(): void { - server.listen(port, hostname, () => { - new Succ(200, `Server is listening on http://${hostname}:${port}`) - }) -} - -if (!env.NORK.database) { - runServer() -} else { - const db_connection = database() - if (db_connection) { - runServer() - } -} diff --git a/api/src/services/globalService.ts b/api/src/services/globalService.ts deleted file mode 100644 index 78e579e..0000000 --- a/api/src/services/globalService.ts +++ /dev/null @@ -1,173 +0,0 @@ -import colors from 'colors' -import fs from 'fs' -import path from 'path' - -export interface ErrType { - code: number - message: string - data?: any -} - -export class Err implements ErrType { - code: number - message: string - data: any - - constructor(code: number, message: string | object, data: any = null) { - this.code = code - typeof message === 'object' ? (this.message = JSON.stringify(message)) : (this.message = message) - data ? (this.data = data) : false - // typeof data === 'object' ? (this.data = JSON.stringify(data)) : (this.data = data) - - this.drop() - } - - drop() { - if (this.data) { - console.log(colors.bgRed(`${this.code}`) + colors.bgBlack.red(` ${this.message}`) + this.data) - Log.make('Err', this.code, this.message, this.data) - return { - code: this.code, - message: this.message, - data: this.data - } - } - - console.log(colors.bgRed(`${this.code}`) + colors.bgBlack.red(` ${this.message}`)) - Log.make('Err', this.code, this.message) - return { - code: this.code, - message: this.message - } - } -} - -export class Succ { - code: number - message: string - data?: any - - constructor(code: number, message: string, data: any = null) { - this.code = code - this.message = message - data ? (this.data = data) : false - this.drop() - } - - drop() { - if (this.data) { - console.log(colors.bgGreen.black(`${this.code}`) + colors.green.bgBlack(` ${this.message}`) + this.data) - return { - code: this.code, - message: this.message, - data: this.data - } - } - - console.log(colors.bgGreen.black(`${this.code}`) + colors.green.bgBlack(` ${this.message}`)) - return { - code: this.code, - message: this.message - } - } -} - -export interface LogType { - type: 'Err' | 'Succ' | 'Info' - code?: number - message?: string - data?: any - logFile?: string -} -export class Log implements LogType { - type: 'Err' | 'Succ' | 'Info' - code?: number - message?: string - data?: any - logFile?: string - - /** - * @param type - * - Type of log - * - Err | Succ | Info - * @param code - * - not required - * - HTTP status code - * @param message - * - could be anything - * @param data - * - could be anything - * @param logFile - * - name of logFile - * - default is log type file - */ - constructor(type: 'Err' | 'Succ' | 'Info', code?: number, message?: string, data?: any, logFile?: string) { - this.type = type - this.code = code - this.message = message - this.data = data - this.logFile = logFile - - if (!this.logFile) { - this.logFile = `${type}.global.log` - } else { - this.logFile = this.logFile + '.log' - } - - this.logFile = path.join(__dirname, this.logFile) - } - - static pathMake(type: string, name?: string) { - let logName - if (!name) { - logName = `${type}.global.log` - } else { - logName = name + '.log' - } - - return path.join(__dirname, '../logs/' + logName) - } - - /** - * returns current date in my custom format - */ - static dateNow(): string { - /** - * @param num: number - * - * receives number and returns two digits number - * example: - * input num = 9 => returns string 09 - */ - function add0(num: number): string { - if (num.toString().length <= 1) { - return '0' + String(num) - } - return String(num) - } - - const d = new Date() - return `${d.getFullYear()}-${add0(d.getMonth() + 1)}-${add0(d.getDate())} ${add0(d.getHours())}:${add0(d.getMinutes())}:${add0(d.getSeconds())}` - } - - static make(type: 'Err' | 'Succ' | 'Info', code?: number, message?: string, data?: any, logFile?: string) { - let realPath = Log.pathMake(type, logFile) - let formattedData = `Date: "${Log.dateNow()}" Type: "${type}"` - - code ? (formattedData += ` Code: "${code}"`) : false - message ? (formattedData += ` Message: "${message}"`) : false - if (data) { - if (typeof data === 'object') { - data = JSON.stringify(data) - } - formattedData += ` Data: "${data}"` - } - formattedData += '\n' - - if (fs.existsSync(realPath)) { - fs.appendFileSync(realPath, formattedData) - } else { - fs.writeFileSync(realPath, formattedData) - } - } -} diff --git a/api/src/services/rootService.ts b/api/src/services/rootService.ts deleted file mode 100644 index 75ca5d8..0000000 --- a/api/src/services/rootService.ts +++ /dev/null @@ -1,3 +0,0 @@ -export const helloWorld = () => { - console.log('hello world') -} diff --git a/api/src/utils/copyAssets.ts b/api/src/utils/copyAssets.ts deleted file mode 100644 index 658c4c5..0000000 --- a/api/src/utils/copyAssets.ts +++ /dev/null @@ -1,7 +0,0 @@ -import * as shell from 'shelljs' - -// Copy all the view templates -shell.cp('-R', 'src/views', 'dist/') -shell.cp('-R', 'src/public', 'dist/') -shell.cp('-R', 'src/models', 'dist/') -shell.cp('-u', 'src/.env', 'dist/') diff --git a/api/src/validators/rootValidator.ts b/api/src/validators/rootValidator.ts deleted file mode 100644 index 7b1acbb..0000000 --- a/api/src/validators/rootValidator.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { body, param, query } from 'express-validator' - -class rootValidator { - checkRootGet() { - return [] - } -} - -export default new rootValidator() diff --git a/api/src/views/home.ejs b/api/src/views/home.ejs deleted file mode 100644 index d841985..0000000 --- a/api/src/views/home.ejs +++ /dev/null @@ -1,69 +0,0 @@ - - - - - - - New Project - - - - - - -
-
-

Let's make something amazing!

-
- node.js logo - express.js logo -
-
- -
- - \ No newline at end of file diff --git a/api/tsconfig.json b/api/tsconfig.json deleted file mode 100644 index a6f9e39..0000000 --- a/api/tsconfig.json +++ /dev/null @@ -1,63 +0,0 @@ -{ - "compilerOptions": { - /* Visit https://aka.ms/tsconfig.json to read more about this file */ - - /* Basic Options */ - // "incremental": true, /* Enable incremental compilation */ - "target": "es6", - - /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */ - "module": "commonjs", - - /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */ - // "lib": [], /* Specify library files to be included in the compilation. */ - // "allowJs": true, /* Allow javascript files to be compiled. */ - // "checkJs": true, /* Report errors in .js files. */ - // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', 'react', 'react-jsx' or 'react-jsxdev'. */ - // "declaration": true, /* Generates corresponding '.d.ts' file. */ - // "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */ - // "sourceMap": true, /* Generates corresponding '.map' file. */ - // "outFile": "./", /* Concatenate and emit output to single file. */ - "outDir": "./dist", - - /* Redirect output structure to the directory. */ - "rootDir": "./src", - /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ - // "composite": true, /* Enable project compilation */ - // "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */ - // "removeComments": true, /* Do not emit comments to output. */ - // "noEmit": true, /* Do not emit outputs. */ - // "importHelpers": true, /* Import emit helpers from 'tslib'. */ - // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */ - // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */ - - /* Strict Type-Checking Options */ - "strict": true, - /* Enable all strict type-checking options. */ - // "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ - // "strictNullChecks": true, /* Enable strict null checks. */ - // "strictFunctionTypes": true, /* Enable strict checking of function types. */ - // "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */ - // "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */ - // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */ - // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */ - - "baseUrl": "./", - "esModuleInterop": true, - /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */ - "resolveJsonModule": true, - // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ - // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ - /* Experimental Options */ - "experimentalDecorators": true, - /* Enables experimental support for ES7 decorators. */ - "emitDecoratorMetadata": true, - /* Enables experimental support for emitting type metadata for decorators. */ - /* Advanced Options */ - "skipLibCheck": true, - /* Skip type checking of declaration files. */ - "forceConsistentCasingInFileNames": true - /* Disallow inconsistently-cased references to the same file. */ - }, - "exclude": ["src/tests"] -} diff --git a/api/degunewapi.txt b/degunewapi.txt similarity index 100% rename from api/degunewapi.txt rename to degunewapi.txt