diff --git a/.env b/.env new file mode 100644 index 0000000..57727ee --- /dev/null +++ b/.env @@ -0,0 +1 @@ +PORT=4000 \ No newline at end of file diff --git a/eslint.config.mjs b/eslint.config.mjs index 38a7956..f022ec7 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -2,17 +2,17 @@ import globals from "globals"; import pluginJs from "@eslint/js"; export default [ - { files: ["**/*.js"], languageOptions: { sourceType: "commonjs" } }, - { languageOptions: { globals: globals.browser } }, - pluginJs.configs.recommended, - { - rules: { - "prefer-const": "off", - "quotes": ["warn", "double", { "allowTemplateLiterals": true }], - "no-unused-vars": "warn", - "no-multi-spaces": "warn", - "no-multiple-empty-lines": ["warn", { "max": 1 }], - "no-case-declarations": "off" - } - } -]; \ No newline at end of file + { files: ["**/*.js"], languageOptions: { sourceType: "commonjs" } }, + { languageOptions: { globals: { ...globals.browser, ...globals.node } } }, + pluginJs.configs.recommended, + { + rules: { + "prefer-const": "off", + "no-unused-vars": "warn", + "no-multi-spaces": "warn", + "no-case-declarations": "off", + "no-multiple-empty-lines": ["warn", { max: 1 }], + quotes: ["warn", "double", { allowTemplateLiterals: true }], + }, + }, +]; diff --git a/package-lock.json b/package-lock.json index 1c419a5..3389d6e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,6 +9,7 @@ "version": "1.0.0", "license": "ISC", "dependencies": { + "dotenv": "^16.4.5", "express": "^4.19.2" }, "devDependencies": { @@ -601,6 +602,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", diff --git a/package.json b/package.json index 52bfc1f..089a339 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ "author": "", "license": "ISC", "dependencies": { + "dotenv": "^16.4.5", "express": "^4.19.2" }, "devDependencies": { diff --git a/src/app.js b/src/app.js index bdef7fb..714f1a6 100644 --- a/src/app.js +++ b/src/app.js @@ -1,9 +1,11 @@ +require("dotenv").config(); const express = require("express"); const app = express(); +const PORT = process.env.PORT app.use((req, res, next) => { res.send("Hello"); }); -app.listen(3000); +app.listen(PORT);