From 6d4738cd37e8ff26c9e8728e0b8a025ea1b14018 Mon Sep 17 00:00:00 2001 From: BRAVO68WEB Date: Mon, 31 Jan 2022 23:05:13 +0530 Subject: [PATCH] Last Minute Conf --- .github/labels.json | 37 ++++++ .github/workflows/issue-labeler.yml | 17 +++ .github/workflows/one-issue-at-time.yml | 19 +++ HOW_TO_CONTRIBUTE.md | 146 ++++++++++++++++++++++++ README.md | 4 + backend/.env.example | 2 +- {frontend => backend}/.prettierrc | 0 backend/config/mongodb.js | 22 ++-- backend/controllers/home_controller.js | 4 +- backend/index.js | 62 +++++----- backend/package.json | 84 +++++++------- backend/routers/index.js | 10 +- backend/yarn.lock | 5 + 13 files changed, 324 insertions(+), 88 deletions(-) create mode 100644 .github/labels.json create mode 100644 .github/workflows/issue-labeler.yml create mode 100644 .github/workflows/one-issue-at-time.yml create mode 100644 HOW_TO_CONTRIBUTE.md rename {frontend => backend}/.prettierrc (100%) diff --git a/.github/labels.json b/.github/labels.json new file mode 100644 index 0000000..3cad08b --- /dev/null +++ b/.github/labels.json @@ -0,0 +1,37 @@ +[ + { + "name": "good first issue", + "description": "This issue is good for first timers", + "color": "7057ff" + }, + { + "name": "help wanted", + "description": "This issue needs help ! Please help if possible !", + "color": "008672" + }, + { + "name": "hard", + "description": "Points will be: 5(1st Phase), 8(2nd Phase). 4 days will be allotted.", + "color": "f90716" + }, + { + "name": "medium", + "description": "Points will be: 3(1st Phase), 4(2nd Phase). 2-3 days will be allotted.", + "color": "ffe400" + }, + { + "name": "easy", + "description": "Points will be: 1(1st Phase), 2(2nd Phase). 1 day will be allotted.", + "color": "28ffbf" + }, + { + "name": "JWOC", + "description": "This issue/pull request will be considered for JWOC 2k22.", + "color": "1d4cb0" + }, + { + "name": "🤩 Up for Grab", + "description": "This issue is not assigned ! Grab It !", + "color": "bf00ff" + } +] diff --git a/.github/workflows/issue-labeler.yml b/.github/workflows/issue-labeler.yml new file mode 100644 index 0000000..c9cd0ed --- /dev/null +++ b/.github/workflows/issue-labeler.yml @@ -0,0 +1,17 @@ +name: Issue/Pull Request Label + +on: [push] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - name: Label Syncer + uses: micnncim/action-label-syncer@v1.3.0 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_REPOSITORY: ${{ github.repository }} + with: + manifest: .github/labels.json + prune: false \ No newline at end of file diff --git a/.github/workflows/one-issue-at-time.yml b/.github/workflows/one-issue-at-time.yml new file mode 100644 index 0000000..6c3654f --- /dev/null +++ b/.github/workflows/one-issue-at-time.yml @@ -0,0 +1,19 @@ +name: Issue_watcher + +on: + issues: + types: [opened] + +jobs: + first-job: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@main + - name: Run Action + uses: TesseractCoding/Issue_Watcher@main + with: + token: '${{ secrets.GITHUB_TOKEN }}' + author: '${{github.actor}}' + repo: BRAVO68WEB/url-minify + maxIssue: 2 \ No newline at end of file diff --git a/HOW_TO_CONTRIBUTE.md b/HOW_TO_CONTRIBUTE.md new file mode 100644 index 0000000..893a66b --- /dev/null +++ b/HOW_TO_CONTRIBUTE.md @@ -0,0 +1,146 @@ +# How to contribute + +Hello 👋. We are glad to have you here. + +## GIT AND GITHUB +*** +Before continuing we want to clarify the difference between Git and Github. Git is a version control system(VCS) which is a tool to manage the history of our Source Code. GitHub is a hosting service for Git projects. + +We assume you have created an account on Github and installed Git on your System. + +Now tell Git your name and E-mail (used on Github) address. + +``` $ git config --global user.name "YOUR NAME" ``` +```$ git config --global user.email "YOUR EMAIL ADDRESS"``` +This is an important step to mark your commits to your name and email. + +### FORK A PROJECT - +*** +You can use github explore - https://github.com/explore to find a project that interests you and match your skills. Once you find your cool project to workon, you can make a copy of project to your account. This process is called forking a project to your Github account. On Upper right side of project page on Github, you can see - + +

+Click on fork to create a copy of project to your account. This creates a separate copy for you to workon. + +### FINDING A FEATURE OR BUG TO WORKON - +*** +Open Source projects always have something to workon and improves with each new release. You can see the issues section to find something you can solve or report a bug. The project managers always welcome new contributors and can guide you to solve the problem. You can find issues in the right section of project page. + +

+ +### CLONE THE FORKED PROJECT - +*** +You have forked the project you want to contribute to your github account. To get this project on your development machine we use clone command of git. + +```$ git clone https://github.com//.git``` +Now you have the project on your local machine. + +### ADD A REMOTE (UPSTREAM) TO ORIGINAL PROJECT REPOSITORY +*** +Remote means the remote location of project on Github. By cloning, we have a remote called origin which points to your forked repository. Now we will add a remote to the original repository from where we had forked. + +```$ cd ``` +```$ git remote add upstream https://github.com//.git``` +You will see the benefits of adding remote later. +### SYNCHRONIZING YOUR FORK - +*** +Open Source projects have a number of contributors who can push code anytime. So it is necessary to make your forked copy equal with the original repository. The remote added above called Upstream helps in this. + +```$ git checkout master``` +```$ git fetch upstream``` +```$ git merge upstream/master``` +```$ git push origin master``` +The last command pushes the latest code to your forked repository on Github. The origin is the remote pointing to your forked repository on github. + +### CREATE A NEW BRANCH FOR A FEATURE OR BUGFIX - +*** +Normally, all repositories have a master branch which is considered to remain stable and all new features should be made in a separate branch and after completion merged into master branch. So we should create a new branch for our feature or bugfix and start working on the issue. + +```$ git checkout -b ``` +This will create a new branch out of master branch. Now start working on the problem and commit your changes. + +```$ git add --all``` +```$ git commit -m ""``` +The first command adds all the files or you can add specific files by removing -a and adding the file names. The second command gives a message to your changes so you can know in future what changes this commit makes. If you are solving an issue on original repository, you should add the issue number like #35 to your commit message. This will show the reference to commits in the issue. +### REBASE YOUR FEATURE BRANCH WITH UPSTREAM- +*** +It can happen that your feature takes time to complete and other contributors are constantly pushing code. After completing the feature your feature branch should be rebase on latest changes to upstream master branch. + +```$ git checkout ``` +```$ git pull --rebase upstream master``` +Now you get the latest commits from other contributors and check that your commits are compatible with the new commits. If there are any conflicts solve them. + +### SQUASHING YOUR COMMITS- +*** +You have completed the feature, but you have made a number of commits which make less sense. You should squash your commits to make good commits. +```$ git rebase -i HEAD~5``` +This will open an editor which will allow you to squash the commits. + +### PUSH CODE AND CREATE A PULL REQUEST - +*** +Till this point you have a new branch with the feature or bugfix you want in the project you had forked. Now push your new branch to your remote fork on github. + +```$ git push origin ``` +Now you are ready to help the project by opening a pull request means you now tell the project managers to add the feature or bugfix to original repository. You can open a pull request by clicking on green icon - + +

+ +Remember your upstream base branch should be master and source should be your feature branch. Click on create pull request and add a name to your pull request. You can also describe your feature. + +Awesome! You have made your first contribution. If you have any doubts please let me know in the comments. + +#### BE OPEN! +*** + +## For Front End + +Got to frontend directory by typing `$ cd frontend` in your terminal. +In the frontend directory, you can run: + +#### `yarn` + +#### `yarn start` + +Runs the app in the development mode.
+Open [http://localhost:3000](http://localhost:3000) to view it in the browser. + +The page will reload if you make edits.
+You will also see any lint errors in the console. + +
+ +## For Back End + +Got to backend directory by typing `$ cd backend` in your terminal. +In the backend directory, you can run: + +#### `yarn` + +#### `yarn dev` + +Runs the app in the development mode.
+Open [http://localhost:5000](http://localhost:5000) to view it in the browser.

+Make sure you have `Nodemon` installed in your system, either globally or locally for this project
+
+ +## Contributing to repository + +### Commit Message Format + +This is the list of _type_ of commits that we accept: + +- **chore** : Updating deps, docs, linting, etc. +- **ci** : Changes to our CI configuration files and scripts +- **docs** : Documentation only changes. +- **feat** : A new feature. +- **fix** : A bug fix. +- **perf** : A code change that improves performance. +- **refactor** : A code change that neither fixes a bug nor adds a feature. +- **revert** : Reverts the previous commit. +- **style** : Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc). +- **test** : Adding missing tests or correcting existing tests. + +✔ Participant are requested to give regular updates regarding their progress to the project leads. + +✔ If the participant is not able to contribute to the assigned issue due to any reason, kindly let the project leads know so that the issue is assigned to some other participant. + +### Happy Coding 👩‍💻👩‍💻 \ No newline at end of file diff --git a/README.md b/README.md index ee116d1..b4807bc 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,10 @@ ![NodeJS](https://img.shields.io/badge/node.js-6DA55F?style=for-the-badge&logo=node.js&logoColor=white&color=green) ![NextJS](https://img.shields.io/badge/nextjs-1.svg?style=for-the-badge&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cHRjAAB4nOPyDAhxVigoyk/LzEnlUgADIwsuYwsTIxNLkxQDEyBEgDTDZAMjs1Qgy9jUyMTMxBzEB8uASKBKLgDqFxF08kI1lQAAAABJRU5ErkJggg==&color=grey) +## Getting Started + +Read here :- [How to Contribute](HOW_TO_CONTRIBUTE.md) + ## Install ```sh diff --git a/backend/.env.example b/backend/.env.example index 1b6b2a2..b45d350 100644 --- a/backend/.env.example +++ b/backend/.env.example @@ -1,2 +1,2 @@ MONGO_DB=mongo-uri -SECRET= \ No newline at end of file +SECRET=secret \ No newline at end of file diff --git a/frontend/.prettierrc b/backend/.prettierrc similarity index 100% rename from frontend/.prettierrc rename to backend/.prettierrc diff --git a/backend/config/mongodb.js b/backend/config/mongodb.js index 8ce9428..7b7419c 100644 --- a/backend/config/mongodb.js +++ b/backend/config/mongodb.js @@ -1,14 +1,14 @@ -const mongoose = require("mongoose"); -require("dotenv").config(); +const mongoose = require('mongoose') +require('dotenv').config() const db = mongoose - .connect(process.env.MONGO_DB) - .then(() => { - console.log("Connected to MongoDB 🍀"); - return mongoose.connection.getClient(); - }) - .catch((e) => { - console.log(e); - }); + .connect(process.env.MONGO_DB) + .then(() => { + console.log('Connected to MongoDB 🍀') + return mongoose.connection.getClient() + }) + .catch((e) => { + console.log(e) + }) -module.exports = db; +module.exports = db diff --git a/backend/controllers/home_controller.js b/backend/controllers/home_controller.js index 3beb547..0cb2a62 100644 --- a/backend/controllers/home_controller.js +++ b/backend/controllers/home_controller.js @@ -1,3 +1,3 @@ module.exports.home = function (req, res) { - return res.send("URL MiniFy is running"); -}; + return res.send('URL MiniFy is running') +} diff --git a/backend/index.js b/backend/index.js index d340908..220f736 100644 --- a/backend/index.js +++ b/backend/index.js @@ -1,34 +1,40 @@ -const express = require("express"); -const http = require("http"); -const { urlencoded, json } = require("body-parser"); -const session = require("express-session"); -const mongoStore = require("connect-mongo"); -const db = require("./config/mongodb"); +const express = require('express') +const http = require('http') +const { urlencoded, json } = require('body-parser') +const session = require('express-session') +const mongoStore = require('connect-mongo') +const db = require('./config/mongodb') -require("dotenv").config(); -const app = express(); +require('dotenv').config() +const app = express() -app.use(express.json()); -app.use(json()); -app.use(urlencoded({ extended: false })); +app.use(express.json()) +app.use(json()) +app.use( + urlencoded({ + extended: false, + }) +) app.use( - session({ - name: "url-minify", - // TODO change the secret before deployment secret need to be proper key for now we put some random text - saveUninitialized: false, - resave: false, - secret: process.env.SECRET, - cookie: { - maxAge: 1000 * 60 * 30, - }, - store: mongoStore.create({ clientPromise: db }), - }) -); + session({ + name: 'url-minify', + // TODO change the secret before deployment secret need to be proper key for now we put some random text + saveUninitialized: false, + resave: false, + secret: process.env.SECRET, + cookie: { + maxAge: 1000 * 60 * 30, + }, + store: mongoStore.create({ + clientPromise: db, + }), + }) +) -app.use("/", require("./routers")); +app.use('/', require('./routers')) -const server = http.createServer(app); -server.listen(process.env.PORT || 5000, "0.0.0.0", () => { - console.log(`🤖 API listening on port ${process.env.PORT || 5000}!`); -}); \ No newline at end of file +const server = http.createServer(app) +server.listen(process.env.PORT || 5000, '0.0.0.0', () => { + console.log(`🤖 API listening on port ${process.env.PORT || 5000}!`) +}) diff --git a/backend/package.json b/backend/package.json index 026f345..e84f872 100644 --- a/backend/package.json +++ b/backend/package.json @@ -1,43 +1,45 @@ { - "name": "url-minify-api", - "version": "1.0.0", - "description": "URL Minify Backend", - "main": "index.js", - "scripts": { - "dev": "nodemon index.js", - "start": "node index.js" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/bravo68web/url-minify.git" - }, - "keywords": [ - "express", - "api", - "url", - "rest" - ], - "author": "BRAVO68WEB", - "license": "MIT", - "bugs": { - "url": "https://github.com/bravo68web/url-minify/issues" - }, - "homepage": "https://github.com/bravo68web/url-minify#readme", - "dependencies": { - "axios": "^0.25.0", - "body-parser": "^1.19.1", - "chalk": "^5.0.0", - "connect-mongo": "^4.6.0", - "cors": "^2.8.5", - "dotenv": "^14.3.2", - "express": "^4.17.2", - "express-session": "^1.17.2", - "helmet": "^5.0.2", - "mongoose": "^6.1.8", - "morgan": "^1.10.0", - "nanoid": "^3.2.0" - }, - "devDependencies": { - "nodemon": "^2.0.15" - } + "name": "url-minify-api", + "version": "1.0.0", + "description": "URL Minify Backend", + "main": "index.js", + "scripts": { + "dev": "nodemon index.js", + "start": "node index.js", + "prettier": "prettier --write ." + }, + "repository": { + "type": "git", + "url": "git+https://github.com/bravo68web/url-minify.git" + }, + "keywords": [ + "express", + "api", + "url", + "rest" + ], + "author": "BRAVO68WEB", + "license": "MIT", + "bugs": { + "url": "https://github.com/bravo68web/url-minify/issues" + }, + "homepage": "https://github.com/bravo68web/url-minify#readme", + "dependencies": { + "axios": "^0.25.0", + "body-parser": "^1.19.1", + "chalk": "^5.0.0", + "connect-mongo": "^4.6.0", + "cors": "^2.8.5", + "dotenv": "^14.3.2", + "express": "^4.17.2", + "express-session": "^1.17.2", + "helmet": "^5.0.2", + "mongoose": "^6.1.8", + "morgan": "^1.10.0", + "nanoid": "^3.2.0" + }, + "devDependencies": { + "nodemon": "^2.0.15", + "prettier": "2.5.1" + } } diff --git a/backend/routers/index.js b/backend/routers/index.js index f14c293..bfe26f2 100644 --- a/backend/routers/index.js +++ b/backend/routers/index.js @@ -1,8 +1,8 @@ -const express = require("express"); -const router = express.Router(); +const express = require('express') +const router = express.Router() -const homeController = require("../controllers/home_controller"); +const homeController = require('../controllers/home_controller') -router.get("/", homeController.home); +router.get('/', homeController.home) -module.exports = router; +module.exports = router diff --git a/backend/yarn.lock b/backend/yarn.lock index dc8482f..df61ba9 100644 --- a/backend/yarn.lock +++ b/backend/yarn.lock @@ -1018,6 +1018,11 @@ prepend-http@^2.0.0: resolved "https://registry.yarnpkg.com/prepend-http/-/prepend-http-2.0.0.tgz#e92434bfa5ea8c19f41cdfd401d741a3c819d897" integrity sha1-6SQ0v6XqjBn0HN/UAddBo8gZ2Jc= +prettier@2.5.1: + version "2.5.1" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.5.1.tgz#fff75fa9d519c54cf0fce328c1017d94546bc56a" + integrity sha512-vBZcPRUR5MZJwoyi3ZoyQlc1rXeEck8KgeC9AwwOn+exuxLxq5toTRDTSaVrXHxelDMHy9zlicw8u66yxoSUFg== + proxy-addr@~2.0.7: version "2.0.7" resolved "https://registry.yarnpkg.com/proxy-addr/-/proxy-addr-2.0.7.tgz#f19fe69ceab311eeb94b42e70e8c2070f9ba1025"