Skip to content

Commit

Permalink
added github repo functionality to site -- tested
Browse files Browse the repository at this point in the history
  • Loading branch information
luckynumberke7in committed Oct 2, 2020
1 parent ab605a5 commit 567af06
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 55 deletions.
105 changes: 53 additions & 52 deletions MERN-social-app.sublime-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"file": "routes/api/profile.js",
"settings":
{
"buffer_size": 8319,
"buffer_size": 8336,
"encoding": "UTF-8",
"line_ending": "Windows"
}
Expand Down Expand Up @@ -126,22 +126,26 @@
"last_filter": "",
"selected_items":
[
[
"term",
"Terminus: Open Default Shell in Panel"
],
[
"git push",
"Git: Push Current Branch"
],
[
"git quick",
"quick",
"Git: Quick Commit (repo)"
],
[
"git add",
"Git: Add All"
],
[
"term",
"Terminus: Open Default Shell in Panel"
],
[
"git quick",
"Git: Quick Commit (repo)"
],
[
"git quic",
"Git: Quick Commit (repo)"
Expand All @@ -150,10 +154,6 @@
"git pus",
"Git: Push Current Branch"
],
[
"quick",
"Git: Quick Commit (repo)"
],
[
"git pu",
"Git: Push Current Branch"
Expand Down Expand Up @@ -364,7 +364,7 @@
],
"find":
{
"height": 28.0
"height": 27.0
},
"find_in_files":
{
Expand All @@ -378,6 +378,7 @@
"case_sensitive": false,
"find_history":
[
"newExp",
"location",
"company",
"school",
Expand Down Expand Up @@ -653,15 +654,15 @@
"semi_transient": false,
"settings":
{
"buffer_size": 8319,
"buffer_size": 8336,
"regions":
{
},
"selection":
[
[
8151,
8151
5730,
5730
]
],
"settings":
Expand All @@ -674,8 +675,8 @@
{
"1":
[
8200,
8201
5756,
5757
]
},
"icon":
Expand All @@ -690,8 +691,8 @@
{
"1":
[
7896,
7897
5598,
5599
]
},
"unmatched":
Expand All @@ -700,21 +701,6 @@
},
"bracket_highlighter.regions":
[
"bh_angle",
"bh_angle_center",
"bh_angle_open",
"bh_angle_close",
"bh_angle_content",
"bh_c_define",
"bh_c_define_center",
"bh_c_define_open",
"bh_c_define_close",
"bh_c_define_content",
"bh_single_quote",
"bh_single_quote_center",
"bh_single_quote_open",
"bh_single_quote_close",
"bh_single_quote_content",
"bh_default",
"bh_default_center",
"bh_default_open",
Expand All @@ -725,36 +711,51 @@
"bh_square_open",
"bh_square_close",
"bh_square_content",
"bh_round",
"bh_round_center",
"bh_round_open",
"bh_round_close",
"bh_round_content",
"bh_angle",
"bh_angle_center",
"bh_angle_open",
"bh_angle_close",
"bh_angle_content",
"bh_c_define",
"bh_c_define_center",
"bh_c_define_open",
"bh_c_define_close",
"bh_c_define_content",
"bh_regex",
"bh_regex_center",
"bh_regex_open",
"bh_regex_close",
"bh_regex_content",
"bh_curly",
"bh_curly_center",
"bh_curly_open",
"bh_curly_close",
"bh_curly_content",
"bh_single_quote",
"bh_single_quote_center",
"bh_single_quote_open",
"bh_single_quote_close",
"bh_single_quote_content",
"bh_double_quote",
"bh_double_quote_center",
"bh_double_quote_open",
"bh_double_quote_close",
"bh_double_quote_content",
"bh_curly",
"bh_curly_center",
"bh_curly_open",
"bh_curly_close",
"bh_curly_content",
"bh_tag",
"bh_tag_center",
"bh_tag_open",
"bh_tag_close",
"bh_tag_content",
"bh_unmatched",
"bh_unmatched_center",
"bh_unmatched_open",
"bh_unmatched_close",
"bh_unmatched_content",
"bh_tag",
"bh_tag_center",
"bh_tag_open",
"bh_tag_close",
"bh_tag_content"
"bh_round",
"bh_round_center",
"bh_round_open",
"bh_round_close",
"bh_round_content"
],
"color_scheme": "Packages/JavaScript Ultimate/themes/Tron.tmTheme",
"git_gutter_is_enabled": true,
Expand All @@ -764,7 +765,7 @@
"syntax": "Packages/JavaScript/JavaScript.sublime-syntax"
},
"translation.x": 0.0,
"translation.y": 6384.0,
"translation.y": 4368.8,
"zoom_level": 1.0
},
"stack_index": 0,
Expand Down Expand Up @@ -1253,7 +1254,7 @@
],
"incremental_find":
{
"height": 28.0
"height": 27.0
},
"input":
{
Expand Down Expand Up @@ -1322,7 +1323,7 @@
"project": "MERN-social-app.sublime-project",
"replace":
{
"height": 52.0
"height": 50.0
},
"save_all_on_build": true,
"select_file":
Expand Down Expand Up @@ -1367,7 +1368,7 @@
"show_minimap": true,
"show_open_files": false,
"show_tabs": true,
"side_bar_visible": false,
"side_bar_visible": true,
"side_bar_width": 138.0,
"status_bar_visible": true,
"template_settings":
Expand Down
6 changes: 4 additions & 2 deletions config/default.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
"mongoURI": "mongodb+srv://ke7in:[email protected]/<dbname>?retryWrites=true&w=majority",
"jwtSecret": "mysecrettoken"
}
"jwtSecret": "mysecrettoken",
"githubClientId": "542e872f9c5c3d3c7683",
"githubSecret": "380a761a0f4fae1a751decfc01035e3d7bcf3d64"
}
35 changes: 34 additions & 1 deletion routes/api/profile.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
const express = require('express');
const request = require('request');
const config = require('config');
const router = express.Router();
const auth = require('../../middleware/auth');
const { check, validationResult } = require('express-validator');
Expand Down Expand Up @@ -289,7 +291,7 @@ router.put(
return res.status(400).json({ errors: errors.array });
}

// receive new job
// receive new education
const {
school,
degree,
Expand Down Expand Up @@ -352,4 +354,35 @@ router.delete('/education/:edu_id', auth, async (req, res) => {
}
});

// @route GET api/profile/github/:username
// @description Get github repos for user
// @access Public

router.get('/github/:username', (req, res) => {
try {
const options = {
uri: `https://api.github.com/users/${
req.params.username
}/repos?per_page=5&sort=created:asc&client_id=${config.get(
'githubClientId'
)}&client_secret=${config.get('githubSecret')}`,
method: 'GET',
headers: { 'user-agent': 'node.js' },
};

request(options, (error, response, body) => {
if (error) console.error(error);

if (response.statusCode !== 200) {
return res.status(404).json({ msg: 'No Github profile found' });
}

res.json(JSON.parse(body));
});
} catch (err) {
console.error(err.message);
res.status(500).send('Server Error');
}
});

module.exports = router;

0 comments on commit 567af06

Please sign in to comment.