Skip to content

Commit 2bf4600

Browse files
authored
Merge pull request #267 from vinitkumar/develop
Login fix
2 parents 8e867a4 + c41337e commit 2bf4600

File tree

8 files changed

+83
-69
lines changed

8 files changed

+83
-69
lines changed

.env.example

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Example of Environment Variables
2+
3+
NODE_ENV=development
4+
GITHUB_CLIENT_SECRET="your_github_client_secret"
5+
SECRET="your_secret"
6+
GITHUB_CLIENT_ID="your_github_client_id"
7+
DB="mongodb://localhost/ntwitter"
8+
# Use this when run via Docker
9+
# DB="mongodb://mongodb/ntwitter"
10+
PORT=3000

.github/workflows/greetings.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
name: Greetings
2+
3+
on: [pull_request, issues]
4+
5+
jobs:
6+
greeting:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/first-interaction@v1
10+
with:
11+
repo-token: ${{ secrets.GITHUB_TOKEN }}
12+
issue-message: 'Hi! Thanks for taking the time. Please fill up the issue in as much detail as possible'' first issue'
13+
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'

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ npm-debug.log
44
.idea
55
.DS_Store
66
.sass-cache
7-
data/*
7+
.env
8+
data/*

Dockerfile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ WORKDIR /usr/src/app
44
# Install app dependencies
55
COPY package*.json ./
66
RUN npm install
7-
ENV SECRET='abadjadjadja1223232412424'
8-
ENV DEVELOPMEN_DB = 'mongodb://mongodb:27017/ntwitter'
97
# Copy app source code
108
COPY . .
119
#Expose port and start application

config/config.js

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,51 @@
11
const path = require("path");
22
const rootPath = path.normalize(__dirname + "/..");
3-
const DB = process.env.DB;
4-
const clientID = process.env.GITHUB_CLIENT_ID;
5-
const clientSecret = process.env.GITHUB_CLIENT_SECRET;
6-
const DEVELOPMEN_DB = process.env.DEVELOPMEN_DB || 'mongodb://localhost:27017/ntwitter';
73

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

99
module.exports = {
1010
development: {
11-
// Use different urls for running service with Docker and without Docker
12-
db: DEVELOPMEN_DB,
13-
//db: "mongodb://mongodb:27017/ntwitter",
14-
//db: "mongodb://localhost:27017/ntwitter",
11+
db: process.env.DB,
12+
port: process.env.PORT,
1513
root: rootPath,
1614
app: {
1715
name: "Node Twitter"
1816
},
1917
github: {
20-
clientID: "e3930cf94c772ba10ef1",
21-
clientSecret: "fb1284b1874444a9c0c55c963092f836596ecc56",
18+
// GITHUB_CLIENT_SECRET and GITHUB_CLIENT_ID should be defined in .env file
19+
// which is stored locally on your computer or those variables values
20+
// can be passed from Docker container
21+
clientSecret: process.env.GITHUB_CLIENT_SECRET,
22+
clientID: process.env.GITHUB_CLIENT_ID,
2223
callbackURL: "http://localhost:3000/auth/github/callback"
2324
}
2425
},
2526
test: {
27+
//db: process.env.DB,
28+
// Hack to allow tests run
2629
db: "mongodb://root:[email protected]:39078/ntwitter",
2730
root: rootPath,
2831
app: {
2932
name: "Nodejs Express Mongoose Demo"
3033
},
3134
github: {
32-
clientID: "c2e0f478634366e1289d",
33-
clientSecret: "0bfde82383deeb99b28d0f6a9eac001a0deb798a",
35+
clientSecret: process.env.GITHUB_CLIENT_SECRET,
36+
clientID: process.env.GITHUB_CLIENT_ID,
3437
callbackURL: "http://localhost:3000/auth/github/callback"
3538
}
3639
},
3740
production: {
38-
db: DB,
41+
db: process.env.DB,
3942
root: rootPath,
4043
app: {
4144
name: "Nodejs Express Mongoose Demo"
4245
},
4346
github: {
44-
clientID: clientID,
45-
clientSecret: clientSecret,
47+
clientSecret: process.env.GITHUB_CLIENT_SECRET,
48+
clientID: process.env.GITHUB_CLIENT_ID,
4649
callbackURL: "http://nitter.herokuapp.com/auth/github/callback"
4750
}
4851
}

package-lock.json

Lines changed: 29 additions & 30 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"compression": "^1.7.1",
2222
"connect-flash": "latest",
2323
"connect-mongo": "latest",
24+
"dotenv": "^8.2.0",
2425
"cookie-parser": "^1.4.4",
2526
"cookie-session": "^1.3.3",
2627
"csurf": "^1.10.0",
@@ -31,7 +32,7 @@
3132
"forever": "latest",
3233
"method-override": "^2.3.10",
3334
"moment": "^2.20.1",
34-
"mongoose": "^5.7.5",
35+
"mongoose": "^5.7.8",
3536
"morgan": "^1.9.0",
3637
"opencollective": "^1.0.3",
3738
"passport": "^0.3.2",

readme.md

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -30,26 +30,13 @@ sudo npm install -g sass
3030
3131
```
3232

33-
The configuration is in `config/config.js`. Please create your own
34-
github application [Github Developer Settings](https://github.com/settings/applications) and replace the token and keys.
35-
36-
```js
37-
var path = require('path'),
38-
rootPath = path.normalize(__dirname + '/..');
39-
module.exports = {
40-
production: {
41-
db: '',
42-
root: rootPath,
43-
app: {
44-
name: 'Node Twitter'
45-
},
46-
github: {
47-
clientID: '',
48-
clientSecret: '',
49-
callbackURL: ''
50-
}
51-
}
52-
};
33+
The configuration is in `config/config.js`. Please create your own `.env` file. You can find an example of `.env` file in `.env.example`.
34+
35+
Create a [github application](https://github.com/settings/apps) and copy cliend id and secret to .env file:
36+
37+
```
38+
GITHUB_CLIENT_SECRET="your_github_client_secret"
39+
GITHUB_CLIENT_ID="your_github_client_id"
5340
```
5441
## Usage via Docker
5542

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

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

7160
## Usage
7261

0 commit comments

Comments
 (0)