master
omidshj 2024-09-20 20:30:11 +03:30
parent 052c17ec8e
commit a24bb293ee
6 changed files with 30 additions and 2 deletions

2
.env.example Normal file
View File

@ -0,0 +1,2 @@
NODE="20.12"
PORT=3000

1
.gitignore vendored
View File

@ -1 +1,2 @@
node_modules
.env

View File

@ -1,6 +1,7 @@
// index.js
const express = require('express');
const app = express();
require('dotenv').config()
const cron = require('node-cron')
@ -13,6 +14,8 @@ app.listen(3000, () => {
console.log('Server is running on port 3000');
});
console.log('hhhh', process.env.FOO);
cron.schedule('* * * * *', () => {
fetchCalendar()

12
package-lock.json generated
View File

@ -9,6 +9,7 @@
"version": "1.0.0",
"license": "ISC",
"dependencies": {
"dotenv": "^16.4.5",
"express": "^4.21.0",
"mongodb": "^6.9.0",
"mysql": "^2.18.1",
@ -231,6 +232,17 @@
"npm": "1.2.8000 || >= 1.4.16"
}
},
"node_modules/dotenv": {
"version": "16.4.5",
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.4.5.tgz",
"integrity": "sha512-ZmdL2rui+eB2YwhsWzjInR8LldtZHGDoQ1ugH85ppHKwpUHL7j7rN0Ti9NCnGiQbhaZ11FpR+7ao1dNsmduNUg==",
"engines": {
"node": ">=12"
},
"funding": {
"url": "https://dotenvx.com"
}
},
"node_modules/ee-first": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz",

View File

@ -4,11 +4,13 @@
"description": "",
"main": "index.js",
"scripts": {
"index": "node ./index.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"dotenv": "^16.4.5",
"express": "^4.21.0",
"mongodb": "^6.9.0",
"mysql": "^2.18.1",

10
run.sh
View File

@ -1,2 +1,10 @@
#!/bin/bash
docker run -w /srv -v $(pwd):/srv -u $(id -u ${USER}):$(id -g ${USER}) -p 3000:3000 -it --rm node:20.8 bash
if [ ! -f ".env" ]; then
if [ -f ".env.example" ]; then
cp ".env.example" ".env"
fi
fi
source .env
docker run -w /srv -v $(pwd):/srv \
-u $(id -u ${USER}):$(id -g ${USER}) -p $PORT:3000 \
-it --rm node:$NODE npm --env-file=.env run index