added some dev environment stuff
This commit is contained in:
10
app-dist/static/index.html
Normal file
10
app-dist/static/index.html
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>$Title$</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
$END$
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
6
server/package-lock.json
generated
6
server/package-lock.json
generated
@@ -23,6 +23,12 @@
|
|||||||
"@types/node": "*"
|
"@types/node": "*"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"@types/cors": {
|
||||||
|
"version": "2.8.10",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/cors/-/cors-2.8.10.tgz",
|
||||||
|
"integrity": "sha512-C7srjHiVG3Ey1nR6d511dtDkCEjxuN9W1HWAEjGq8kpcwmNM6JJkpC0xvabM7BXTG2wDq8Eu33iH9aQKa7IvLQ==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
"@types/dotenv": {
|
"@types/dotenv": {
|
||||||
"version": "8.2.0",
|
"version": "8.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/@types/dotenv/-/dotenv-8.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/@types/dotenv/-/dotenv-8.2.0.tgz",
|
||||||
|
|||||||
@@ -4,7 +4,8 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/node-fetch": "^2.5.8",
|
"@types/node-fetch": "^2.5.8",
|
||||||
"@types/dotenv": "^8.2.0",
|
"@types/dotenv": "^8.2.0",
|
||||||
"@types/express": "^4.17.11"
|
"@types/express": "^4.17.11",
|
||||||
|
"@types/cors": "^2.8.10"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "concurrently -n \"typescript,nodemon\" -c \"bgGreen.gray.bold,bgYellow.gray.bold\" \"tsc -w\" \"nodemon ../app-dist/server/main.js\""
|
"dev": "concurrently -n \"typescript,nodemon\" -c \"bgGreen.gray.bold,bgYellow.gray.bold\" \"tsc -w\" \"nodemon ../app-dist/server/main.js\""
|
||||||
|
|||||||
@@ -4,3 +4,4 @@ MYSQL_ADDRESS=192.168.0.198
|
|||||||
MYSQL_USERNAME=admin
|
MYSQL_USERNAME=admin
|
||||||
MYSQL_PW=sekna123jk
|
MYSQL_PW=sekna123jk
|
||||||
SENSOR_PING_INTERVAL=30
|
SENSOR_PING_INTERVAL=30
|
||||||
|
DEV=true
|
||||||
@@ -4,6 +4,7 @@ import {newMainRouter} from "./mainRouter";
|
|||||||
import {setupCollections} from "./Collections";
|
import {setupCollections} from "./Collections";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
import {startSensorPinger} from "./pingSensors";
|
import {startSensorPinger} from "./pingSensors";
|
||||||
|
import cors from "cors";
|
||||||
|
|
||||||
dotenv.config({ path: path.resolve(__dirname + "/.env") });
|
dotenv.config({ path: path.resolve(__dirname + "/.env") });
|
||||||
const SERVER_ROOT = process.env.SERVER_ROOT ?? "/";
|
const SERVER_ROOT = process.env.SERVER_ROOT ?? "/";
|
||||||
@@ -14,6 +15,11 @@ async function main() {
|
|||||||
const mainRouter = newMainRouter(collections);
|
const mainRouter = newMainRouter(collections);
|
||||||
const app = express();
|
const app = express();
|
||||||
app.use(express.json());
|
app.use(express.json());
|
||||||
|
if (process.env.DEV) {
|
||||||
|
app.use(cors({
|
||||||
|
origin: "http://192.168.0.181/"
|
||||||
|
}));
|
||||||
|
}
|
||||||
app.set("port", process.env.PORT || 3000);
|
app.set("port", process.env.PORT || 3000);
|
||||||
app.use(express.urlencoded({ extended: false}));
|
app.use(express.urlencoded({ extended: false}));
|
||||||
app.locals = {
|
app.locals = {
|
||||||
|
|||||||
Reference in New Issue
Block a user