Skip to content

Commit f3009e5

Browse files
authored
Merge pull request #53 from gadhagod/main
Add formatter
2 parents 93862d7 + 5b2ca53 commit f3009e5

File tree

129 files changed

+25515
-14933
lines changed

Some content is hidden

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

129 files changed

+25515
-14933
lines changed

.prettierignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.min.*

README.md

+48-33
Large diffs are not rendered by default.

db.js

+24-14
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,35 @@
1-
const mongoose = require('mongoose');
2-
const config = require('./config.json');
1+
const mongoose = require("mongoose");
2+
const config = require("./config.json");
33

44
mongoose.Promise = global.Promise;
55

6-
mongoose.connect(`mongodb://${config.database.auth ? config.database.auth.username + ":"+config.database.auth.password + "@" : ""}localhost:${config.database.port}/${config.database.databaseName}`, {
7-
config: {
8-
autoIndex: false,
9-
},
10-
useNewUrlParser:true,
11-
useUnifiedTopology: true
12-
});
6+
mongoose.connect(
7+
`mongodb://${
8+
config.database.auth
9+
? config.database.auth.username +
10+
":" +
11+
config.database.auth.password +
12+
"@"
13+
: ""
14+
}localhost:${config.database.port}/${config.database.databaseName}`,
15+
{
16+
config: {
17+
autoIndex: false,
18+
},
19+
useNewUrlParser: true,
20+
useUnifiedTopology: true,
21+
}
22+
);
1323

1424
const db = mongoose.connection;
1525

16-
db.on('error', () => {
17-
console.error('MongoDB connection error');
18-
process.exit(1);
26+
db.on("error", () => {
27+
console.error("MongoDB connection error");
28+
process.exit(1);
1929
});
2030

21-
db.once('open', () => {
22-
console.log('Successfully connected to MongoDB');
31+
db.once("open", () => {
32+
console.log("Successfully connected to MongoDB");
2333
});
2434

2535
module.exports = mongoose;

docs/index.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# Home
22

3-
Welcome to Harker Robotics' software documentation! To get started, visit the [introduction](introduction/) page.
3+
Welcome to Harker Robotics' software documentation! To get started, visit the [introduction](introduction/) page.

docs/introduction/git.md

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,21 @@
11
# Git
22

3-
Git is a source control tool that we use to manage changes in our code. It allows us to map out the progress of our code over time, and also makes it easy to revert to a previous version if necessary. At its core, Git works not by storing the code but instead by tracking *commits*, which is a change in the code. Whenever make a major change or implement an important feature, we create a commit, which stores how the code was changed from the previous commit. To fetch the latest version, it runs through the previous commits and reconstructs the code. To speed things up, git creates checkpoints that reocrds the codebase at that commit, so it doesn't have to jump all the way back to the start.
3+
Git is a source control tool that we use to manage changes in our code. It allows us to map out the progress of our code over time, and also makes it easy to revert to a previous version if necessary. At its core, Git works not by storing the code but instead by tracking _commits_, which is a change in the code. Whenever make a major change or implement an important feature, we create a commit, which stores how the code was changed from the previous commit. To fetch the latest version, it runs through the previous commits and reconstructs the code. To speed things up, git creates checkpoints that reocrds the codebase at that commit, so it doesn't have to jump all the way back to the start.
44

5-
To store our code online we use GitHub. GitHub stores Git projects online, and is referred to as a *remote*, a server where your project is stored (think of Git as email, while GitHub is Gmail).
5+
To store our code online we use GitHub. GitHub stores Git projects online, and is referred to as a _remote_, a server where your project is stored (think of Git as email, while GitHub is Gmail).
66

77
### Tutorials
88

9-
There are tons of Git tutorials online that are really great. To learn the basics, go to <https://backlog.com/git-tutorial/what-is-git/> and complete the **Learn Git Basics** section (except the *Rewriting History* lesson, that is very bad practice) and the **Learn Git Collboration** section, stopping after you complete the *Branching Workflows* lesson. Keep in mind that the sample workflow in that lesson is typical in larger scopes, our team normally onlt uses two branches, dev and master.
9+
There are tons of Git tutorials online that are really great. To learn the basics, go to <https://backlog.com/git-tutorial/what-is-git/> and complete the **Learn Git Basics** section (except the _Rewriting History_ lesson, that is very bad practice) and the **Learn Git Collboration** section, stopping after you complete the _Branching Workflows_ lesson. Keep in mind that the sample workflow in that lesson is typical in larger scopes, our team normally onlt uses two branches, dev and master.
1010

1111
Git is very complex and it can be difficult to remember all the commands. Our team has a cheatsheet available at <https://robotics.harker.org/github> that contains all the commands you should need in robotics that you can consult if you forget something.
1212

1313
### Commit Messages
1414

15-
Commit messages summarize a group of changes into a sentence, so writing them well makes the development process much easier. Our team has a standard format for commit messages: they should start with a capitalized, present tense verb. A valid commit message forms a sentence if you put "This commit will ..." before it (ignoring capitalization).
15+
Commit messages summarize a group of changes into a sentence, so writing them well makes the development process much easier. Our team has a standard format for commit messages: they should start with a capitalized, present tense verb. A valid commit message forms a sentence if you put "This commit will ..." before it (ignoring capitalization).
1616

1717
> This commit will **Begin tuning auton paths**.
1818
19-
Multiple phrases should be separated by a comma (without *and*), which does break this structure, but the individual parts should still follow it. Here is a sample set of commits from our 2020 codebase:
19+
Multiple phrases should be separated by a comma (without _and_), which does break this structure, but the individual parts should still follow it. Here is a sample set of commits from our 2020 codebase:
2020

2121
![image of commits](https://i.imgur.com/ZhsBEtP.png)
22-

docs/introduction/index.md

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
# Introduction
2-
The software docs are designed to act both as training material as well as a quick refrerence for those looking to refresh their knowledge or learn a little about how software works. It's divided into three sections: Introduction, Basic Concepts, and Advanced Concepts.
32

4-
- The [Introduction](.) section is designed to be a "Week 1" training set, which goes over how to get set up to write software and some of the fundamental concepts that we use.
5-
- The [Basic Concepts](../basic/) include those that are used in every codebase, and make up the vast majority of the code we write. Any software member looking to make significant contributions should master these concepts, as a thorough understanding of them will allow you to quickly write code and provide a foundation to learn the more advanced concepts.
6-
- The [Advanced Concepts](../advanced/) are those that may not be used every year or ones that are complicated enough that we use an external library to provide their functionality. These should only be tackled if you are very comfortable with the basic conepts.
3+
The software docs are designed to act both as training material as well as a quick refrerence for those looking to refresh their knowledge or learn a little about how software works. It's divided into three sections: Introduction, Basic Concepts, and Advanced Concepts.
74

8-
It's important to know that the docs are intended as a supplement to normal training presentations and projects. Reading these pages alone will not help you learn, you need to actually open an editor and write some original code. Copying from the docs won't help you learn, even if it writing code feels challenging at first.
5+
- The [Introduction](.) section is designed to be a "Week 1" training set, which goes over how to get set up to write software and some of the fundamental concepts that we use.
6+
- The [Basic Concepts](../basic/) include those that are used in every codebase, and make up the vast majority of the code we write. Any software member looking to make significant contributions should master these concepts, as a thorough understanding of them will allow you to quickly write code and provide a foundation to learn the more advanced concepts.
7+
- The [Advanced Concepts](../advanced/) are those that may not be used every year or ones that are complicated enough that we use an external library to provide their functionality. These should only be tackled if you are very comfortable with the basic conepts.
98

10-
If you have any extra questions or comments about any of the material, feel free to send a message in #software.
9+
It's important to know that the docs are intended as a supplement to normal training presentations and projects. Reading these pages alone will not help you learn, you need to actually open an editor and write some original code. Copying from the docs won't help you learn, even if it writing code feels challenging at first.
10+
11+
If you have any extra questions or comments about any of the material, feel free to send a message in #software.

docs/introduction/installation.md

+8-8
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22

33
In order to start coding, you'll need to the right apps to allow you to write robot code. The software can be divided into two groups: those needed to write and deploy code, and those needed to enable and run the robot. Since all the programs needed to run the code are already installed on the software laptop, you only need to install the ones for coding. These include:
44

5-
- Visual Studio Code, an IDE for writing code
6-
- Java JDK 11, to compile the project
7-
- Gradle, a program to build and deploy code
8-
- VS Code extentions, to streamline development
9-
- Git, to manage our code over time
10-
- WPILib, a library that interfaces with the robot
5+
- Visual Studio Code, an IDE for writing code
6+
- Java JDK 11, to compile the project
7+
- Gradle, a program to build and deploy code
8+
- VS Code extentions, to streamline development
9+
- Git, to manage our code over time
10+
- WPILib, a library that interfaces with the robot
1111

1212
Fortunately, almost all of these are included with an installer that WPILib provides, which installs a custom version of VS Code (which will be separate from an existing version of VS Code). Follow the following link to go through the installation process: <https://docs.wpilib.org/en/stable/docs/zero-to-robot/step-2/wpilib-setup.html>
1313

14-
Make sure to select **Download VS Code for Single Install** as the installation option. You can leave all the installation options checked, technically our team doesn't use C++ or the Tools and Utilities, but its still nice to have them available.
14+
Make sure to select **Download VS Code for Single Install** as the installation option. You can leave all the installation options checked, technically our team doesn't use C++ or the Tools and Utilities, but its still nice to have them available.
1515

16-
Once the installation process finishes, first check the name of the VS Code application that it created. If it has the name "Visual Studio Code," I recommend you rename it to something like FRC VS Code 2021 (or the correct year), so you can keep track of multiple versions over time and avoid conflicts with the actual non-WPILib VS Code. Also, you'll have to install Live Share, an extension that isn't included in the installer. Open VS Code and click on the bottom most icon on the left side (looks 3 squares with 1 more detached), then search for "Live Share" and install the one by Microsoft. Live Share is essentially Google Docs for coding and makes collaboration very easy.
16+
Once the installation process finishes, first check the name of the VS Code application that it created. If it has the name "Visual Studio Code," I recommend you rename it to something like FRC VS Code 2021 (or the correct year), so you can keep track of multiple versions over time and avoid conflicts with the actual non-WPILib VS Code. Also, you'll have to install Live Share, an extension that isn't included in the installer. Open VS Code and click on the bottom most icon on the left side (looks 3 squares with 1 more detached), then search for "Live Share" and install the one by Microsoft. Live Share is essentially Google Docs for coding and makes collaboration very easy.

docs/introduction/java-resources.md

+18-15
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,27 @@
11
# Java Resources
22

3-
Our team uses Java to code the robot, primarily because Harker also teaches Java in CS classes. Other langauges that are common among other teams are C++, LabView, and Python.
3+
Our team uses Java to code the robot, primarily because Harker also teaches Java in CS classes. Other langauges that are common among other teams are C++, LabView, and Python.
44

5-
A working knowledge of Java is important in learning FRC programming, especially once the program constructs are introduced. Concepts like the command-based system and robot lifecycle are much easier to understand if you have a programming background. However, in general the curriculum is designed to be useful to those even without programming experience. If you've completed Advanced Programming or higher you should be fine, otherwise if you haven't learned Java or know another language, it is highly recommended to learn or refresh yourself in Java syntax. Below are a list of resoucres, tutorials, and videos that can assist your learning.
5+
A working knowledge of Java is important in learning FRC programming, especially once the program constructs are introduced. Concepts like the command-based system and robot lifecycle are much easier to understand if you have a programming background. However, in general the curriculum is designed to be useful to those even without programming experience. If you've completed Advanced Programming or higher you should be fine, otherwise if you haven't learned Java or know another language, it is highly recommended to learn or refresh yourself in Java syntax. Below are a list of resoucres, tutorials, and videos that can assist your learning.
66

77
### Learning Java
8-
- [Codecademy course](https://www.codecademy.com/learn/learn-java)
9-
- [Youtube tutorial](https://www.youtube.com/watcH?v=GoXwIVyNvX0)
10-
- [Java syntax review](https://learnxinyminutes.com/docs/java)
8+
9+
- [Codecademy course](https://www.codecademy.com/learn/learn-java)
10+
- [Youtube tutorial](https://www.youtube.com/watcH?v=GoXwIVyNvX0)
11+
- [Java syntax review](https://learnxinyminutes.com/docs/java)
1112

1213
### Practice
13-
- [CodingBat](https://codingbat.com/java)
14-
- <https://practiceit.cs.washington.edu/>
14+
15+
- [CodingBat](https://codingbat.com/java)
16+
- <https://practiceit.cs.washington.edu/>
1517

1618
### Extras
17-
These are concepts that might not be emphasized in normal courses but you should definitely know for robot programming.
18-
19-
- [Object Oriented Programming Review](https://stackify.com/oops-concepts-in-java/)
20-
- [Static vs. Non-static 1](https://www.programiz.com/java-programming/static-keyword)
21-
- [Static vs. Non-static 2](https://beginnersbook.com/2013/05/static-vs-non-static-methods/)
22-
- [Static vs. Non-static 3](https://www.tutorialspoint.com/differences-between-static-and-non-static-methods-in-java)
23-
- [Singletons](https://www.programiz.com/java-programming/singleton)
24-
- [Enums](https://www.programiz.com/java-programming/enums)
19+
20+
These are concepts that might not be emphasized in normal courses but you should definitely know for robot programming.
21+
22+
- [Object Oriented Programming Review](https://stackify.com/oops-concepts-in-java/)
23+
- [Static vs. Non-static 1](https://www.programiz.com/java-programming/static-keyword)
24+
- [Static vs. Non-static 2](https://beginnersbook.com/2013/05/static-vs-non-static-methods/)
25+
- [Static vs. Non-static 3](https://www.tutorialspoint.com/differences-between-static-and-non-static-methods-in-java)
26+
- [Singletons](https://www.programiz.com/java-programming/singleton)
27+
- [Enums](https://www.programiz.com/java-programming/enums)

docs/stylesheets/extra.css

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
--md-primary-fg-color: #1e3155;
33
}
44

5-
:root>* {
6-
--md-typeset-a-color: #557cc3 !important;
7-
}
5+
:root > * {
6+
--md-typeset-a-color: #557cc3 !important;
7+
}

ecosystem.config.js

+11-9
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
module.exports = {
2-
apps : [{
3-
name: "_github",
4-
script: "./index.js",
5-
env_hook: {
6-
command: 'git pull && pm2 restart robo',
7-
cwd: '/home/djm/robotics-website'
8-
}
9-
}]
10-
}
2+
apps: [
3+
{
4+
name: "_github",
5+
script: "./index.js",
6+
env_hook: {
7+
command: "git pull && pm2 restart robo",
8+
cwd: "/home/djm/robotics-website",
9+
},
10+
},
11+
],
12+
};

exampleconfig.json

+11-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{
1+
{
22
"contacturl": "https://hooks.slack.com/services/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",
33
"google": {
44
"clientIDs": ["GoogleClientID"],
@@ -41,8 +41,16 @@
4141
"apiKey": "key"
4242
},
4343
"users": {
44-
"admins": ["22angiej@students.harker.org", "22ethanc@students.harker.org", "22gloriaz@students.harker.org"],
44+
"admins": [
45+
"22angiej@students.harker.org",
46+
"22ethanc@students.harker.org",
47+
"22gloriaz@students.harker.org"
48+
],
4549
"mentor": "robotics@harker.org",
46-
"superadmins": [ "22arjund@students.harker.org", "22chiragk@students.harker.org", "24kabirr@students.harker.org"]
50+
"superadmins": [
51+
"22arjund@students.harker.org",
52+
"22chiragk@students.harker.org",
53+
"24kabirr@students.harker.org"
54+
]
4755
}
4856
}

helpers/auth.js

+35-27
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,41 @@
11
const sessionAuth = (req, res, next) => {
2-
req.auth = req.session.auth
3-
if (!req.auth) req.auth = { loggedin: false }
4-
res.locals.auth = req.auth
5-
next()
6-
}
2+
req.auth = req.session.auth;
3+
if (!req.auth) req.auth = { loggedin: false };
4+
res.locals.auth = req.auth;
5+
next();
6+
};
77

88
const verifyLogin = (req, res, next) => {
9-
sessionAuth(req, res, () => {
10-
if (req.auth.loggedin) {
11-
console.log(`[REQ: ${req.request_id}] Authed as: ${req.auth.info.name} (${req.auth.info.email})`)
12-
console.log(`[REQ: ${req.request_id}] Auth level: ${req.auth.level}`)
13-
next()
14-
} else {
15-
res.render('pages/member/login')
16-
}
17-
})
18-
}
9+
sessionAuth(req, res, () => {
10+
if (req.auth.loggedin) {
11+
console.log(
12+
`[REQ: ${req.request_id}] Authed as: ${req.auth.info.name} (${req.auth.info.email})`
13+
);
14+
console.log(
15+
`[REQ: ${req.request_id}] Auth level: ${req.auth.level}`
16+
);
17+
next();
18+
} else {
19+
res.render("pages/member/login");
20+
}
21+
});
22+
};
1923

20-
const verifyRank = rank => {
21-
return (req, res, next) => {
22-
verifyLogin(req, res, () => {
23-
if (req.auth.level >= rank) next()
24-
else res.render('pages/member/error', { statusCode: 401, error: "You must have higher authorization to reach this page."})
25-
})
26-
}
27-
}
24+
const verifyRank = (rank) => {
25+
return (req, res, next) => {
26+
verifyLogin(req, res, () => {
27+
if (req.auth.level >= rank) next();
28+
else
29+
res.render("pages/member/error", {
30+
statusCode: 401,
31+
error: "You must have higher authorization to reach this page.",
32+
});
33+
});
34+
};
35+
};
2836

2937
module.exports = {
30-
sessionAuth,
31-
verifyLogin,
32-
verifyRank,
33-
}
38+
sessionAuth,
39+
verifyLogin,
40+
verifyRank,
41+
};

0 commit comments

Comments
 (0)