From 973c567f177b28d4544b7a78576e1ee7a1edf5a5 Mon Sep 17 00:00:00 2001 From: Eghizio Date: Thu, 16 Sep 2021 08:39:44 +0200 Subject: [PATCH] Added dotenv --- .env.example | 1 + .gitignore | 3 ++- package-lock.json | 6 ++++++ package.json | 1 + src/index.ts | 2 ++ src/middlewares/cache.ts | 3 ++- 6 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 .env.example diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..2f304be --- /dev/null +++ b/.env.example @@ -0,0 +1 @@ +PORT="" \ No newline at end of file diff --git a/.gitignore b/.gitignore index b512c09..1dcef2d 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -node_modules \ No newline at end of file +node_modules +.env \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 9850567..8af0a09 100644 --- a/package-lock.json +++ b/package-lock.json @@ -670,6 +670,12 @@ "is-obj": "^1.0.0" } }, + "dotenv": { + "version": "10.0.0", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-10.0.0.tgz", + "integrity": "sha512-rlBi9d8jpv9Sf1klPjNfFAuWDjKLwTIJJ/VxtoTwIR6hnZxcEOQCZg2oIL3MWBYw5GpUDKOEnND7LXTbIpQ03Q==", + "dev": true + }, "duplexer3": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/duplexer3/-/duplexer3-0.1.4.tgz", diff --git a/package.json b/package.json index 2b35180..03e8ddf 100644 --- a/package.json +++ b/package.json @@ -26,6 +26,7 @@ "@types/express": "^4.17.6", "@types/node": "^13.13.5", "@types/xml2js": "^0.4.5", + "dotenv": "^10.0.0", "nodemon": "^1.19.3", "ts-node": "^8.10.1", "ts-node-dev": "^1.1.8", diff --git a/src/index.ts b/src/index.ts index 0a85bd7..56baffc 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,3 +1,5 @@ +import dotenv from "dotenv"; +dotenv.config(); // need to add dev/prod and logger import { createServer } from "./server"; diff --git a/src/middlewares/cache.ts b/src/middlewares/cache.ts index 807c828..9acefed 100644 --- a/src/middlewares/cache.ts +++ b/src/middlewares/cache.ts @@ -20,4 +20,5 @@ export const cache = (ttl: number = 0): RequestHandler => { next(); }; -}; \ No newline at end of file +}; +// need to disable caching when error, or should i? \ No newline at end of file