Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Udemy courses #13

Open
wants to merge 2 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
7,038 changes: 4,414 additions & 2,624 deletions client/package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
}
},
"dependencies": {
"axios": "^0.16.2",
"axios": "^0.20.0",
"materialize-css": "^0.100.2",
"react": "^16.0.0-alpha.13",
"react-dom": "^16.0.0-alpha.13",
Expand Down
1 change: 1 addition & 0 deletions client/src/actions/types.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export const FETCH_USER = 'fetch_user';
export const FETCH_BLOGS = 'fetch_blogs';
export const FETCH_BLOG = 'fetch_blog';
export const FETCH_TEAMS = 'fetch_teams';
2 changes: 2 additions & 0 deletions client/src/components/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import Landing from './Landing';
import Dashboard from './Dashboard';
import BlogNew from './blogs/BlogNew';
import BlogShow from './blogs/BlogShow';
import MyTeam from './MyTeam';

class App extends Component {
componentDidMount() {
Expand All @@ -24,6 +25,7 @@ class App extends Component {
<Route path="/blogs/new" component={BlogNew} />
<Route exact path="/blogs/:_id" component={BlogShow} />
<Route path="/blogs" component={Dashboard} />
<Route path="/teams" component={MyTeam} />
<Route path="/" component={Landing} />
</Switch>
</div>
Expand Down
3 changes: 3 additions & 0 deletions client/src/components/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ class Header extends Component {
);
default:
return [
<li key="1" style={{margin: '0 10px'}}>
<Link to="/teams">My Teams</Link>
</li>,
<li key="3" style={{ margin: '0 10px' }}>
<Link to="/blogs">My Blogs</Link>
</li>,
Expand Down
14 changes: 14 additions & 0 deletions client/src/components/MyTeam.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import React from 'react';

const MyTeam = () => {
return (
<div style={{ textAlign: 'center' }}>
<h1>
My Teams!
</h1>
Create your own team
</div>
);
};

export default MyTeam;
30 changes: 30 additions & 0 deletions client/tests/header.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
const puppeteer = require('puppeteer');
let browser, page;

beforeAll(async () => {
browser = await puppeteer.launch({
headless: false
});
page = await browser.newPage();
await page.goto('localhost:3000');
});

afterAll(async () => {
await browser.close();
});

test('the header has the correct text', async () => {

const text = await page.$eval('a.brand-logo', el => el.innerHTML);
expect(text).toEqual('Blogster');

});

test('clicking login start oauth flow', async() => {

await page.click('.right a');
const url = await page.url();
console.log(url);
expect(url).toMatch(/accounts\.google\.com/);

});
2 changes: 1 addition & 1 deletion config/dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ module.exports = {
googleClientID:
'70265989829-0t7m7ce5crs6scqd3t0t6g7pv83ncaii.apps.googleusercontent.com',
googleClientSecret: '8mkniDQOqacXtlRD3gA4n2az',
mongoURI: 'mongodb://readonly:password@ds063124.mlab.com:63124/blog_everyone',
mongoURI: 'mongodb://p00gz:wtkv66MEeOPLDV17@cluster0-shard-00-00.p8zfy.mongodb.net:27017,cluster0-shard-00-01.p8zfy.mongodb.net:27017,cluster0-shard-00-02.p8zfy.mongodb.net:27017/blogs_dev?ssl=true&replicaSet=atlas-63l7xl-shard-0&authSource=admin&retryWrites=true&w=majority',
cookieKey: '123123123',
};
3 changes: 3 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ const keys = require('./config/keys');

require('./models/User');
require('./models/Blog');
require('./models/Team');
require('./services/passport');
require('./services/cache');

mongoose.Promise = global.Promise;
mongoose.connect(keys.mongoURI, { useMongoClient: true });
Expand All @@ -26,6 +28,7 @@ app.use(passport.session());

require('./routes/authRoutes')(app);
require('./routes/blogRoutes')(app);
require('./routes/teamRoutes')(app);

if (['production'].includes(process.env.NODE_ENV)) {
app.use(express.static('client/build'));
Expand Down
7 changes: 7 additions & 0 deletions middlewares/cleanHash.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const { clearHash } = require('../services/cache');

module.exports = async (req, res, next) => {
await next();

clearHash(req.user.id);
}
12 changes: 12 additions & 0 deletions models/Team.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const mongoose = require('mongoose');
const { Schema } = mongoose;

const teamSchema = new Schema({
teamName: String,
coachName: String,
createdAt: {type: Date, default: Date.Now},
_user: {type: Schema.Types.ObjectId, ref: 'User'}

});

mongoose.model('Team', teamSchema);
Loading