Skip to content

Commit

Permalink
Merge pull request #267 from vinitkumar/develop
Browse files Browse the repository at this point in the history
Login fix
  • Loading branch information
vinitkumar authored Nov 28, 2019
2 parents 8e867a4 + c41337e commit 2bf4600
Show file tree
Hide file tree
Showing 8 changed files with 83 additions and 69 deletions.
10 changes: 10 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Example of Environment Variables

NODE_ENV=development
GITHUB_CLIENT_SECRET="your_github_client_secret"
SECRET="your_secret"
GITHUB_CLIENT_ID="your_github_client_id"
DB="mongodb://localhost/ntwitter"
# Use this when run via Docker
# DB="mongodb://mongodb/ntwitter"
PORT=3000
13 changes: 13 additions & 0 deletions .github/workflows/greetings.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Greetings

on: [pull_request, issues]

jobs:
greeting:
runs-on: ubuntu-latest
steps:
- uses: actions/first-interaction@v1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
issue-message: 'Hi! Thanks for taking the time. Please fill up the issue in as much detail as possible'' first issue'
pr-message: 'Thanks for making a contribution to the project. One of the maintainers will look into it and get back to you as soon as possible'' first pr'
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ npm-debug.log
.idea
.DS_Store
.sass-cache
data/*
.env
data/*
2 changes: 0 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ WORKDIR /usr/src/app
# Install app dependencies
COPY package*.json ./
RUN npm install
ENV SECRET='abadjadjadja1223232412424'
ENV DEVELOPMEN_DB = 'mongodb://mongodb:27017/ntwitter'
# Copy app source code
COPY . .
#Expose port and start application
Expand Down
33 changes: 18 additions & 15 deletions config/config.js
Original file line number Diff line number Diff line change
@@ -1,48 +1,51 @@
const path = require("path");
const rootPath = path.normalize(__dirname + "/..");
const DB = process.env.DB;
const clientID = process.env.GITHUB_CLIENT_ID;
const clientSecret = process.env.GITHUB_CLIENT_SECRET;
const DEVELOPMEN_DB = process.env.DEVELOPMEN_DB || 'mongodb://localhost:27017/ntwitter';

const envPath = process.env.ENVPATH || ".env";
const dotenv = require("dotenv");
// Path to the file where environment variables
dotenv.config({path: envPath });

module.exports = {
development: {
// Use different urls for running service with Docker and without Docker
db: DEVELOPMEN_DB,
//db: "mongodb://mongodb:27017/ntwitter",
//db: "mongodb://localhost:27017/ntwitter",
db: process.env.DB,
port: process.env.PORT,
root: rootPath,
app: {
name: "Node Twitter"
},
github: {
clientID: "e3930cf94c772ba10ef1",
clientSecret: "fb1284b1874444a9c0c55c963092f836596ecc56",
// GITHUB_CLIENT_SECRET and GITHUB_CLIENT_ID should be defined in .env file
// which is stored locally on your computer or those variables values
// can be passed from Docker container
clientSecret: process.env.GITHUB_CLIENT_SECRET,
clientID: process.env.GITHUB_CLIENT_ID,
callbackURL: "http://localhost:3000/auth/github/callback"
}
},
test: {
//db: process.env.DB,
// Hack to allow tests run
db: "mongodb://root:[email protected]:39078/ntwitter",
root: rootPath,
app: {
name: "Nodejs Express Mongoose Demo"
},
github: {
clientID: "c2e0f478634366e1289d",
clientSecret: "0bfde82383deeb99b28d0f6a9eac001a0deb798a",
clientSecret: process.env.GITHUB_CLIENT_SECRET,
clientID: process.env.GITHUB_CLIENT_ID,
callbackURL: "http://localhost:3000/auth/github/callback"
}
},
production: {
db: DB,
db: process.env.DB,
root: rootPath,
app: {
name: "Nodejs Express Mongoose Demo"
},
github: {
clientID: clientID,
clientSecret: clientSecret,
clientSecret: process.env.GITHUB_CLIENT_SECRET,
clientID: process.env.GITHUB_CLIENT_ID,
callbackURL: "http://nitter.herokuapp.com/auth/github/callback"
}
}
Expand Down
59 changes: 29 additions & 30 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"compression": "^1.7.1",
"connect-flash": "latest",
"connect-mongo": "latest",
"dotenv": "^8.2.0",
"cookie-parser": "^1.4.4",
"cookie-session": "^1.3.3",
"csurf": "^1.10.0",
Expand All @@ -31,7 +32,7 @@
"forever": "latest",
"method-override": "^2.3.10",
"moment": "^2.20.1",
"mongoose": "^5.7.5",
"mongoose": "^5.7.8",
"morgan": "^1.9.0",
"opencollective": "^1.0.3",
"passport": "^0.3.2",
Expand Down
29 changes: 9 additions & 20 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,26 +30,13 @@ sudo npm install -g sass
```

The configuration is in `config/config.js`. Please create your own
github application [Github Developer Settings](https://github.com/settings/applications) and replace the token and keys.

```js
var path = require('path'),
rootPath = path.normalize(__dirname + '/..');
module.exports = {
production: {
db: '',
root: rootPath,
app: {
name: 'Node Twitter'
},
github: {
clientID: '',
clientSecret: '',
callbackURL: ''
}
}
};
The configuration is in `config/config.js`. Please create your own `.env` file. You can find an example of `.env` file in `.env.example`.

Create a [github application](https://github.com/settings/apps) and copy cliend id and secret to .env file:

```
GITHUB_CLIENT_SECRET="your_github_client_secret"
GITHUB_CLIENT_ID="your_github_client_id"
```
## Usage via Docker

Expand All @@ -67,6 +54,8 @@ docker-compose up
```
Now, open the website on http://localhost:3000 and it should just work.

Before building Docker container change DB link to: `mongodb://mongodb/ntwitter` in `.env` file.


## Usage

Expand Down

0 comments on commit 2bf4600

Please sign in to comment.