Skip to content

Commit 8ac7e95

Browse files
committed
done with all chapters
1 parent 331b191 commit 8ac7e95

File tree

114 files changed

+40393
-2326
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

114 files changed

+40393
-2326
lines changed

book/4-end/server/utils/slugify.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const _ = require('lodash');
22

33
// https://devdocs.io/lodash~4/index#kebabCase
44

5-
const slugify = text => _.kebabCase(text);
5+
const slugify = (text) => _.kebabCase(text);
66

77
async function createUniqueSlug(Model, slug, count) {
88
const user = await Model.findOne({ slug: `${slug}-${count}` }, 'id');

book/4-start/server/google.js

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,16 @@ function auth({ ROOT_URL, server }) {
2929
console.log(err); // eslint-disable-line
3030
}
3131
};
32-
passport.use(new Strategy(
33-
{
34-
clientID: process.env.Google_clientID,
35-
clientSecret: process.env.Google_clientSecret,
36-
callbackURL: `${ROOT_URL}/oauth2callback`,
37-
},
38-
verify,
39-
));
32+
passport.use(
33+
new Strategy(
34+
{
35+
clientID: process.env.Google_clientID,
36+
clientSecret: process.env.Google_clientSecret,
37+
callbackURL: `${ROOT_URL}/oauth2callback`,
38+
},
39+
verify,
40+
),
41+
);
4042

4143
passport.serializeUser((user, done) => {
4244
done(null, user.id);
@@ -51,10 +53,13 @@ function auth({ ROOT_URL, server }) {
5153
server.use(passport.initialize());
5254
server.use(passport.session());
5355

54-
server.get('/auth/google', passport.authenticate('google', {
55-
scope: ['profile', 'email'],
56-
prompt: 'select_account',
57-
}));
56+
server.get(
57+
'/auth/google',
58+
passport.authenticate('google', {
59+
scope: ['profile', 'email'],
60+
prompt: 'select_account',
61+
}),
62+
);
5863

5964
server.get(
6065
'/oauth2callback',

book/5-end/server/aws.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,3 @@ function sendEmail(options) {
4141
}
4242

4343
module.exports = sendEmail;
44-

book/5-end/server/google.js

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,16 @@ function auth({ ROOT_URL, server }) {
2929
console.log(err); // eslint-disable-line
3030
}
3131
};
32-
passport.use(new Strategy(
33-
{
34-
clientID: process.env.Google_clientID,
35-
clientSecret: process.env.Google_clientSecret,
36-
callbackURL: `${ROOT_URL}/oauth2callback`,
37-
},
38-
verify,
39-
));
32+
passport.use(
33+
new Strategy(
34+
{
35+
clientID: process.env.Google_clientID,
36+
clientSecret: process.env.Google_clientSecret,
37+
callbackURL: `${ROOT_URL}/oauth2callback`,
38+
},
39+
verify,
40+
),
41+
);
4042

4143
passport.serializeUser((user, done) => {
4244
done(null, user.id);
@@ -51,10 +53,13 @@ function auth({ ROOT_URL, server }) {
5153
server.use(passport.initialize());
5254
server.use(passport.session());
5355

54-
server.get('/auth/google', passport.authenticate('google', {
55-
scope: ['profile', 'email'],
56-
prompt: 'select_account',
57-
}));
56+
server.get(
57+
'/auth/google',
58+
passport.authenticate('google', {
59+
scope: ['profile', 'email'],
60+
prompt: 'select_account',
61+
}),
62+
);
5863

5964
server.get(
6065
'/oauth2callback',

book/5-end/server/models/Book.js

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
21
const mongoose = require('mongoose');
3-
const generateSlug = require ('../utils/slugify');
2+
const generateSlug = require('../utils/slugify');
43
const Chapter = require('./Chapter');
54

65
const { Schema } = mongoose;
@@ -31,7 +30,6 @@ const mongoSchema = new Schema({
3130
},
3231
});
3332

34-
3533
class BookClass {
3634
static async list({ offset = 0, limit = 10 } = {}) {
3735
const books = await this.find({})
@@ -49,9 +47,9 @@ class BookClass {
4947

5048
const book = bookDoc.toObject();
5149

52-
book.chapters = (await Chapter.find({ bookId: book._id }, 'title slug')
53-
.sort({ order: 1 }))
54-
.map(chapter => chapter.toObject());
50+
book.chapters = (await Chapter.find({ bookId: book._id }, 'title slug').sort({ order: 1 })).map(
51+
(chapter) => chapter.toObject(),
52+
);
5553
return book;
5654
}
5755

@@ -69,9 +67,7 @@ class BookClass {
6967
});
7068
}
7169

72-
static async edit({
73-
id, name, price, githubRepo,
74-
}) {
70+
static async edit({ id, name, price, githubRepo }) {
7571
const book = await this.findById(id, 'slug name');
7672

7773
if (!book) {

book/5-end/server/models/Chapter.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,4 +78,3 @@ mongoSchema.loadClass(ChapterClass);
7878
const Chapter = mongoose.model('Chapter', mongoSchema);
7979

8080
module.exports = Chapter;
81-

book/5-end/server/models/EmailTemplate.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,9 @@ function insertTemplates() {
4646
return;
4747
}
4848

49-
EmailTemplate
50-
.create(template)
51-
.catch((error) => {
52-
logger.error('EmailTemplate insertion error:', error);
53-
});
49+
EmailTemplate.create(template).catch((error) => {
50+
logger.error('EmailTemplate insertion error:', error);
51+
});
5452
});
5553
}
5654

book/5-end/server/models/User.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,7 @@ class UserClass {
5555
return ['id', 'displayName', 'email', 'avatarUrl', 'slug', 'isAdmin', 'isGithubConnected'];
5656
}
5757

58-
static async signInOrSignUp({
59-
googleId, email, googleToken, displayName, avatarUrl,
60-
}) {
58+
static async signInOrSignUp({ googleId, email, googleToken, displayName, avatarUrl }) {
6159
const user = await this.findOne({ googleId }).select(UserClass.publicFields().join(' '));
6260

6361
if (user) {

book/5-end/server/utils/slugify.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const _ = require('lodash');
22

33
// https://devdocs.io/lodash~4/index#kebabCase
44

5-
const slugify = text => _.kebabCase(text);
5+
const slugify = (text) => _.kebabCase(text);
66

77
async function createUniqueSlug(Model, slug, count) {
88
const user = await Model.findOne({ slug: `${slug}-${count}` }, 'id');

book/5-start/server/utils/slugify.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const _ = require('lodash');
22

33
// https://devdocs.io/lodash~4/index#kebabCase
44

5-
const slugify = text => _.kebabCase(text);
5+
const slugify = (text) => _.kebabCase(text);
66

77
async function createUniqueSlug(Model, slug, count) {
88
const user = await Model.findOne({ slug: `${slug}-${count}` }, 'id');

0 commit comments

Comments
 (0)