Skip to content
This repository has been archived by the owner on Sep 26, 2019. It is now read-only.

Added env-template file to gateway. #46

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ terraform
lerna-debug.log
yarn-error.log
.eslintcache
.env
4 changes: 4 additions & 0 deletions apps/gateway/.env-template
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
PHOTO_GARDEN_PROVIDERS_GOOGLE_DRIVE_CLIENT_ID=
PHOTO_GARDEN_PROVIDERS_GOOGLE_DRIVE_CLIENT_SECRET=
PHOTO_GARDEN_PROVIDERS_GOOGLE_DRIVE_CLIENT_REDIRECT_URI=
PHOTO_GARDEN_PROVIDERS_DROPBOX_CLIENT_ID=
22 changes: 13 additions & 9 deletions apps/gateway/app.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
require("dotenv").config();
const providers = require("./providers");
const logger = require("logging");
const express = require("express");
Expand Down Expand Up @@ -25,8 +26,8 @@ app.use(
activeDuration: 10 * 60 * 1000,
cookie: {
secure: false
},
saveUninitialized: true,
},
saveUninitialized: true
})
);

Expand All @@ -47,26 +48,29 @@ app.get("/logout", (req, res) => {
});

app.get("/user", [isAuthenticated, allowCors], (req, res) => {
res.json({ user: req.gardenSession.userIdentity });
res.json({ user: req.gardenSession.userIdentity });
});

function allowCors(req, res, next) {
res.header("Access-Control-Allow-Origin", "http://localhost:3001");
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
res.header('Access-Control-Allow-Credentials', 'true');
res.header(
"Access-Control-Allow-Headers",
"Origin, X-Requested-With, Content-Type, Accept"
);
res.header("Access-Control-Allow-Credentials", "true");
return next();
}

function isAuthenticated(req, res, next) {
req.gardenSession.userIdentity = '7509d0e0-702b-4758-bd65-203ea38cf756';
req.gardenSession.userIdentity = "7509d0e0-702b-4758-bd65-203ea38cf756";
return next();
logger.info('SESSION IN GATEWAY', req.gardenSession)
logger.info("SESSION IN GATEWAY", req.gardenSession);
if (req.gardenSession.userIdentity) {
return next();
} else {
res.status(401).send('You are not logged in');
res.status(401).send("You are not logged in");
}
//
//
//res.redirect("http://localhost:3000/login");
}
// Mount providers
Expand Down
1 change: 1 addition & 0 deletions apps/gateway/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"client-sessions": "^0.8.0",
"communication": "^1.0.0",
"config": "^1.0.0",
"dotenv": "^6.0.0",
"dropbox-api": "^1.0.0",
"express": "^4.16.2",
"google-auth-library": "^0.12.0",
Expand Down
9 changes: 7 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,17 @@
"url": "https://github.com/Etimo/photo-garden/issues"
},
"homepage": "https://github.com/Etimo/photo-garden#readme",
"workspaces": ["apps/*", "libs/*"],
"workspaces": [
"apps/*",
"libs/*"
],
"scripts": {
"prettier": "prettier --write \"**/*.{js,json,css,md}\"",
"pm2": "docker exec -ti photogarden_services_1 pm2"
},
"pre-commit": ["prettier"],
"pre-commit": [
"prettier"
],
"dependencies": {},
"devDependencies": {
"eslint": "^4.19.1",
Expand Down
4 changes: 4 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2150,6 +2150,10 @@ dotenv@^5.0.0:
version "5.0.1"
resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-5.0.1.tgz#a5317459bd3d79ab88cff6e44057a6a3fbb1fcef"

dotenv@^6.0.0:
version "6.0.0"
resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-6.0.0.tgz#24e37c041741c5f4b25324958ebbc34bca965935"

duplexer2@~0.1.4:
version "0.1.4"
resolved "https://registry.yarnpkg.com/duplexer2/-/duplexer2-0.1.4.tgz#8b12dab878c0d69e3e7891051662a32fc6bddcc1"
Expand Down