Added nodemon scripts

This commit is contained in:
Alexis
2021-07-23 21:56:44 +02:00
parent a43b5a95c4
commit 681ff2b086
7 changed files with 1932 additions and 51 deletions

13
nodemon.json Normal file
View File

@@ -0,0 +1,13 @@
{
"ignore": [
"src/**/*.test.ts",
"src/**/*.spec.ts",
".git",
"node_modules"
],
"watch": [
"src"
],
"exec": "npm start",
"ext": "ts"
}

1926
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -5,9 +5,10 @@
"main": "./src/main.ts", "main": "./src/main.ts",
"private": true, "private": true,
"scripts": { "scripts": {
"dev": "ts-node ./src/main.ts", "dev": "nodemon",
"build": "tsc", "build": "tsc -p ./",
"start": "node ./dist/main.js" "start": "ts-node ./src/main.ts",
"start:prod": "node ./dist/main.js"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
@@ -40,19 +41,21 @@
"morgan": "^1.10.0", "morgan": "^1.10.0",
"mysql": "^2.18.1", "mysql": "^2.18.1",
"nodemailer": "^6.6.3", "nodemailer": "^6.6.3",
"uuid": "^8.3.2" "uuid": "^8.3.2",
"mariadb": "^2.5.4",
"sequelize": "^6.6.5"
}, },
"devDependencies": { "devDependencies": {
"@types/cors": "^2.8.12", "@types/cors": "^2.8.12",
"@types/express": "^4.17.13", "@types/express": "^4.17.13",
"@types/helmet": "^4.0.0", "@types/helmet": "^4.0.0",
"@types/morgan": "^1.9.3", "@types/morgan": "^1.9.3",
"@types/validator": "^13.6.3",
"babel-eslint": "^10.1.0", "babel-eslint": "^10.1.0",
"dotenv": "^8.6.0", "dotenv": "^8.6.0",
"eslint": "^7.31.0", "eslint": "^7.31.0",
"eslint-plugin-import": "^2.23.4", "eslint-plugin-import": "^2.23.4",
"mariadb": "^2.5.4", "nodemon": "^1.18.6",
"sequelize": "^6.6.5",
"ts-node": "^10.1.0", "ts-node": "^10.1.0",
"typescript": "^4.3.5" "typescript": "^4.3.5"
} }

View File

@@ -1,8 +1,10 @@
import { NextFunction, Response } from "express";
const regexInt = RegExp(/^[1-9]\d*$/); const regexInt = RegExp(/^[1-9]\d*$/);
const regexXSS = RegExp(/<[^>]*script/); const regexXSS = RegExp(/<[^>]*script/);
// Check if int for param validation // Check if int for param validation
const paramIntCheck = (req, res, next, input) => { const paramIntCheck = (req: Request, res: Response, next: NextFunction, input: any) => {
try { try {
if (regexInt.test(input)) { if (regexInt.test(input)) {
next(); next();
@@ -19,12 +21,12 @@ const paramIntCheck = (req, res, next, input) => {
}; };
// Check if script injection attempt // Check if script injection attempt
const isXSSAttempt = (string) => { const isXSSAttempt = (string: string) => {
return regexXSS.test(string); return regexXSS.test(string);
}; };
// Check if object is null // Check if object is null
const isEmptyObject = (obj) => { const isEmptyObject = (obj: Object) => {
return (Object.keys(obj).length === 0 && obj.constructor === Object); return (Object.keys(obj).length === 0 && obj.constructor === Object);
}; };
@@ -32,4 +34,4 @@ module.exports = {
paramIntCheck, paramIntCheck,
isXSSAttempt, isXSSAttempt,
isEmptyObject isEmptyObject
}; };

View File

@@ -3,12 +3,12 @@
*/ */
// .env Data // .env Data
import * as dotenv from 'dotenv'; import * as dotenv from 'dotenv'
dotenv.config(); dotenv.config();
// Packages // Packages
import morgan from 'morgan'; import morgan from 'morgan'
import helmet from 'helmet'; import helmet from 'helmet'
import express from 'express' import express from 'express'
import { AuracleApi } from './common/classes/AuracleApi' import { AuracleApi } from './common/classes/AuracleApi'

9
tsconfig.build.json Normal file
View File

@@ -0,0 +1,9 @@
{
"extends": "./tsconfig.json",
"exclude": [
"node_modules",
"test",
"dist",
"**/*spec.ts"
]
}

View File

@@ -11,7 +11,7 @@
"sourceMap": true, "sourceMap": true,
"outDir": "./dist", "outDir": "./dist",
"esModuleInterop": true, "esModuleInterop": true,
"baseUrl": "./", "baseUrl": "./src",
"incremental": true, "incremental": true,
"types": [ "types": [
"node", "node",
@@ -19,4 +19,4 @@
"sequelize" "sequelize"
], ],
} }
} }