diff --git a/.env.prod b/.env.prod new file mode 100644 index 0000000..e4ea1d2 --- /dev/null +++ b/.env.prod @@ -0,0 +1,7 @@ +NODE_ENV=prod +DB_HOST=localhost +DB_PORT=5432 +DB_USER=your_db_user +DB_NAME=your_db_name +DB_PASSWORD=your_db_password +JWT_SECRET_KEY=your_secret_key \ No newline at end of file diff --git a/.env.test b/.env.test new file mode 100644 index 0000000..d42db9e --- /dev/null +++ b/.env.test @@ -0,0 +1,7 @@ +NODE_ENV=test +DB_HOST=localhost +DB_PORT=5432 +DB_USER=your_db_user +DB_NAME=your_db_name +DB_PASSWORD=your_db_password +JWT_SECRET_KEY=your_secret_key \ No newline at end of file diff --git a/.gitignore b/.gitignore index 4781473..bc435e4 100644 --- a/.gitignore +++ b/.gitignore @@ -74,6 +74,7 @@ web_modules/ # dotenv environment variable files .env +.env.dev .env.development.local .env.test.local .env.production.local diff --git a/index.js b/index.js index 01f3874..1c367ef 100644 --- a/index.js +++ b/index.js @@ -13,7 +13,9 @@ const { swaggerUi, swaggerSpec } = require('./config/swagger'); // Import Swagge const metricsRoutes = require('./routes/metricsRoutes'); const { trackRequests } = require('./controllers/metricsController'); -dotenv.config(); +dotenv.config({ + path: `.env.${process.env.NODE_ENV || 'dev'}`, +}); const app = express(); const port = process.env.PORT || 3000; diff --git a/package-lock.json b/package-lock.json index 276741a..7fa20eb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6532,13 +6532,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/openapi-types": { - "version": "12.1.3", - "resolved": "https://registry.npmjs.org/openapi-types/-/openapi-types-12.1.3.tgz", - "integrity": "sha512-N4YtSYJqghVu4iek2ZUvcN/0aqH1kRDuNqzcycDxhOUpg7GdvLa2F3DgS6yBNhInhv2r/6I0Flkn7CqL8+nIcw==", - "license": "MIT", - "peer": true - }, "node_modules/p-limit": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", diff --git a/package.json b/package.json index d8c4e99..6718fb6 100644 --- a/package.json +++ b/package.json @@ -53,8 +53,8 @@ ] }, "scripts": { - "test": "DEBUG=module:* nyc mocha --require @babel/register", - "start": "node src/index.js", - "dev": "nodemon src/index.js" + "test": "NODE_ENV=prod DEBUG=module:* nyc mocha --require @babel/register", + "start": "NODE_ENV=prod node index.js", + "start:dev": "node index.js" } }