├── .dockerignore ├── .editorconfig ├── .env.dev ├── .env.test ├── .eslintrc.json ├── .github ├── FUNDING.yml ├── ISSUE_TEMPLATE │ ├── bug-report.md │ ├── bug_report.md │ ├── enhancement.md │ ├── feature-request.md │ └── feature_request.md ├── pull_request_template.md └── workflows │ └── image-workflow.yaml ├── .gitignore ├── .travis.yml ├── Dockerfile.dev ├── Dockerfile.prod ├── LICENSE ├── README.md ├── app.js ├── app ├── controllers │ ├── activity.js │ ├── analytics.js │ ├── auth.js │ ├── comment.js │ ├── email.js │ ├── event.js │ ├── notification.js │ ├── organization.js │ ├── post.js │ ├── project.js │ ├── proposal.js │ ├── ticket.js │ ├── urlShortner.js │ ├── user.js │ └── wikis.js ├── middleware │ ├── OAuthMiddlewares.js │ ├── activate.js │ ├── activity.js │ ├── auth.js │ ├── isOAuthAllowed.js │ ├── maintenance.js │ ├── passportOAuth.js │ ├── rateLimiter.js │ └── sanitise.js ├── models │ ├── Activity.js │ ├── Comment.js │ ├── Event.js │ ├── Notifications.js │ ├── Organisation.js │ ├── Post.js │ ├── Project.js │ ├── Proposal.js │ ├── ProposalNotification.js │ ├── Ticket.js │ ├── UrlShortner.js │ └── User.js ├── routes │ ├── activity.js │ ├── analytics.js │ ├── auth.js │ ├── comment.js │ ├── event.js │ ├── index.js │ ├── notification.js │ ├── organisation.js │ ├── post.js │ ├── project.js │ ├── proposal.js │ ├── ticket.js │ ├── urlShortner.js │ ├── user.js │ └── wikis.js └── utils │ ├── activity-helper.js │ ├── collections.js │ ├── compressAndUpload.js │ ├── console-helper.js │ ├── fileToBuffer.js │ ├── format-user.js │ ├── notif-helper.js │ ├── notificationTags.js │ ├── paginate.js │ ├── permission.js │ ├── proposal-notif-helper.js │ ├── response-helper.js │ ├── settingHelpers.js │ ├── ticket-helper.js │ ├── uploadToAWS.js │ └── wikis-helper.js ├── bin └── www ├── config ├── fileHandlingConstants.js ├── gAnalytics.js ├── mongoose.js ├── passport.js ├── redis.js └── winston.js ├── docker-compose.dev.yml ├── docker-compose.prod.yml ├── docs ├── ansible │ └── ansible.md ├── docs.md └── wikis │ └── wikis.md ├── infra ├── backend.yml ├── frontend.yml ├── group_vars │ └── all.yml ├── hosts ├── roles │ ├── setup_client │ │ ├── defaults │ │ │ └── main.yml │ │ ├── tasks │ │ │ ├── main.yml │ │ │ └── nodejs.yml │ │ └── templates │ │ │ └── env.j2 │ ├── setup_dbs │ │ ├── defaults │ │ │ └── main.yml │ │ ├── files │ │ │ └── mongodb.conf │ │ ├── handlers │ │ │ └── main.yml │ │ ├── tasks │ │ │ ├── create_org.yml │ │ │ ├── main.yml │ │ │ ├── mongo.yml │ │ │ └── redis.yml │ │ └── templates │ │ │ └── organization.j2 │ ├── setup_nginx │ │ ├── tasks │ │ │ └── main.yml │ │ └── templates │ │ │ ├── etc_config.j2 │ │ │ └── nginx_conf.j2 │ └── setup_server │ │ ├── defaults │ │ └── main.yml │ │ ├── tasks │ │ └── main.yml │ │ └── templates │ │ └── ecosystem.config.j2 └── site.yml ├── package-lock.json ├── package.json ├── public └── stylesheets │ └── style.css ├── scripts └── install.sh ├── socket.js ├── test ├── comment.test.js ├── event.test.js ├── organisation.test.js ├── post.test.js ├── project.test.js ├── proposal.test.js ├── rateLimit.test.js ├── url.test.js └── user.test.js └── views ├── emailTemplate.ejs ├── error.ejs └── index.ejs /.dockerignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .git 3 | .github 4 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_style = space 5 | indent_size = 2 6 | end_of_line = lf 7 | charset = utf-8 8 | trim_trailing_whitespace = true 9 | insert_final_newline = true 10 | -------------------------------------------------------------------------------- /.env.dev: -------------------------------------------------------------------------------- 1 | PORT=5000 2 | NODE_ENV="development" 3 | JWT_SECRET="thisismysupersecrettokenjustkidding" 4 | DATABASE_URL="mongodb://localhost:27017/donut-development" 5 | SENDGRID_API_KEY='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' 6 | SENDGRID_FROM_EMAIL_ADDRESS='services@codeuino.com' 7 | SOCKET_PORT=8810 8 | clientbaseurl="http://localhost:3000" 9 | SOCKET_PORT=8810 10 | REDIS_HOST="redis" 11 | REDIS_PORT=6379 12 | REDIS_PASSWORD="auth" 13 | REDIS_DB=0 14 | REDIS_ACTIVITY_DB=1 15 | GITHUB_OAUTH_APP_CLIENTID="a3e08516c35fe7e83f43" 16 | GITHUB_OAUTH_APP_CLIENTSECRET="8393d95c3bfeeb0943045f447a9d055cb660bce0" 17 | GOOGLE_OAUTH_CLIENT_ID="" 18 | GOOGLE_OAUTH_CLIENT_SECRET="" 19 | GOOGLE_OAUTH_CALLBACK="http://localhost:5000/user/auth/google/callback" 20 | GITHUB_OAUTH_CLIENT_ID="" 21 | GITHUB_OAUTH_CLIENT_SECRET="" 22 | GITHUB_OAUTH_CALLBACK="http://localhost:5000/user/auth/github/callback" 23 | AWS_ACCESS_KEY="" 24 | AWS_SECRET_KEY="" 25 | AWS_STORAGE_REGION="" 26 | AWS_BUCKET_NAME="" 27 | # session token only if needed! 28 | AWS_SESSION_TOKEN='' 29 | MAX_WINDOW_REQUEST_COUNT= 30 | -------------------------------------------------------------------------------- /.env.test: -------------------------------------------------------------------------------- 1 | PORT=3000 2 | NODE_ENV=testing 3 | JWT_SECRET=thisismysupersecrettokenjustkidding 4 | DATABASE_URL=mongodb+srv://donut-admin:5cdS2C2g3wRAdQWp@donut-users-hdawt.mongodb.net/donut-testing?retryWrites=true&w=majority 5 | SENDGRID_API_KEY = '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' 6 | SOCKET_PORT = 8810 -------------------------------------------------------------------------------- /.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "browser": true, 4 | "commonjs": true, 5 | "es6": true, 6 | "jest": true 7 | }, 8 | "extends": [ 9 | "standard" 10 | ], 11 | "globals": { 12 | "Atomics": "readonly", 13 | "SharedArrayBuffer": "readonly" 14 | }, 15 | "parserOptions": { 16 | "ecmaVersion": 2018 17 | }, 18 | "rules": { 19 | } 20 | } -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | open_collective: donut 2 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug-report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug Report 3 | about: Create a report to help us improve 4 | title: "[BUG]" 5 | labels: bug 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **Steps to Reproduce** 14 | Steps to reproduce the behaviour: 15 | 1. Go to '...' 16 | 2. Click on '....' 17 | 3. Scroll down to '....' 18 | 4. See error 19 | 20 | **Expected behaviour** 21 | A clear and concise description of what you expected to happen. 22 | 23 | **Screenshots** 24 | If applicable, add screenshots to help explain your problem. 25 | 26 | **Console Log Output** 27 | If available, add console log output. 28 | 29 | **Desktop (please complete the following information):** 30 | - Browser [e.g. chrome, safari] 31 | 32 | **Additional context** 33 | Add any other context about the problem here. 34 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: bug 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behaviour: 15 | 1. Go to '...' 16 | 2. Click on '....' 17 | 3. Scroll down to '....' 18 | 4. See error 19 | 20 | **Expected behaviour** 21 | A clear and concise description of what you expected to happen. 22 | 23 | **Screenshots** 24 | If applicable, add screenshots to help explain your problem. 25 | 26 | **Console Log Output** 27 | If available, add console log output. 28 | 29 | **Desktop (please complete the following information):** 30 | - Browser [e.g. chrome, safari] 31 | 32 | **Additional context** 33 | Add any other context about the problem here. 34 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/enhancement.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Enhancement 3 | about: Describe the enhancement request. 4 | title: "[ENHANCEMENT]" 5 | labels: enhancement 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the enhancement you'd like** 11 | A clear and concise description of what you want to enhance. 12 | 13 | **Describe approaches if you have thought of any** 14 | A clear and concise description of any approaches solutions you've considered. 15 | 16 | **Additional context** 17 | Add any resources that will be helpful for this issue. 18 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature-request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature Request 3 | about: Suggest an idea for this project 4 | title: "[FEATURE]" 5 | labels: feature 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: feature 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /.github/pull_request_template.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Pull Request template 3 | about: Describe the PR. 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | ### **Problem** 11 | Github Issue Number: # 12 | Describe the problem you are trying to achieve. Please provide in detail_ 13 | 14 | ### **Solution of problem** 15 | How did you solve this problem? 16 | 17 | ### **In Case of UI Changes** 18 | **Before Changes Screenshot** [How was it earlier, add it here] 19 | 20 | **After Changes Screenshot** [How it looks now, add it here] 21 | 22 | ### **Type of Change** 23 | [ ] Bug fix 24 | [ ] New Feature 25 | [ ] Development of UI/UX prototypes 26 | [ ] Small refactor 27 | [ ] Change in Documentation 28 | 29 | ### **Checklist** 30 | [ ] My code follows the same style as the codebase 31 | [ ] My Code change requires a change in documentation 32 | [ ] I have updated the Readme accordingly 33 | [ ] I made PR against **development branch** 34 | [ ] I have run the test cases locally and it's passing. 35 | [ ] I have squashed my commits 36 | -------------------------------------------------------------------------------- /.github/workflows/image-workflow.yaml: -------------------------------------------------------------------------------- 1 | name: donut-server-image-ci 2 | 3 | on: 4 | push: 5 | branches: 6 | - development 7 | 8 | tags: 9 | - v* 10 | 11 | env: 12 | IMAGE_NAME: donut-server:latest 13 | REPO_NAME: codeuino1 14 | REGISTRY_NAME: registry.hub.docker.com 15 | 16 | jobs: 17 | push: 18 | runs-on: ubuntu-latest 19 | steps: 20 | - uses: actions/checkout@v2 21 | 22 | - name: Build image 23 | run: docker build . --file Dockerfile.prod --tag $IMAGE_NAME 24 | 25 | - name: Log into registry 26 | run: echo "{{ secrets.DOCKER_PASSWORD }}" | docker login -u {{ secrets.DOCKER_USERNAME }} --password-stdin 27 | - name: Push image 28 | run: | 29 | IMAGE_ID=$REGISTRY_NAME/$REPO_NAME/$IMAGE_NAME 30 | 31 | [[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//') 32 | 33 | echo IMAGE_ID=$IMAGE_ID 34 | echo VERSION=$VERSION 35 | 36 | docker tag $IMAGE_NAME $IMAGE_ID:$VERSION 37 | docker push $IMAGE_ID:$VERSION 38 | docker tag $IMAGE_NAME $IMAGE_ID:latest 39 | docker push $IMAGE_ID:$VERSION 40 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | lerna-debug.log* 8 | 9 | # Diagnostic reports (https://nodejs.org/api/report.html) 10 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 11 | 12 | # Runtime data 13 | pids 14 | *.pid 15 | *.seed 16 | *.pid.lock 17 | 18 | # Directory for instrumented libs generated by jscoverage/JSCover 19 | lib-cov 20 | 21 | # Coverage directory used by tools like istanbul 22 | coverage 23 | *.lcov 24 | 25 | # nyc test coverage 26 | .nyc_output 27 | 28 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 29 | .grunt 30 | 31 | # Bower dependency directory (https://bower.io/) 32 | bower_components 33 | 34 | # node-waf configuration 35 | .lock-wscript 36 | 37 | # Compiled binary addons (https://nodejs.org/api/addons.html) 38 | build/Release 39 | 40 | # Dependency directories 41 | node_modules/ 42 | jspm_packages/ 43 | 44 | # TypeScript v1 declaration files 45 | typings/ 46 | 47 | # TypeScript cache 48 | *.tsbuildinfo 49 | 50 | # Optional npm cache directory 51 | .npm 52 | 53 | # Optional eslint cache 54 | .eslintcache 55 | 56 | # Microbundle cache 57 | .rpt2_cache/ 58 | .rts2_cache_cjs/ 59 | .rts2_cache_es/ 60 | .rts2_cache_umd/ 61 | 62 | # Optional REPL history 63 | .node_repl_history 64 | 65 | # Output of 'npm pack' 66 | *.tgz 67 | 68 | # Yarn Integrity file 69 | .yarn-integrity 70 | 71 | # dotenv environment variables file 72 | .env 73 | .env.prod 74 | 75 | # parcel-bundler cache (https://parceljs.org/) 76 | .cache 77 | 78 | # next.js build output 79 | .next 80 | 81 | # nuxt.js build output 82 | .nuxt 83 | 84 | # gatsby files 85 | .cache/ 86 | 87 | # vuepress build output 88 | .vuepress/dist 89 | 90 | # Serverless directories 91 | .serverless/ 92 | 93 | # FuseBox cache 94 | .fusebox/ 95 | 96 | # DynamoDB Local files 97 | .dynamodb/ 98 | 99 | .DS_Store 100 | 101 | .vscode/ -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - 8.11.3 -------------------------------------------------------------------------------- /Dockerfile.dev: -------------------------------------------------------------------------------- 1 | FROM node:14 2 | 3 | ENV NODE_ENV="development" 4 | 5 | # Copy package.json file into container 6 | COPY package.json package.json 7 | COPY package-lock.json package-lock.json 8 | 9 | # Install node modules 10 | RUN npm install && \ 11 | npm install --only=dev && \ 12 | npm cache clean --force --loglevel=error 13 | 14 | # Volume to mount source code into container 15 | VOLUME [ "/server" ] 16 | 17 | # move to the source code directory 18 | WORKDIR /server 19 | 20 | # Start the server 21 | CMD mv ../node_modules . && npm run dev 22 | -------------------------------------------------------------------------------- /Dockerfile.prod: -------------------------------------------------------------------------------- 1 | FROM node:14 2 | 3 | ENV NODE_ENV="production" 4 | 5 | WORKDIR /server 6 | 7 | RUN git clone https://github.com/codeuino/social-platform-donut-backend.git 8 | 9 | WORKDIR /server/social-platform-donut-backend 10 | 11 | RUN npm install && \ 12 | npm install pm2@latest -g && \ 13 | npm cache clean --force --loglevel=error 14 | 15 | # Start the server 16 | CMD [ "pm2", "start", "./bin/www", "--time", "--no-daemon" ] 17 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # social-platform-donut-backend 2 | 3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
112 | POST : To create resource 113 | PATCH : To Update resource 114 | GET : Get a resource or list of resources 115 | DELETE : To delete resource 116 |117 | 118 | ## Description Of Donut API Server Responses: 119 |
Code | 122 |Name | 123 |Details | 124 |
---|---|---|
200 |
127 | OK |
128 | the request was successful. | 129 |
201 |
132 | Created |
133 | the request was successful and a resource was created. | 134 |
204 |
137 | No Content |
138 | the request was successful but there is no representation to return (i.e. the response is empty). | 139 |
400 |
142 | Bad Request |
143 | the request could not be understood or was missing required parameters. | 144 |
401 |
147 | Unauthorized |
148 | authentication failed or user doesn't have permissions for requested operation. | 149 |
403 |
152 | Forbidden |
153 | access denied. | 154 |
404 |
157 | Not Found |
158 | resource was not found. | 159 |
405 |
162 | Method Not Allowed |
163 | requested method is not supported for resource. | 164 |
409 |
167 | Conflict |
168 | resourse with given id already exist. | 169 |
429 |
172 | Too many requests |
173 | sent too many requests to the server in short span of time | 174 |
18 |
19 | ![]() |
25 | |||||||
29 |
|
116 | |||||||
121 |
|
129 | |||||||
134 |
|
144 |
145 |
<%= error.stack %>4 | -------------------------------------------------------------------------------- /views/index.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
Welcome to <%= title %>
10 | 11 | 12 | --------------------------------------------------------------------------------