├── .nvmrc
├── docs
├── CNAME
├── .DS_Store
├── api
│ ├── img
│ │ └── favicon.ico
│ ├── fonts
│ │ ├── glyphicons-halflings-regular.eot
│ │ ├── glyphicons-halflings-regular.ttf
│ │ ├── glyphicons-halflings-regular.woff
│ │ └── glyphicons-halflings-regular.woff2
│ ├── api_project.json
│ ├── api_project.js
│ ├── vendor
│ │ ├── prettify
│ │ │ ├── prettify.css
│ │ │ ├── lang-rd.js
│ │ │ ├── lang-latex.js
│ │ │ ├── lang-tex.js
│ │ │ ├── lang-go.js
│ │ │ ├── lang-proto.js
│ │ │ ├── lang-ll.js
│ │ │ ├── lang-llvm.js
│ │ │ ├── lang-yaml.js
│ │ │ ├── lang-yml.js
│ │ │ ├── lang-cbm.js
│ │ │ ├── lang-basic.js
│ │ │ ├── lang-wiki.js
│ │ │ ├── lang-lua.js
│ │ │ ├── lang-erl.js
│ │ │ ├── lang-erlang.js
│ │ │ ├── lang-hs.js
│ │ │ ├── lang-tcl.js
│ │ │ ├── lang-pascal.js
│ │ │ ├── lang-r.js
│ │ │ ├── lang-s.js
│ │ │ ├── lang-Splus.js
│ │ │ ├── lang-cl.js
│ │ │ ├── lang-el.js
│ │ │ ├── lang-ss.js
│ │ │ ├── lang-lisp.js
│ │ │ ├── lang-lsp.js
│ │ │ ├── lang-rkt.js
│ │ │ ├── lang-scm.js
│ │ │ ├── lang-lgt.js
│ │ │ ├── lang-logtalk.js
│ │ │ ├── lang-clj.js
│ │ │ ├── lang-mumps.js
│ │ │ ├── lang-css.js
│ │ │ ├── lang-scala.js
│ │ │ ├── lang-aea.js
│ │ │ ├── lang-agc.js
│ │ │ ├── lang-apollo.js
│ │ │ ├── lang-dart.js
│ │ │ ├── lang-fs.js
│ │ │ ├── lang-ml.js
│ │ │ ├── lang-swift.js
│ │ │ ├── lang-vhd.js
│ │ │ ├── lang-vhdl.js
│ │ │ ├── lang-n.js
│ │ │ ├── lang-nemerle.js
│ │ │ ├── lang-rust.js
│ │ │ ├── lang-sql.js
│ │ │ ├── lang-vb.js
│ │ │ └── lang-vbs.js
│ │ ├── path-to-regexp
│ │ │ └── LICENSE
│ │ └── prettify.css
│ └── locales
│ │ ├── zh.js
│ │ ├── zh_cn.js
│ │ ├── tr.js
│ │ ├── pl.js
│ │ ├── ca.js
│ │ ├── vi.js
│ │ ├── cs.js
│ │ ├── de.js
│ │ ├── ro.js
│ │ ├── ru.js
│ │ ├── pt_br.js
│ │ ├── es.js
│ │ ├── nl.js
│ │ ├── fr.js
│ │ ├── it.js
│ │ └── locale.js
├── _config.yml
├── deploy.md
└── getting-started.md
├── Procfile
├── .dockerignore
├── .eslintignore
├── .prettierignore
├── results.txt
├── results2.txt
├── tests
├── testResume.pdf
├── auth.service.spec.js
├── util
│ ├── auth.test.util.js
│ ├── staff.test.util.js
│ ├── settings.test.util.js
│ ├── bus.test.util.js
│ ├── role.test.util.js
│ ├── resetPassword.test.util.js
│ ├── volunteer.test.util.js
│ ├── sponsor.test.util.js
│ └── team.test.util.js
├── storage.spec.js
├── setup.spec.js
└── email.service.spec.js
├── assets
└── email
│ └── test.hbs
├── .prettierrc
├── .idea
├── misc.xml
├── jsLibraryMappings.xml
├── modules.xml
├── vcs.xml
├── Hackboard.iml
└── runConfigurations
│ └── bin_www.xml
├── .vscode
└── settings.json
├── services
├── version.service.js
├── parsePatch.service.js
├── settings.service.js
├── volunteer.service.js
├── env.service.js
├── role.service.js
├── sponsor.service.js
└── database.service.js
├── middlewares
├── validators
│ ├── volunteer.validator.js
│ ├── role.validator.js
│ ├── settings.validator.js
│ ├── routeParam.validator.js
│ ├── search.validator.js
│ ├── team.validator.js
│ ├── travel.validator.js
│ ├── auth.validator.js
│ ├── sponsor.validator.js
│ └── account.validator.js
├── parse-body.middleware.js
├── util.middleware.js
├── role.middleware.js
├── search.middleware.js
└── email.middleware.js
├── Dockerfile
├── apidoc.json
├── .eslintrc
├── ingress.yaml
├── seed
├── settings.seed.js
├── roles.seed.js
└── index.js
├── scripts
├── batch_update_travel.js
├── interest_form_emails.py
└── migrate_email_templates.js
├── .github
├── dependabot.yml
├── ISSUE_TEMPLATE
│ ├── create-route.md
│ └── bug_report.md
└── PULL_REQUEST_TEMPLATE.md
├── models
├── staff.model.js
├── volunteer.model.js
├── passwordResetToken.model.js
├── emailTemplate.model.js
├── roleBinding.model.js
├── settings.model.js
├── team.model.js
├── sponsor.model.js
├── accountConfirmationToken.model.js
├── role.model.js
├── bus.model.js
└── travel.model.js
├── routes
└── index.js
├── README.md
├── controllers
├── role.controller.js
├── search.controller.js
├── settings.controller.js
├── email.controller.js
├── volunteer.controller.js
├── auth.controller.js
├── sponsor.controller.js
└── travel.controller.js
├── service.yaml
├── constants
├── testMongoId.constant.js
└── settings.constant.js
├── LICENSE
├── .gitignore
├── .env.example
├── bin
└── www.js
├── app.json
└── package.json
/.nvmrc:
--------------------------------------------------------------------------------
1 | 20.10.0
2 |
--------------------------------------------------------------------------------
/docs/CNAME:
--------------------------------------------------------------------------------
1 | docs.mchacks.ca
--------------------------------------------------------------------------------
/Procfile:
--------------------------------------------------------------------------------
1 | web: npm run deploy
2 |
--------------------------------------------------------------------------------
/.dockerignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | npm-debug.log
--------------------------------------------------------------------------------
/.eslintignore:
--------------------------------------------------------------------------------
1 | assets/
2 | docs/
3 | node_modules/
4 | package-lock.json
5 |
--------------------------------------------------------------------------------
/.prettierignore:
--------------------------------------------------------------------------------
1 | assets/
2 | docs/
3 | node_modules/
4 | package-lock.json
5 |
--------------------------------------------------------------------------------
/results.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hackmcgill/hackerAPI/HEAD/results.txt
--------------------------------------------------------------------------------
/results2.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hackmcgill/hackerAPI/HEAD/results2.txt
--------------------------------------------------------------------------------
/docs/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hackmcgill/hackerAPI/HEAD/docs/.DS_Store
--------------------------------------------------------------------------------
/tests/testResume.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hackmcgill/hackerAPI/HEAD/tests/testResume.pdf
--------------------------------------------------------------------------------
/docs/api/img/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hackmcgill/hackerAPI/HEAD/docs/api/img/favicon.ico
--------------------------------------------------------------------------------
/assets/email/test.hbs:
--------------------------------------------------------------------------------
1 |
This is used for testing email service. DO NOT REMOVE.{{TEST}}.
link
--------------------------------------------------------------------------------
/docs/_config.yml:
--------------------------------------------------------------------------------
1 | theme: jekyll-theme-cayman
2 | url: https://hackerapi.mchacks.ca
3 | repository: https://github.com/hackmcgill/hackerAPI
4 |
--------------------------------------------------------------------------------
/docs/api/fonts/glyphicons-halflings-regular.eot:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hackmcgill/hackerAPI/HEAD/docs/api/fonts/glyphicons-halflings-regular.eot
--------------------------------------------------------------------------------
/docs/api/fonts/glyphicons-halflings-regular.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hackmcgill/hackerAPI/HEAD/docs/api/fonts/glyphicons-halflings-regular.ttf
--------------------------------------------------------------------------------
/docs/api/fonts/glyphicons-halflings-regular.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hackmcgill/hackerAPI/HEAD/docs/api/fonts/glyphicons-halflings-regular.woff
--------------------------------------------------------------------------------
/docs/api/fonts/glyphicons-halflings-regular.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hackmcgill/hackerAPI/HEAD/docs/api/fonts/glyphicons-halflings-regular.woff2
--------------------------------------------------------------------------------
/.prettierrc:
--------------------------------------------------------------------------------
1 | {
2 | "tabWidth": 4,
3 | "useTabs": false,
4 | "singleQuote": false,
5 | "semi": true,
6 | "arrowParens": "always",
7 | "jsxBracketSameLine": false
8 | }
9 |
--------------------------------------------------------------------------------
/tests/auth.service.spec.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | const dotenv = require("dotenv");
3 | const AuthService = require("../services/auth.service");
4 | const assert = require("chai").assert;
5 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "search.usePCRE2": true,
3 | "editor.formatOnSave": true,
4 | "files.insertFinalNewline": true,
5 | "files.trimFinalNewlines": true,
6 | "editor.tabSize": 4
7 | }
8 |
--------------------------------------------------------------------------------
/services/version.service.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | const { version } = require("../package.json");
3 |
4 | const get = function() {
5 | return version;
6 | };
7 |
8 | module.exports = {
9 | get: get
10 | };
11 |
--------------------------------------------------------------------------------
/.idea/jsLibraryMappings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/middlewares/validators/volunteer.validator.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | const VALIDATOR = require("./validator.helper");
3 |
4 | module.exports = {
5 | newVolunteerValidator: [
6 | VALIDATOR.mongoIdValidator("body", "accountId", false)
7 | ]
8 | };
9 |
--------------------------------------------------------------------------------
/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM node:carbon
2 |
3 | ENV PORT 8080
4 |
5 | WORKDIR /usr/src/app
6 |
7 | COPY package*.json ./
8 | ADD VERSION .
9 |
10 | RUN npm install -g n
11 | RUN n 9.9.0
12 | RUN npm install npm -g
13 | RUN npm install
14 |
15 | COPY . .
16 |
17 | EXPOSE 8080
18 | CMD [ "npm", "run", "debug" ]
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/apidoc.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "hackerAPI",
3 | "version": "0.0.8",
4 | "defaultVersion": "0.0.8",
5 | "description": "Documentation for the API used for mchacks",
6 | "title": "hackerAPI documentation",
7 | "url": "https://api.mchacks.ca/api",
8 | "sampleUrl": "https://api.mchacks.ca/api"
9 | }
--------------------------------------------------------------------------------
/.eslintrc:
--------------------------------------------------------------------------------
1 | {
2 | "env": {
3 | "browser": true,
4 | "es6": true,
5 | "node": true,
6 | "mocha": true
7 | },
8 | "parserOptions": {
9 | "ecmaVersion": 2017,
10 | "sourceType": "module"
11 | },
12 | "plugins": [
13 | "prettier"
14 | ],
15 | "extends": [
16 | "eslint:recommended",
17 | "prettier"
18 | ]
19 | }
20 |
--------------------------------------------------------------------------------
/middlewares/validators/role.validator.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | const VALIDATOR = require("./validator.helper");
3 | const Constants = require("../../constants/general.constant");
4 |
5 | module.exports = {
6 | newRoleValidator: [
7 | VALIDATOR.alphaValidator("body", "name", false),
8 | VALIDATOR.routesValidator("body", "routes", false)
9 | ]
10 | };
11 |
--------------------------------------------------------------------------------
/ingress.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: extensions/v1beta1
2 | kind: Ingress
3 | metadata:
4 | name: hackboard-ingress
5 | annotations:
6 | kubernetes.io/ingress.global-static-ip-name: hackboard-ingress-static-ip
7 | spec:
8 | # tls:
9 | # - secretName: hackboard-secret
10 | # rules:
11 | # - http:
12 | # paths:
13 | # - path: /*
14 | backend:
15 | serviceName: hackboard-service
16 | servicePort: 80
--------------------------------------------------------------------------------
/docs/api/api_project.json:
--------------------------------------------------------------------------------
1 | {
"name": "hackerAPI",
"version": "0.0.8",
"description": "Documentation for the API used for mchacks",
"defaultVersion": "0.0.8",
"title": "hackerAPI documentation",
"url": "https://api.mchacks.ca/api",
"sampleUrl": "https://api.mchacks.ca/api",
"apidoc": "0.3.0",
"generator": {
"name": "apidoc",
"time": "2020-11-01T22:01:33.009Z",
"url": "http://apidocjs.com",
"version": "0.17.7"
}
}
2 |
--------------------------------------------------------------------------------
/docs/api/api_project.js:
--------------------------------------------------------------------------------
1 | define({
"name": "hackerAPI",
"version": "0.0.8",
"description": "Documentation for the API used for mchacks",
"defaultVersion": "0.0.8",
"title": "hackerAPI documentation",
"url": "https://api.mchacks.ca/api",
"sampleUrl": "https://api.mchacks.ca/api",
"apidoc": "0.3.0",
"generator": {
"name": "apidoc",
"time": "2020-11-01T22:01:33.009Z",
"url": "http://apidocjs.com",
"version": "0.17.7"
}
});
2 |
--------------------------------------------------------------------------------
/middlewares/validators/settings.validator.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | const VALIDATOR = require("./validator.helper");
3 |
4 | module.exports = {
5 | createSettingsValidator: [
6 | VALIDATOR.dateValidator("body", "openTime", true),
7 | VALIDATOR.dateValidator("body", "closeTime", true),
8 | VALIDATOR.dateValidator("body", "confirmTime", true),
9 | VALIDATOR.booleanValidator("body", "isRemote", true)
10 | ]
11 | };
12 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/middlewares/validators/routeParam.validator.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | const VALIDATOR = require("./validator.helper");
3 | const Constants = require("../../constants/general.constant");
4 |
5 | module.exports = {
6 | idValidator: [VALIDATOR.mongoIdValidator("param", "id", false)],
7 |
8 | hackeridValidator: [VALIDATOR.mongoIdValidator("param", "hackerId", false)],
9 |
10 | emailValidator: [
11 | VALIDATOR.regexValidator("param", "email", false, Constants.EMAIL_REGEX)
12 | ]
13 | };
14 |
--------------------------------------------------------------------------------
/.idea/Hackboard.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/seed/settings.seed.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | const Settings = require("../models/settings.model");
3 |
4 | /**
5 | * Drops all elements in Role
6 | */
7 | function drop() {
8 | return Settings.deleteMany({});
9 | }
10 |
11 | /**
12 | * Stores all of the roles in the db
13 | * @param {Settings} setting the setting that we want to seed
14 | */
15 | function store(setting) {
16 | return Settings.collection.insertOne(new Settings(setting));
17 | }
18 |
19 | module.exports = {
20 | store: store,
21 | drop: drop
22 | };
23 |
--------------------------------------------------------------------------------
/.idea/runConfigurations/bin_www.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/scripts/batch_update_travel.js:
--------------------------------------------------------------------------------
1 | // use hackboard-dev; // Change to product for actual update
2 |
3 | // Create a travel document for every hacker document
4 | db.hackers.find().forEach(hacker => {
5 | let request = 0;
6 | if (hacker.application && hacker.application.accommodation && hacker.application.accommodation.travel) {
7 | request = hacker.application.accommodation.travel;
8 | }
9 | db.travels.insert({ hackerId: hacker._id, accountId: hacker.accountId, request: request, offer: 0, status: "None" })
10 | });
11 |
--------------------------------------------------------------------------------
/.github/dependabot.yml:
--------------------------------------------------------------------------------
1 | # To get started with Dependabot version updates, you'll need to specify which
2 | # package ecosystems to update and where the package manifests are located.
3 | # Please see the documentation for all configuration options:
4 | # https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5 |
6 | version: 2
7 | updates:
8 | - package-ecosystem: "npm" # See documentation for possible values
9 | directory: "/" # Location of package manifests
10 | schedule:
11 | interval: "weekly"
12 |
--------------------------------------------------------------------------------
/models/staff.model.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | const mongoose = require("mongoose");
3 | //describes the data type
4 | const StaffSchema = new mongoose.Schema({
5 | accountId: {
6 | type: mongoose.Schema.Types.ObjectId,
7 | ref: "Account",
8 | required: true
9 | }
10 | });
11 |
12 | StaffSchema.methods.toJSON = function(options) {
13 | const ss = this.toObject(options);
14 | delete ss.__v;
15 | ss.id = ss._id;
16 | delete ss._id;
17 | return ss;
18 | };
19 | //export the model
20 | module.exports = mongoose.model("Staff", StaffSchema);
21 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/create-route.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Create route
3 | about: Use when proposing a new route
4 |
5 | ---
6 |
7 | ### Route name
8 |
9 | ### Uri
10 |
11 | ### Http method
12 |
13 | ### Short description
14 |
15 | ### Parameters
16 |
17 | #### Body
18 | | Attribute name | Type |
19 | |----------------|------|
20 |
21 | #### Header
22 |
23 | | Attribute name | Type |
24 | |----------------|------|
25 |
26 | #### Query
27 |
28 | | Attribute name | Type |
29 | |----------------|------|
30 |
31 | #### Authentication required
32 |
33 | #### Authorization required
34 |
--------------------------------------------------------------------------------
/routes/index.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | const express = require("express");
3 | const versionService = require("../services/version.service");
4 | const router = new express.Router();
5 |
6 | /* GET home page. */
7 | /**
8 | * @api {get} / version
9 | * @apiVersion 0.0.8
10 | * @apiName index
11 | * @apiGroup Index
12 | * @apiPermission public
13 | */
14 | router.get("/", function(req, res) {
15 | const VERSION = versionService.get();
16 | res.status(200).send({
17 | name: "hackerAPI",
18 | version: VERSION
19 | });
20 | });
21 |
22 | module.exports = router;
23 |
--------------------------------------------------------------------------------
/models/volunteer.model.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | const mongoose = require("mongoose");
3 | //describes the data type
4 | const VolunteerSchema = new mongoose.Schema({
5 | accountId: {
6 | type: mongoose.Schema.Types.ObjectId,
7 | ref: "Account",
8 | required: true
9 | }
10 | });
11 |
12 | VolunteerSchema.methods.toJSON = function(options) {
13 | const vs = this.toObject(options);
14 | delete vs.__v;
15 | vs.id = vs._id;
16 | delete vs._id;
17 | return vs;
18 | };
19 | //export the model
20 | module.exports = mongoose.model("Volunteer", VolunteerSchema);
21 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # hackerAPI
2 |
3 | API for registration, live-site
4 |
5 | ## Builds
6 |
7 | ### Master
8 |
9 | [](https://travis-ci.org/hackmcgill/hackerAPI)
10 |
11 | ### Develop
12 |
13 | [](https://travis-ci.org/hackmcgill/hackerAPI)
14 |
15 | ## How to use and contribute
16 |
17 | See documentation here:
18 |
19 | ## Deploy
20 |
21 | [](https://heroku.com/deploy)
22 |
--------------------------------------------------------------------------------
/controllers/role.controller.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | const Success = require("../constants/success.constant");
4 |
5 | /**
6 | * @function createdRole
7 | * @param {{body: {role: Object}}} req
8 | * @param {*} res
9 | * @return {JSON} Success status and role object
10 | * @description Returns the JSON of role object located in req.body.role
11 | */
12 | function createdRole(req, res) {
13 | return res.status(200).json({
14 | message: Success.ROLE_CREATE,
15 | data: req.body.role.toJSON()
16 | });
17 | }
18 |
19 | module.exports = {
20 | createdRole: createdRole
21 | };
22 |
--------------------------------------------------------------------------------
/services/parsePatch.service.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | const mongoose = require("mongoose");
3 |
4 | module.exports = {
5 | parsePatch: function(req, model, done) {
6 | setMatchingAttributes(model).then(() => {
7 | done();
8 | });
9 | }
10 | };
11 |
12 | async function setMatchingAttributes(model) {
13 | let modelDetails = {};
14 | for (const val in req.body) {
15 | if (model.schema.paths.hasOwnProperty(val)) {
16 | modelDetails[val] = req.body[val];
17 | delete req.body[val];
18 | }
19 | }
20 | req.body.modelDetails = modelDetails;
21 | }
22 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/bug_report.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Bug report
3 | about: Create a report to help us improve
4 |
5 | ---
6 |
7 | **Describe the bug**
8 | A clear and concise description of what the bug is.
9 |
10 | **To Reproduce**
11 | Steps to reproduce the behavior:
12 | 1. Go to '...'
13 | 2. Click on '....'
14 | 3. Scroll down to '....'
15 | 4. See error
16 |
17 | **Expected behavior**
18 | A clear and concise description of what you expected to happen.
19 |
20 | **Screenshots**
21 | If applicable, add screenshots to help explain your problem.
22 |
23 | **Additional context**
24 | Add any other context about the problem here.
25 |
--------------------------------------------------------------------------------
/middlewares/validators/search.validator.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | const VALIDATOR = require("./validator.helper");
3 |
4 | module.exports = {
5 | searchQueryValidator: [
6 | VALIDATOR.searchModelValidator("query", "model", false),
7 | VALIDATOR.alphaValidator("query", "sort", true),
8 | VALIDATOR.integerValidator("query", "page", true, 0),
9 | VALIDATOR.integerValidator("query", "limit", true, 0, 1000),
10 | VALIDATOR.searchSortValidator("query", "sort_by"),
11 | VALIDATOR.booleanValidator("query", "expand", true),
12 | VALIDATOR.searchValidator("query", "q")
13 | ]
14 | };
15 |
--------------------------------------------------------------------------------
/models/passwordResetToken.model.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | const mongoose = require("mongoose");
3 | const passwordResetSchema = new mongoose.Schema({
4 | accountId: {
5 | type: mongoose.Schema.Types.ObjectId,
6 | required: true,
7 | ref: "Account"
8 | },
9 | created: {
10 | type: Date,
11 | required: true
12 | }
13 | });
14 |
15 | passwordResetSchema.methods.toJSON = function(options) {
16 | const prs = this.toObject(options);
17 | delete prs.__v;
18 | prs.id = prs._id;
19 | delete prs._id;
20 | return prs;
21 | };
22 |
23 | module.exports = mongoose.model("PasswordResetToken", passwordResetSchema);
24 |
--------------------------------------------------------------------------------
/docs/api/vendor/prettify/prettify.css:
--------------------------------------------------------------------------------
1 | .pln{color:#000}@media screen{.str{color:#080}.kwd{color:#008}.com{color:#800}.typ{color:#606}.lit{color:#066}.pun,.opn,.clo{color:#660}.tag{color:#008}.atn{color:#606}.atv{color:#080}.dec,.var{color:#606}.fun{color:red}}@media print,projection{.str{color:#060}.kwd{color:#006;font-weight:bold}.com{color:#600;font-style:italic}.typ{color:#404;font-weight:bold}.lit{color:#044}.pun,.opn,.clo{color:#440}.tag{color:#006;font-weight:bold}.atn{color:#404}.atv{color:#060}}pre.prettyprint{padding:2px;border:1px solid #888}ol.linenums{margin-top:0;margin-bottom:0}li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8{list-style-type:none}li.L1,li.L3,li.L5,li.L7,li.L9{background:#eee}
--------------------------------------------------------------------------------
/models/emailTemplate.model.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | const mongoose = require("mongoose");
3 |
4 | // describes the data type
5 | const EmailTemplateSchema = new mongoose.Schema({
6 | name: {
7 | type: String,
8 | required: true
9 | },
10 | content: {
11 | type: String,
12 | required: true
13 | }
14 | });
15 |
16 | EmailTemplateSchema.methods.toJSON = function (options) {
17 | const ets = this.toObject(options);
18 | delete ets.__v;
19 | ets.id = ets._id;
20 | delete ets._id;
21 | return ets;
22 | };
23 |
24 | // export the model
25 | module.exports = mongoose.model(
26 | "EmailTemplate",
27 | EmailTemplateSchema
28 | );
29 |
--------------------------------------------------------------------------------
/seed/roles.seed.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | const Role = require("../models/role.model");
3 |
4 | /**
5 | * Drops all elements in Role
6 | */
7 | function dropAll() {
8 | return Role.deleteMany({});
9 | }
10 |
11 | /**
12 | * Stores all of the roles in the db
13 | * @param {role[]} attributes all attributes
14 | */
15 | function storeAll(attributes) {
16 | const roleDocs = [];
17 | const roleNames = [];
18 | attributes.forEach((attribute) => {
19 | roleDocs.push(new Role(attribute));
20 | roleNames.push(attribute.name);
21 | });
22 | return Role.collection.insertMany(roleDocs);
23 | }
24 |
25 | module.exports = {
26 | storeAll: storeAll,
27 | dropAll: dropAll
28 | };
29 |
--------------------------------------------------------------------------------
/controllers/search.controller.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | const Services = {
3 | Search: require("../services/search.service"),
4 | Logger: require("../services/logger.service")
5 | };
6 | const Util = require("../middlewares/util.middleware");
7 | const Success = require("../constants/success.constant");
8 |
9 | async function searchResults(req, res) {
10 | let results = req.body.results;
11 | let message;
12 | if (results.length < 1) {
13 | message = Success.SEARCH_NO_RESULTS;
14 | results = {};
15 | } else {
16 | message = Success.SEARCH_QUERY;
17 | }
18 | return res.status(200).json({
19 | message: message,
20 | data: results
21 | });
22 | }
23 |
24 | module.exports = {
25 | searchResults: Util.asyncMiddleware(searchResults)
26 | };
27 |
--------------------------------------------------------------------------------
/tests/util/auth.test.util.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | module.exports = {
3 | login: login
4 | };
5 | /**
6 | * Use this function to log in a user before executing a test that requires certain permissions.
7 | * @param {ChaiHttp.Agent} agent
8 | * @param {{email:string,password:string}} credentials
9 | * @param {(err?:any)=>void} callback
10 | */
11 | function login(agent, credentials, callback) {
12 | agent
13 | .post("/api/auth/login")
14 | .type("application/json")
15 | .send({
16 | email: credentials.email,
17 | password: credentials.password
18 | })
19 | .end((err, res) => {
20 | if (err) {
21 | callback(err);
22 | } else {
23 | callback();
24 | }
25 | });
26 | }
27 |
--------------------------------------------------------------------------------
/middlewares/parse-body.middleware.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | const { validationResult, matchedData } = require("express-validator");
3 | const Constants = {
4 | Error: require("../constants/error.constant")
5 | };
6 |
7 | module.exports = {
8 | middleware: middleware
9 | };
10 |
11 | /**
12 | * Moves matched data to req.body, and fails if any validation fails.
13 | * @param {*} req
14 | * @param {*} res
15 | * @param {(err?)=>void} next
16 | */
17 | function middleware(req, res, next) {
18 | const errors = validationResult(req);
19 | if (!errors.isEmpty()) {
20 | return next({
21 | status: 422,
22 | message: Constants.Error.VALIDATION_422_MESSAGE,
23 | data: errors.mapped()
24 | });
25 | }
26 | req.body = matchedData(req);
27 | return next();
28 | }
29 |
--------------------------------------------------------------------------------
/models/roleBinding.model.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | const mongoose = require("mongoose");
3 | //describes the data type
4 | const roleBinding = new mongoose.Schema({
5 | accountId: {
6 | type: mongoose.Schema.Types.ObjectId,
7 | ref: "Account",
8 | required: true,
9 | unique: true
10 | },
11 | roles: {
12 | type: [
13 | {
14 | type: mongoose.Schema.Types.ObjectId,
15 | ref: "Role",
16 | required: true
17 | }
18 | ]
19 | }
20 | });
21 |
22 | roleBinding.methods.toJSON = function(options) {
23 | const rb = this.toObject(options);
24 | delete rb.__v;
25 | rb.id = rb._id;
26 | delete rb._id;
27 | return rb;
28 | };
29 | //export the model
30 | module.exports = mongoose.model("RoleBinding", roleBinding);
31 |
--------------------------------------------------------------------------------
/service.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: v1
2 | kind: Service
3 | metadata:
4 | name: hackboard-service
5 | labels:
6 | run: hackboard # because that's the label on the deployment (not sure what labels do tho)
7 | # annotations:
8 | # cloud.google.com/app-protocols: '{"hackboard-https-port":"HTTPS","hackboard-http-port":"HTTP"}'
9 | spec:
10 | selector:
11 | run: hackboard # because that's the selector on the deployment (not sure what labels do tho)
12 | ports:
13 | - name: http #hackboard-http-port
14 | protocol: TCP
15 | port: 80
16 | targetPort: 8080 # because the deployment port is 80/TCP
17 | # - name: hackboard-https-port
18 | # protocol: TCP
19 | # port: 443
20 | type: LoadBalancer
21 |
22 | # endpoint of service same as ip of pods -> means communication between service and pod (direction?)
23 | # can talk to this service with cluster-ip:port from any other node on cluster
--------------------------------------------------------------------------------
/docs/api/vendor/prettify/lang-rd.js:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | Copyright (C) 2012 Jeffrey Arnold
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 | */
17 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\r \xA0]+/,null,"\t\n\r \u00a0"],["com",/^%[^\r\n]*/,null,"%"]],[["lit",/^\\(?:cr|l?dots|R|tab)\b/],["kwd",/^\\[a-zA-Z@]+/],["kwd",/^#(?:ifn?def|endif)/],["pln",/^\\[{}]/],["pun",/^[{}()\[\]]+/]]),["Rd","rd"]);
18 |
--------------------------------------------------------------------------------
/docs/api/vendor/prettify/lang-latex.js:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | Copyright (C) 2011 Martin S.
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 | */
17 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\r \xA0]+/,null,"\t\n\r \u00a0"],["com",/^%[^\r\n]*/,null,"%"]],[["kwd",/^\\[a-zA-Z@]+/],["kwd",/^\\./],["typ",/^[$&]/],["lit",/[+-]?(?:\.\d+|\d+(?:\.\d*)?)(cm|em|ex|in|pc|pt|bp|mm)/i],["pun",/^[{}()\[\]=]+/]]),["latex","tex"]);
18 |
--------------------------------------------------------------------------------
/docs/api/vendor/prettify/lang-tex.js:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | Copyright (C) 2011 Martin S.
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 | */
17 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\r \xA0]+/,null,"\t\n\r \u00a0"],["com",/^%[^\r\n]*/,null,"%"]],[["kwd",/^\\[a-zA-Z@]+/],["kwd",/^\\./],["typ",/^[$&]/],["lit",/[+-]?(?:\.\d+|\d+(?:\.\d*)?)(cm|em|ex|in|pc|pt|bp|mm)/i],["pun",/^[{}()\[\]=]+/]]),["latex","tex"]);
18 |
--------------------------------------------------------------------------------
/docs/api/vendor/prettify/lang-go.js:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | Copyright (C) 2010 Google Inc.
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 | */
17 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\r \xA0]+/,null,"\t\n\r \u00a0"],["pln",/^(?:\"(?:[^\"\\]|\\[\s\S])*(?:\"|$)|\'(?:[^\'\\]|\\[\s\S])+(?:\'|$)|`[^`]*(?:`|$))/,null,"\"'"]],[["com",/^(?:\/\/[^\r\n]*|\/\*[\s\S]*?\*\/)/],["pln",/^(?:[^\/\"\'`]|\/(?![\/\*]))+/i]]),["go"]);
18 |
--------------------------------------------------------------------------------
/models/settings.model.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | const mongoose = require("mongoose");
3 | //describes the data type
4 | const settings = new mongoose.Schema({
5 | openTime: {
6 | type: Date,
7 | default: Date.now() + 2628000000 // One month from now.
8 | },
9 | closeTime: {
10 | type: Date,
11 | default: Date.now() + 31540000000 + 2628000000 // One year and 1 month from now.
12 | },
13 | confirmTime: {
14 | type: Date,
15 | default: Date.now() + 31540000000 + 2628000000 + 2628000000 // 1 year and 2 months from now.
16 | },
17 | isRemote: {
18 | type: Boolean,
19 | default: false
20 | }
21 | });
22 |
23 | settings.methods.toJSON = function(options) {
24 | const ss = this.toObject(options);
25 | delete ss.__v;
26 | ss.id = ss._id;
27 | delete ss._id;
28 | return ss;
29 | };
30 | //export the model
31 | module.exports = mongoose.model("Settings", settings);
32 |
--------------------------------------------------------------------------------
/docs/api/vendor/prettify/lang-proto.js:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | Copyright (C) 2006 Google Inc.
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 | */
17 | PR.registerLangHandler(PR.sourceDecorator({keywords:"bytes,default,double,enum,extend,extensions,false,group,import,max,message,option,optional,package,repeated,required,returns,rpc,service,syntax,to,true",types:/^(bool|(double|s?fixed|[su]?int)(32|64)|float|string)\b/,cStyleComments:!0}),["proto"]);
18 |
--------------------------------------------------------------------------------
/middlewares/validators/team.validator.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | const VALIDATOR = require("./validator.helper");
3 | const Constants = require("../../constants/general.constant");
4 |
5 | module.exports = {
6 | newTeamValidator: [
7 | VALIDATOR.stringValidator("body", "name", false),
8 | VALIDATOR.regexValidator(
9 | "body",
10 | "devpostURL",
11 | true,
12 | Constants.DEVPOST_REGEX
13 | ),
14 | VALIDATOR.stringValidator("body", "projectName", true)
15 | ],
16 |
17 | joinTeamValidator: [VALIDATOR.stringValidator("body", "name", false)],
18 |
19 | patchTeamValidator: [
20 | VALIDATOR.stringValidator("body", "name", true),
21 | VALIDATOR.regexValidator(
22 | "body",
23 | "devpostURL",
24 | true,
25 | Constants.DEVPOST_REGEX
26 | ),
27 | VALIDATOR.stringValidator("body", "projectName", true)
28 | ]
29 | };
30 |
--------------------------------------------------------------------------------
/constants/testMongoId.constant.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | const mongoose = require("mongoose");
4 |
5 | const team1Id = new mongoose.Types.ObjectId();
6 | const team2Id = new mongoose.Types.ObjectId();
7 | const team3Id = new mongoose.Types.ObjectId();
8 |
9 | const hackerAId = new mongoose.Types.ObjectId();
10 | const hackerBId = new mongoose.Types.ObjectId();
11 | const hackerCId = new mongoose.Types.ObjectId();
12 | const hackerDId = new mongoose.Types.ObjectId();
13 | const hackerEId = new mongoose.Types.ObjectId();
14 | const hackerFId = new mongoose.Types.ObjectId();
15 | const hackerGId = new mongoose.Types.ObjectId();
16 | const hackerHId = new mongoose.Types.ObjectId();
17 |
18 | module.exports = {
19 | team1Id: team1Id,
20 | team2Id: team2Id,
21 | team3Id: team3Id,
22 | hackerAId: hackerAId,
23 | hackerBId: hackerBId,
24 | hackerCId: hackerCId,
25 | hackerDId: hackerDId,
26 | hackerEId: hackerEId,
27 | hackerFId: hackerFId,
28 | hackerGId: hackerGId,
29 | hackerHId: hackerHId
30 | };
31 |
--------------------------------------------------------------------------------
/docs/deploy.md:
--------------------------------------------------------------------------------
1 | # How to deploy
2 |
3 | This application can be most easily deployed via Heroku. A "deploy to heroku" button is available in the `README.md` file. Once in Heroku, several environment variables will need to be filled out including:
4 |
5 | ```plain
6 | ##front-end server
7 | FRONTEND_ADDRESS_DEPLOY=
8 |
9 | #The info for the deployment database
10 | DB_ADDRESS_DEPLOY=
11 | DB_USER_DEPLOY=
12 | DB_PASS_DEPLOY=
13 |
14 | #Secret key for the cookies
15 | COOKIE_SECRET=
16 |
17 | #Secret key for the invite tokens
18 | JWT_INVITE_SECRET=
19 |
20 | #Reset password secret
21 | JWT_RESET_PWD_SECRET=
22 |
23 | #Secret key fo account confirmation token
24 | JWT_CONFIRM_ACC_SECRET=
25 |
26 | #mail server information
27 | SENDGRID_API_KEY=
28 | NO_REPLY_EMAIL=
29 |
30 | #Google Cloud Storage information
31 | BUCKET_NAME=
32 | TYPE=
33 | PROJECT_ID=-api
34 | PRIVATE_KEY_ID=
35 | PRIVATE_KEY=
36 | CLIENT_EMAIL=
37 | CLIENT_ID=
38 | AUTH_URI=
39 | TOKEN_URI=
40 | AUTH_PROVIDER_X509_CERT_URL=
41 | CLIENT_X509_CERT_URL=
42 | ```
43 |
--------------------------------------------------------------------------------
/docs/api/vendor/prettify/lang-ll.js:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | Copyright (C) 2013 Nikhil Dabas
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 | */
17 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\r \xA0]+/,null,"\t\n\r \u00a0"],["str",/^!?\"(?:[^\"\\]|\\[\s\S])*(?:\"|$)/,null,'"'],["com",/^;[^\r\n]*/,null,";"]],[["pln",/^[%@!](?:[-a-zA-Z$._][-a-zA-Z$._0-9]*|\d+)/],["kwd",/^[A-Za-z_][0-9A-Za-z_]*/,null],["lit",/^\d+\.\d+/],["lit",/^(?:\d+|0[xX][a-fA-F0-9]+)/],["pun",/^[()\[\]{},=*<>:]|\.\.\.$/]]),["llvm","ll"]);
18 |
--------------------------------------------------------------------------------
/docs/api/vendor/prettify/lang-llvm.js:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | Copyright (C) 2013 Nikhil Dabas
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 | */
17 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\r \xA0]+/,null,"\t\n\r \u00a0"],["str",/^!?\"(?:[^\"\\]|\\[\s\S])*(?:\"|$)/,null,'"'],["com",/^;[^\r\n]*/,null,";"]],[["pln",/^[%@!](?:[-a-zA-Z$._][-a-zA-Z$._0-9]*|\d+)/],["kwd",/^[A-Za-z_][0-9A-Za-z_]*/,null],["lit",/^\d+\.\d+/],["lit",/^(?:\d+|0[xX][a-fA-F0-9]+)/],["pun",/^[()\[\]{},=*<>:]|\.\.\.$/]]),["llvm","ll"]);
18 |
--------------------------------------------------------------------------------
/middlewares/validators/travel.validator.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | const VALIDATOR = require("./validator.helper");
3 | const Constants = require("../../constants/general.constant");
4 |
5 | module.exports = {
6 | newTravelValidator: [
7 | VALIDATOR.integerValidator("body", "request", false, 0, 3000),
8 | VALIDATOR.jwtValidator(
9 | "header",
10 | "token",
11 | process.env.JWT_CONFIRM_ACC_SECRET,
12 | true
13 | )
14 | ],
15 | updateTravelValidator: [
16 | VALIDATOR.integerValidator("body", "request", false, 0, 3000)
17 | ],
18 | updateStatusValidator: [
19 | VALIDATOR.enumValidator(
20 | "body",
21 | "status",
22 | Constants.TRAVEL_STATUSES,
23 | false
24 | )
25 | ],
26 | updateOfferValidator: [
27 | VALIDATOR.integerValidator(
28 | "body",
29 | "offer",
30 | false,
31 | 0,
32 | 3000
33 | )
34 | ]
35 | };
36 |
--------------------------------------------------------------------------------
/docs/api/vendor/prettify/lang-yaml.js:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | Copyright (C) 2015 ribrdb @ code.google.com
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 | */
17 | PR.registerLangHandler(PR.createSimpleLexer([["pun",/^[:|>?]+/,null,":|>?"],["dec",/^%(?:YAML|TAG)[^#\r\n]+/,null,"%"],["typ",/^[&]\S+/,null,"&"],["typ",/^!\S*/,null,"!"],["str",/^"(?:[^\\"]|\\.)*(?:"|$)/,null,'"'],["str",/^'(?:[^']|'')*(?:'|$)/,null,"'"],["com",/^#[^\r\n]*/,null,"#"],["pln",/^\s+/,null," \t\r\n"]],[["dec",/^(?:---|\.\.\.)(?:[\r\n]|$)/],["pun",/^-/],["kwd",/^[\w-]+:[ \r\n]/],["pln",
18 | /^\w+/]]),["yaml","yml"]);
19 |
--------------------------------------------------------------------------------
/docs/api/vendor/prettify/lang-yml.js:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | Copyright (C) 2015 ribrdb @ code.google.com
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 | */
17 | PR.registerLangHandler(PR.createSimpleLexer([["pun",/^[:|>?]+/,null,":|>?"],["dec",/^%(?:YAML|TAG)[^#\r\n]+/,null,"%"],["typ",/^[&]\S+/,null,"&"],["typ",/^!\S*/,null,"!"],["str",/^"(?:[^\\"]|\\.)*(?:"|$)/,null,'"'],["str",/^'(?:[^']|'')*(?:'|$)/,null,"'"],["com",/^#[^\r\n]*/,null,"#"],["pln",/^\s+/,null," \t\r\n"]],[["dec",/^(?:---|\.\.\.)(?:[\r\n]|$)/],["pun",/^-/],["kwd",/^[\w-]+:[ \r\n]/],["pln",
18 | /^\w+/]]),["yaml","yml"]);
19 |
--------------------------------------------------------------------------------
/middlewares/util.middleware.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | const multer = require("multer");
3 | //Set up multer middleware
4 | const m = multer({
5 | storage: multer.memoryStorage(),
6 | limits: {
7 | fileSize: 4000000 //4mb
8 | },
9 | fileFilter: function(req, file, cb) {
10 | if (file.mimetype !== "application/pdf") {
11 | cb(null, false);
12 | } else {
13 | cb(null, true);
14 | }
15 | }
16 | });
17 |
18 | /**
19 | * Wrapper function for all asynchronous middleware, aka middleware that returns promises.
20 | * @param {(req,res,next:(err?:any)=>void)=>any} fn The function that is asynchronous
21 | * @returns {(req,res,next:(err?:any)=>void)=>any} Another middleware that, when invoked, will attempt to resolve fn. If there is an error,
22 | * then it will pass the error to 'next' function.
23 | */
24 | function asyncMiddleware(fn) {
25 | return (req, res, next) => {
26 | Promise.resolve(fn(req, res, next)).catch(next);
27 | };
28 | }
29 | module.exports = {
30 | asyncMiddleware: asyncMiddleware,
31 | Multer: m
32 | };
33 |
--------------------------------------------------------------------------------
/models/team.model.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | const mongoose = require("mongoose");
3 | const Constants = require("../constants/general.constant");
4 |
5 | //describes the data type
6 | const TeamSchema = new mongoose.Schema({
7 | name: {
8 | type: String,
9 | required: true,
10 | unique: true
11 | },
12 | members: {
13 | type: [
14 | {
15 | type: mongoose.Schema.Types.ObjectId,
16 | ref: "Hacker"
17 | }
18 | ],
19 | validate: [validateTeamSize, "{PATH} exceeds the limit"]
20 | },
21 | devpostURL: {
22 | type: String,
23 | default: undefined
24 | },
25 | projectName: String
26 | });
27 |
28 | function validateTeamSize(membersArr) {
29 | return membersArr.length <= Constants.MAX_TEAM_SIZE;
30 | }
31 |
32 | TeamSchema.methods.toJSON = function(options) {
33 | const ts = this.toObject(options);
34 | delete ts.__v;
35 | ts.id = ts._id;
36 | delete ts._id;
37 | return ts;
38 | };
39 | //export the model
40 | module.exports = mongoose.model("Team", TeamSchema);
41 |
--------------------------------------------------------------------------------
/middlewares/validators/auth.validator.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | const VALIDATOR = require("./validator.helper");
3 | const Constants = require("../../constants/general.constant");
4 |
5 | module.exports = {
6 | ForgotPasswordValidator: [
7 | VALIDATOR.regexValidator("body", "email", false, Constants.EMAIL_REGEX)
8 | ],
9 | ChangePasswordValidator: [
10 | VALIDATOR.passwordValidator("body", "oldPassword", false),
11 | VALIDATOR.passwordValidator("body", "newPassword", false)
12 | ],
13 | ResetPasswordValidator: [
14 | VALIDATOR.passwordValidator("body", "password", false),
15 | //The json web token is provided via the header with param "Authentication".
16 | VALIDATOR.jwtValidator(
17 | "header",
18 | "X-Reset-Token",
19 | process.env.JWT_RESET_PWD_SECRET,
20 | false
21 | )
22 | ],
23 | accountConfirmationValidator: [
24 | VALIDATOR.jwtValidator(
25 | "param",
26 | "token",
27 | process.env.JWT_CONFIRM_ACC_SECRET,
28 | false
29 | )
30 | ]
31 | };
32 |
--------------------------------------------------------------------------------
/docs/api/locales/zh.js:
--------------------------------------------------------------------------------
1 | define({
2 | zh: {
3 | 'Allowed values:' : '允許值:',
4 | 'Compare all with predecessor': '預先比較所有',
5 | 'compare changes to:' : '比較變更:',
6 | 'compared to' : '對比',
7 | 'Default value:' : '默認值:',
8 | 'Description' : '描述',
9 | 'Field' : '字段',
10 | 'General' : '概括',
11 | 'Generated with' : '生成工具',
12 | 'Name' : '名稱',
13 | 'No response values.' : '無對應資料.',
14 | 'optional' : '選項',
15 | 'Parameter' : '參數',
16 | 'Permission:' : '允許:',
17 | 'Response' : '回應',
18 | 'Send' : '發送',
19 | 'Send a Sample Request' : '發送試用需求',
20 | 'show up to version:' : '顯示到版本:',
21 | 'Size range:' : '尺寸範圍:',
22 | 'Type' : '類型',
23 | 'url' : '網址'
24 | }
25 | });
26 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2018 HackMcGill
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/controllers/settings.controller.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | const Success = require("../constants/success.constant");
4 |
5 | /**
6 | * @function gotSettings
7 | * @param {{body: {settingsDetails: Object}}} req
8 | * @param {*} res
9 | * @return {JSON} Success status and settings object
10 | * @description Returns the JSON of settings object located in req.body.settingsDetails
11 | */
12 | function gotSettings(req, res) {
13 | return res.status(200).json({
14 | message: Success.SETTINGS_GET,
15 | data: req.body.settingsDetails.toJSON()
16 | });
17 | }
18 |
19 | /**
20 | * @function patchedSettings
21 | * @param {{body: {settingsDetails: Object}}} req
22 | * @param {*} res
23 | * @return {JSON} Success status and settings object
24 | * @description Returns the JSON of settings object located in req.body.settingsDetails
25 | */
26 | function patchedSettings(req, res) {
27 | return res.status(200).json({
28 | message: Success.SETTINGS_PATCH,
29 | data: req.body.settingsDetails
30 | });
31 | }
32 |
33 | module.exports = {
34 | gotSettings: gotSettings,
35 | patchedSettings: patchedSettings
36 | };
37 |
--------------------------------------------------------------------------------
/docs/api/locales/zh_cn.js:
--------------------------------------------------------------------------------
1 | define({
2 | 'zh_cn': {
3 | 'Allowed values:' : '允许值:',
4 | 'Compare all with predecessor': '与所有较早的比较',
5 | 'compare changes to:' : '将当前版本与指定版本比较:',
6 | 'compared to' : '相比于',
7 | 'Default value:' : '默认值:',
8 | 'Description' : '描述',
9 | 'Field' : '字段',
10 | 'General' : '概要',
11 | 'Generated with' : '基于',
12 | 'Name' : '名称',
13 | 'No response values.' : '无返回值.',
14 | 'optional' : '可选',
15 | 'Parameter' : '参数',
16 | 'Permission:' : '权限:',
17 | 'Response' : '返回',
18 | 'Send' : '发送',
19 | 'Send a Sample Request' : '发送示例请求',
20 | 'show up to version:' : '显示到指定版本:',
21 | 'Size range:' : '取值范围:',
22 | 'Type' : '类型',
23 | 'url' : '网址'
24 | }
25 | });
26 |
--------------------------------------------------------------------------------
/models/sponsor.model.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | const mongoose = require("mongoose");
3 | //describes the data type
4 | const SponsorSchema = new mongoose.Schema({
5 | accountId: {
6 | type: mongoose.Schema.Types.ObjectId,
7 | ref: "Account",
8 | required: true
9 | },
10 | //What tier of sponsor are they?
11 | tier: {
12 | type: Number,
13 | min: 0,
14 | default: 0
15 | },
16 | company: {
17 | type: String,
18 | required: true
19 | },
20 | //URL to the contract between hackathon and sponsor
21 | contractURL: {
22 | type: String,
23 | required: true
24 | },
25 | //which hackers did the sponsor flag to see again?
26 | nominees: [
27 | {
28 | type: mongoose.Schema.Types.ObjectId,
29 | ref: "Hacker"
30 | }
31 | ]
32 | });
33 |
34 | SponsorSchema.methods.toJSON = function(options) {
35 | const ss = this.toObject(options);
36 | delete ss.__v;
37 | ss.id = ss._id;
38 | delete ss._id;
39 | return ss;
40 | };
41 | //export the model
42 | module.exports = mongoose.model("Sponsor", SponsorSchema);
43 |
--------------------------------------------------------------------------------
/models/accountConfirmationToken.model.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | const mongoose = require("mongoose");
3 | const Constants = {
4 | General: require("../constants/general.constant")
5 | };
6 |
7 | const AccountConfirmationSchema = new mongoose.Schema({
8 | accountId: {
9 | type: mongoose.Schema.Types.ObjectId,
10 | ref: "Account",
11 | required: false
12 | },
13 | accountType: {
14 | type: String,
15 | enum: Constants.General.EXTENDED_USER_TYPES,
16 | default: Constants.General.HACKER
17 | },
18 | email: {
19 | type: String,
20 | required: true
21 | },
22 | confirmationType: {
23 | type: String,
24 | enum: Constants.General.CONFIRMATION_TYPES,
25 | default: Constants.General.CONFIRMATION_TYPE_ORGANIC
26 | }
27 | });
28 |
29 | AccountConfirmationSchema.methods.toJSON = function(options) {
30 | const acs = this.toObject(options);
31 | delete acs.__v;
32 | acs.id = acs._id;
33 | delete acs._id;
34 | return acs;
35 | };
36 |
37 | module.exports = mongoose.model(
38 | "AccountConfirmationToken",
39 | AccountConfirmationSchema
40 | );
41 |
--------------------------------------------------------------------------------
/docs/api/vendor/prettify/lang-cbm.js:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | Copyright (C) 2013 Peter Kofler
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 | */
17 | PR.registerLangHandler(PR.createSimpleLexer([["str",/^(?:"(?:[^\\"\r\n]|\\.)*(?:"|$))/,null,'"'],["pln",/^\s+/,null," \r\n\t\u00a0"]],[["com",/^REM[^\r\n]*/,null],["kwd",/^\b(?:AND|CLOSE|CLR|CMD|CONT|DATA|DEF ?FN|DIM|END|FOR|GET|GOSUB|GOTO|IF|INPUT|LET|LIST|LOAD|NEW|NEXT|NOT|ON|OPEN|OR|POKE|PRINT|READ|RESTORE|RETURN|RUN|SAVE|STEP|STOP|SYS|THEN|TO|VERIFY|WAIT)\b/,null],["pln",/^[A-Z][A-Z0-9]?(?:\$|%)?/i,null],["lit",/^(?:\d+(?:\.\d*)?|\.\d+)(?:e[+\-]?\d+)?/i,
18 | null,"0123456789"],["pun",/^.[^\s\w\.$%"]*/,null]]),["basic","cbm"]);
19 |
--------------------------------------------------------------------------------
/docs/api/vendor/prettify/lang-basic.js:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | Copyright (C) 2013 Peter Kofler
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 | */
17 | PR.registerLangHandler(PR.createSimpleLexer([["str",/^(?:"(?:[^\\"\r\n]|\\.)*(?:"|$))/,null,'"'],["pln",/^\s+/,null," \r\n\t\u00a0"]],[["com",/^REM[^\r\n]*/,null],["kwd",/^\b(?:AND|CLOSE|CLR|CMD|CONT|DATA|DEF ?FN|DIM|END|FOR|GET|GOSUB|GOTO|IF|INPUT|LET|LIST|LOAD|NEW|NEXT|NOT|ON|OPEN|OR|POKE|PRINT|READ|RESTORE|RETURN|RUN|SAVE|STEP|STOP|SYS|THEN|TO|VERIFY|WAIT)\b/,null],["pln",/^[A-Z][A-Z0-9]?(?:\$|%)?/i,null],["lit",/^(?:\d+(?:\.\d*)?|\.\d+)(?:e[+\-]?\d+)?/i,
18 | null,"0123456789"],["pun",/^.[^\s\w\.$%"]*/,null]]),["basic","cbm"]);
19 |
--------------------------------------------------------------------------------
/controllers/email.controller.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | const Constants = {
4 | Success: require("../constants/success.constant"),
5 | Error: require("../constants/error.constant"),
6 | };
7 |
8 | /**
9 | * @function getStatusCount
10 | * @param {{body: {count: number}}} req
11 | * @param {*} res
12 | * @return {JSON} Success status and count
13 | * @description Returns the count of hackers with specified status
14 | */
15 | function getStatusCount(req, res) {
16 | return res.status(200).json({
17 | message: "Successfully retrieved count",
18 | data: { count: req.body.count },
19 | });
20 | }
21 |
22 | /**
23 | * @function sendAutomatedStatusEmails
24 | * @param {{body: {results: {success: number, failed: number}}}} req
25 | * @param {*} res
26 | * @return {JSON} Success status and email results
27 | * @description Returns the results of sending automated status emails
28 | */
29 | function sendAutomatedStatusEmails(req, res) {
30 | return res.status(200).json({
31 | message: "Successfully sent emails",
32 | data: req.body.results,
33 | });
34 | }
35 |
36 | module.exports = {
37 | getStatusCount,
38 | sendAutomatedStatusEmails,
39 | };
40 |
--------------------------------------------------------------------------------
/docs/api/vendor/path-to-regexp/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2014 Blake Embrey (hello@blakeembrey.com)
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | THE SOFTWARE.
22 |
--------------------------------------------------------------------------------
/docs/api/vendor/prettify/lang-wiki.js:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | Copyright (C) 2009 Google Inc.
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 | */
17 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t \xA0a-gi-z0-9]+/,null,"\t \u00a0abcdefgijklmnopqrstuvwxyz0123456789"],["pun",/^[=*~\^\[\]]+/,null,"=*~^[]"]],[["lang-wiki.meta",/(?:^^|\r\n?|\n)(#[a-z]+)\b/],["lit",/^(?:[A-Z][a-z][a-z0-9]+[A-Z][a-z][a-zA-Z0-9]+)\b/],["lang-",/^\{\{\{([\s\S]+?)\}\}\}/],["lang-",/^`([^\r\n`]+)`/],["str",/^https?:\/\/[^\/?#\s]*(?:\/[^?#\s]*)?(?:\?[^#\s]*)?(?:#\S*)?/i],["pln",/^(?:\r\n|[\s\S])[^#=*~^A-Zh\{`\[\r\n]*/]]),["wiki"]);
18 | PR.registerLangHandler(PR.createSimpleLexer([["kwd",/^#[a-z]+/i,null,"#"]],[]),["wiki.meta"]);
19 |
--------------------------------------------------------------------------------
/docs/api/vendor/prettify/lang-lua.js:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | Copyright (C) 2008 Google Inc.
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 | */
17 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\r \xA0]+/,null,"\t\n\r \u00a0"],["str",/^(?:\"(?:[^\"\\]|\\[\s\S])*(?:\"|$)|\'(?:[^\'\\]|\\[\s\S])*(?:\'|$))/,null,"\"'"]],[["com",/^--(?:\[(=*)\[[\s\S]*?(?:\]\1\]|$)|[^\r\n]*)/],["str",/^\[(=*)\[[\s\S]*?(?:\]\1\]|$)/],["kwd",/^(?:and|break|do|else|elseif|end|false|for|function|if|in|local|nil|not|or|repeat|return|then|true|until|while)\b/,null],["lit",/^[+-]?(?:0x[\da-f]+|(?:(?:\.\d+|\d+(?:\.\d*)?)(?:e[+\-]?\d+)?))/i],
18 | ["pln",/^[a-z_]\w*/i],["pun",/^[^\w\t\n\r \xA0][^\w\t\n\r \xA0\"\'\-\+=]*/]]),["lua"]);
19 |
--------------------------------------------------------------------------------
/middlewares/validators/sponsor.validator.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | const VALIDATOR = require("./validator.helper");
3 | const Constants = require("../../constants/general.constant");
4 |
5 | module.exports = {
6 | // mongo id will be added at parse middleware
7 | newSponsorValidator: [
8 | // the id of the base account
9 | VALIDATOR.mongoIdValidator("body", "accountId", false),
10 | // assuming that the tiers are between 0 and 5 (inclusive)
11 | // 5 is the custom class
12 | VALIDATOR.integerValidator("body", "tier", false, 0, 5),
13 | VALIDATOR.stringValidator("body", "company", false),
14 | VALIDATOR.regexValidator(
15 | "body",
16 | "contractURL",
17 | false,
18 | Constants.URL_REGEX
19 | ),
20 | VALIDATOR.mongoIdArrayValidator("body", "nominees", true)
21 | ],
22 |
23 | updateSponsorValidator: [
24 | VALIDATOR.stringValidator("body", "company", true),
25 | VALIDATOR.regexValidator(
26 | "body",
27 | "contractURL",
28 | true,
29 | Constants.URL_REGEX
30 | ),
31 | VALIDATOR.mongoIdArrayValidator("body", "nominees", true)
32 | ]
33 | };
34 |
--------------------------------------------------------------------------------
/tests/util/staff.test.util.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | const Util = {
3 | Account: require("./account.test.util")
4 | };
5 | const Staff = require("../../models/staff.model");
6 | const mongoose = require("mongoose");
7 | const logger = require("../../services/logger.service");
8 |
9 | const Staff0 = {
10 | _id: new mongoose.Types.ObjectId(),
11 | accountId: Util.Account.staffAccounts.stored[0]
12 | };
13 | const Staffs = [Staff0];
14 |
15 | function store(attributes) {
16 | const staffDocs = [];
17 | const staffIds = [];
18 | attributes.forEach((attribute) => {
19 | staffDocs.push(new Staff(attribute));
20 | staffIds.push(attribute._id);
21 | });
22 |
23 | return Staff.collection.insertMany(staffDocs);
24 | }
25 |
26 | async function storeAll() {
27 | await store(Staffs);
28 | }
29 |
30 | async function dropAll() {
31 | try {
32 | await Staff.collection.drop();
33 | } catch (e) {
34 | if (e.code === 26) {
35 | logger.info("namespace %s not found", Staff.collection.name);
36 | } else {
37 | throw e;
38 | }
39 | }
40 | }
41 |
42 | module.exports = {
43 | Staff0: Staff0,
44 | Staffs: Staffs,
45 | storeAll: storeAll,
46 | dropAll: dropAll
47 | };
48 |
--------------------------------------------------------------------------------
/docs/api/vendor/prettify/lang-erl.js:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | Copyright (C) 2013 Andrew Allen
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 | */
17 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\x0B\x0C\r ]+/,null,"\t\n\x0B\f\r "],["str",/^\"(?:[^\"\\\n\x0C\r]|\\[\s\S])*(?:\"|$)/,null,'"'],["lit",/^[a-z][a-zA-Z0-9_]*/],["lit",/^\'(?:[^\'\\\n\x0C\r]|\\[^&])+\'?/,null,"'"],["lit",/^\?[^ \t\n({]+/,null,"?"],["lit",/^(?:0o[0-7]+|0x[\da-f]+|\d+(?:\.\d+)?(?:e[+\-]?\d+)?)/i,null,"0123456789"]],[["com",/^%[^\n]*/],["kwd",/^(?:module|attributes|do|let|in|letrec|apply|call|primop|case|of|end|when|fun|try|catch|receive|after|char|integer|float,atom,string,var)\b/],
18 | ["kwd",/^-[a-z_]+/],["typ",/^[A-Z_][a-zA-Z0-9_]*/],["pun",/^[.,;]/]]),["erlang","erl"]);
19 |
--------------------------------------------------------------------------------
/docs/api/vendor/prettify/lang-erlang.js:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | Copyright (C) 2013 Andrew Allen
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 | */
17 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\x0B\x0C\r ]+/,null,"\t\n\x0B\f\r "],["str",/^\"(?:[^\"\\\n\x0C\r]|\\[\s\S])*(?:\"|$)/,null,'"'],["lit",/^[a-z][a-zA-Z0-9_]*/],["lit",/^\'(?:[^\'\\\n\x0C\r]|\\[^&])+\'?/,null,"'"],["lit",/^\?[^ \t\n({]+/,null,"?"],["lit",/^(?:0o[0-7]+|0x[\da-f]+|\d+(?:\.\d+)?(?:e[+\-]?\d+)?)/i,null,"0123456789"]],[["com",/^%[^\n]*/],["kwd",/^(?:module|attributes|do|let|in|letrec|apply|call|primop|case|of|end|when|fun|try|catch|receive|after|char|integer|float,atom,string,var)\b/],
18 | ["kwd",/^-[a-z_]+/],["typ",/^[A-Z_][a-zA-Z0-9_]*/],["pun",/^[.,;]/]]),["erlang","erl"]);
19 |
--------------------------------------------------------------------------------
/docs/api/vendor/prettify/lang-hs.js:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | Copyright (C) 2009 Google Inc.
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 | */
17 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\x0B\x0C\r ]+/,null,"\t\n\x0B\f\r "],["str",/^\"(?:[^\"\\\n\x0C\r]|\\[\s\S])*(?:\"|$)/,null,'"'],["str",/^\'(?:[^\'\\\n\x0C\r]|\\[^&])\'?/,null,"'"],["lit",/^(?:0o[0-7]+|0x[\da-f]+|\d+(?:\.\d+)?(?:e[+\-]?\d+)?)/i,null,"0123456789"]],[["com",/^(?:(?:--+(?:[^\r\n\x0C]*)?)|(?:\{-(?:[^-]|-+[^-\}])*-\}))/],["kwd",/^(?:case|class|data|default|deriving|do|else|if|import|in|infix|infixl|infixr|instance|let|module|newtype|of|then|type|where|_)(?=[^a-zA-Z0-9\']|$)/,
18 | null],["pln",/^(?:[A-Z][\w\']*\.)*[a-zA-Z][\w\']*/],["pun",/^[^\t\n\x0B\x0C\r a-zA-Z0-9\'\"]+/]]),["hs"]);
19 |
--------------------------------------------------------------------------------
/docs/api/locales/tr.js:
--------------------------------------------------------------------------------
1 | define({
2 | tr: {
3 | 'Allowed values:' : 'İzin verilen değerler:',
4 | 'Compare all with predecessor': 'Tümünü öncekiler ile karşılaştır',
5 | 'compare changes to:' : 'değişiklikleri karşılaştır:',
6 | 'compared to' : 'karşılaştır',
7 | 'Default value:' : 'Varsayılan değer:',
8 | 'Description' : 'Açıklama',
9 | 'Field' : 'Alan',
10 | 'General' : 'Genel',
11 | 'Generated with' : 'Oluşturan',
12 | 'Name' : 'İsim',
13 | 'No response values.' : 'Dönüş verisi yok.',
14 | 'optional' : 'opsiyonel',
15 | 'Parameter' : 'Parametre',
16 | 'Permission:' : 'İzin:',
17 | 'Response' : 'Dönüş',
18 | 'Send' : 'Gönder',
19 | 'Send a Sample Request' : 'Örnek istek gönder',
20 | 'show up to version:' : 'bu versiyona kadar göster:',
21 | 'Size range:' : 'Boyut aralığı:',
22 | 'Type' : 'Tip',
23 | 'url' : 'url'
24 | }
25 | });
26 |
--------------------------------------------------------------------------------
/models/role.model.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | const mongoose = require("mongoose");
3 | const Constants = require("../constants/general.constant");
4 | /**
5 | * The name is descriptive of the role
6 | * Each role may have different routes, where route parameters in the uri are replaced with :self or :all
7 | */
8 | const RoleSchema = new mongoose.Schema({
9 | // The name should be something like "hacker", or "sponsor".
10 | // For roles with singular routes, the name of the role will be the name of the route plus the api route
11 | // For example, "getSelfAccount"
12 | name: {
13 | type: String,
14 | unique: true,
15 | required: true
16 | },
17 | //The array of routes that this Role should have access to.
18 | routes: [
19 | {
20 | uri: {
21 | type: String
22 | },
23 | requestType: {
24 | type: String,
25 | enum: Object.values(Constants.REQUEST_TYPES)
26 | }
27 | }
28 | ]
29 | });
30 |
31 | RoleSchema.methods.toJSON = function(options) {
32 | const rs = this.toObject(options);
33 | delete rs.__v;
34 | rs.id = rs._id;
35 | delete rs._id;
36 | return rs;
37 | };
38 | //export the model
39 | module.exports = mongoose.model("Role", RoleSchema);
40 |
--------------------------------------------------------------------------------
/tests/util/settings.test.util.js:
--------------------------------------------------------------------------------
1 | const Settings = require("../../models/settings.model");
2 | const logger = require("../../services/logger.service");
3 | const Constants = {
4 | Settings: require("../../constants/settings.constant")
5 | };
6 |
7 | async function storeAll() {
8 | const toStore = new Settings(Constants.Settings.APP_OPEN);
9 | Settings.collection.insertOne(toStore);
10 | }
11 |
12 | async function setApplicationClosed() {
13 | await dropAll();
14 | const toStore = new Settings(Constants.Settings.APP_CLOSED);
15 | Settings.collection.insertOne(toStore);
16 | }
17 |
18 | async function setApplicationNotYetOpen() {
19 | await dropAll();
20 | const toStore = new Settings(Constants.Settings.APP_NOT_YET_OPEN);
21 | Settings.collection.insertOne(toStore);
22 | }
23 |
24 | async function dropAll() {
25 | try {
26 | await Settings.collection.drop();
27 | } catch (e) {
28 | if (e.code === 26) {
29 | logger.info("namespace %s not found", Settings.collection.name);
30 | } else {
31 | throw e;
32 | }
33 | }
34 | }
35 | module.exports = {
36 | storeAll: storeAll,
37 | dropAll: dropAll,
38 | setApplicationClosed: setApplicationClosed,
39 | setApplicationNotYetOpen: setApplicationNotYetOpen
40 | };
41 |
--------------------------------------------------------------------------------
/docs/api/locales/pl.js:
--------------------------------------------------------------------------------
1 | define({
2 | pl: {
3 | 'Allowed values:' : 'Dozwolone wartości:',
4 | 'Compare all with predecessor': 'Porównaj z poprzednimi wersjami',
5 | 'compare changes to:' : 'porównaj zmiany do:',
6 | 'compared to' : 'porównaj do:',
7 | 'Default value:' : 'Wartość domyślna:',
8 | 'Description' : 'Opis',
9 | 'Field' : 'Pole',
10 | 'General' : 'Generalnie',
11 | 'Generated with' : 'Wygenerowano z',
12 | 'Name' : 'Nazwa',
13 | 'No response values.' : 'Brak odpowiedzi.',
14 | 'optional' : 'opcjonalny',
15 | 'Parameter' : 'Parametr',
16 | 'Permission:' : 'Uprawnienia:',
17 | 'Response' : 'Odpowiedź',
18 | 'Send' : 'Wyślij',
19 | 'Send a Sample Request' : 'Wyślij przykładowe żądanie',
20 | 'show up to version:' : 'pokaż do wersji:',
21 | 'Size range:' : 'Zakres rozmiaru:',
22 | 'Type' : 'Typ',
23 | 'url' : 'url'
24 | }
25 | });
26 |
--------------------------------------------------------------------------------
/docs/api/locales/ca.js:
--------------------------------------------------------------------------------
1 | define({
2 | ca: {
3 | 'Allowed values:' : 'Valors permesos:',
4 | 'Compare all with predecessor': 'Comparar tot amb versió anterior',
5 | 'compare changes to:' : 'comparar canvis amb:',
6 | 'compared to' : 'comparat amb',
7 | 'Default value:' : 'Valor per defecte:',
8 | 'Description' : 'Descripció',
9 | 'Field' : 'Camp',
10 | 'General' : 'General',
11 | 'Generated with' : 'Generat amb',
12 | 'Name' : 'Nom',
13 | 'No response values.' : 'Sense valors en la resposta.',
14 | 'optional' : 'opcional',
15 | 'Parameter' : 'Paràmetre',
16 | 'Permission:' : 'Permisos:',
17 | 'Response' : 'Resposta',
18 | 'Send' : 'Enviar',
19 | 'Send a Sample Request' : 'Enviar una petició d\'exemple',
20 | 'show up to version:' : 'mostrar versió:',
21 | 'Size range:' : 'Tamany de rang:',
22 | 'Type' : 'Tipus',
23 | 'url' : 'url'
24 | }
25 | });
26 |
--------------------------------------------------------------------------------
/docs/api/locales/vi.js:
--------------------------------------------------------------------------------
1 | define({
2 | vi: {
3 | 'Allowed values:' : 'Giá trị chấp nhận:',
4 | 'Compare all with predecessor': 'So sánh với tất cả phiên bản trước',
5 | 'compare changes to:' : 'so sánh sự thay đổi với:',
6 | 'compared to' : 'so sánh với',
7 | 'Default value:' : 'Giá trị mặc định:',
8 | 'Description' : 'Chú thích',
9 | 'Field' : 'Trường dữ liệu',
10 | 'General' : 'Tổng quan',
11 | 'Generated with' : 'Được tạo bởi',
12 | 'Name' : 'Tên',
13 | 'No response values.' : 'Không có kết quả trả về.',
14 | 'optional' : 'Tùy chọn',
15 | 'Parameter' : 'Tham số',
16 | 'Permission:' : 'Quyền hạn:',
17 | 'Response' : 'Kết quả',
18 | 'Send' : 'Gửi',
19 | 'Send a Sample Request' : 'Gửi một yêu cầu mẫu',
20 | 'show up to version:' : 'hiển thị phiên bản:',
21 | 'Size range:' : 'Kích cỡ:',
22 | 'Type' : 'Kiểu',
23 | 'url' : 'liên kết'
24 | }
25 | });
26 |
--------------------------------------------------------------------------------
/docs/api/locales/cs.js:
--------------------------------------------------------------------------------
1 | define({
2 | cs: {
3 | 'Allowed values:' : 'Povolené hodnoty:',
4 | 'Compare all with predecessor': 'Porovnat vše s předchozími verzemi',
5 | 'compare changes to:' : 'porovnat změny s:',
6 | 'compared to' : 'porovnat s',
7 | 'Default value:' : 'Výchozí hodnota:',
8 | 'Description' : 'Popis',
9 | 'Field' : 'Pole',
10 | 'General' : 'Obecné',
11 | 'Generated with' : 'Vygenerováno pomocí',
12 | 'Name' : 'Název',
13 | 'No response values.' : 'Nebyly vráceny žádné hodnoty.',
14 | 'optional' : 'volitelné',
15 | 'Parameter' : 'Parametr',
16 | 'Permission:' : 'Oprávnění:',
17 | 'Response' : 'Odpověď',
18 | 'Send' : 'Odeslat',
19 | 'Send a Sample Request' : 'Odeslat ukázkový požadavek',
20 | 'show up to version:' : 'zobrazit po verzi:',
21 | 'Size range:' : 'Rozsah velikosti:',
22 | 'Type' : 'Typ',
23 | 'url' : 'url'
24 | }
25 | });
26 |
--------------------------------------------------------------------------------
/docs/api/vendor/prettify/lang-tcl.js:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | Copyright (C) 2012 Pyrios
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 | */
17 | PR.registerLangHandler(PR.createSimpleLexer([["opn",/^\{+/,null,"{"],["clo",/^\}+/,null,"}"],["com",/^#[^\r\n]*/,null,"#"],["pln",/^[\t\n\r \xA0]+/,null,"\t\n\r \u00a0"],["str",/^\"(?:[^\"\\]|\\[\s\S])*(?:\"|$)/,null,'"']],[["kwd",/^(?:after|append|apply|array|break|case|catch|continue|error|eval|exec|exit|expr|for|foreach|if|incr|info|proc|return|set|switch|trace|uplevel|upvar|while)\b/,null],["lit",/^[+\-]?(?:[0#]x[0-9a-f]+|\d+\/\d+|(?:\.\d+|\d+(?:\.\d*)?)(?:[ed][+\-]?\d+)?)/i],
18 | ["lit",/^\'(?:-*(?:\w|\\[\x21-\x7e])(?:[\w-]*|\\[\x21-\x7e])[=!?]?)?/],["pln",/^-*(?:[a-z_]|\\[\x21-\x7e])(?:[\w-]*|\\[\x21-\x7e])[=!?]?/i],["pun",/^[^\w\t\n\r \xA0()\"\\\';]+/]]),["tcl"]);
19 |
--------------------------------------------------------------------------------
/constants/settings.constant.js:
--------------------------------------------------------------------------------
1 | const APP_NOT_YET_OPEN = {
2 | openTime: new Date(Date.now() + 100000000000),
3 | closeTime: new Date(Date.now() + 10000000000000000),
4 | confirmTime: new Date(Date.now() + 100000000000000000)
5 | };
6 |
7 | const APP_OPEN = {
8 | openTime: new Date(Date.now() - 100),
9 | closeTime: new Date(Date.now() + 10000000000),
10 | confirmTime: new Date(Date.now() + 100000000000000)
11 | };
12 |
13 | const APP_CLOSED = {
14 | openTime: new Date(Date.now() - 100),
15 | closeTime: new Date(Date.now() - 1000),
16 | confirmTime: new Date(Date.now() + 100000000000000)
17 | };
18 |
19 | const CONFIRM_CLOSED = {
20 | openTime: new Date(Date.now() - 10000),
21 | closeTime: new Date(Date.now() - 1000),
22 | confirmTime: new Date(Date.now() - 100)
23 | };
24 |
25 | const REMOTE_HACKATHON = {
26 | openTime: new Date(Date.now() - 100),
27 | closeTime: new Date(Date.now() + 10000000000),
28 | confirmTime: new Date(Date.now() + 100000000000000),
29 | isRemote: true
30 | };
31 |
32 | // Some utility dates that are used in tests and seed script
33 | module.exports = {
34 | APP_NOT_YET_OPEN: APP_NOT_YET_OPEN,
35 | APP_OPEN: APP_OPEN,
36 | APP_CLOSED: APP_CLOSED,
37 | CONFIRM_CLOSED: CONFIRM_CLOSED,
38 | REMOTE_HACKATHON: REMOTE_HACKATHON
39 | };
40 |
--------------------------------------------------------------------------------
/docs/api/locales/de.js:
--------------------------------------------------------------------------------
1 | define({
2 | de: {
3 | 'Allowed values:' : 'Erlaubte Werte:',
4 | 'Compare all with predecessor': 'Vergleiche alle mit ihren Vorgängern',
5 | 'compare changes to:' : 'vergleiche Änderungen mit:',
6 | 'compared to' : 'verglichen mit',
7 | 'Default value:' : 'Standardwert:',
8 | 'Description' : 'Beschreibung',
9 | 'Field' : 'Feld',
10 | 'General' : 'Allgemein',
11 | 'Generated with' : 'Erstellt mit',
12 | 'Name' : 'Name',
13 | 'No response values.' : 'Keine Rückgabewerte.',
14 | 'optional' : 'optional',
15 | 'Parameter' : 'Parameter',
16 | 'Permission:' : 'Berechtigung:',
17 | 'Response' : 'Antwort',
18 | 'Send' : 'Senden',
19 | 'Send a Sample Request' : 'Eine Beispielanfrage senden',
20 | 'show up to version:' : 'zeige bis zur Version:',
21 | 'Size range:' : 'Größenbereich:',
22 | 'Type' : 'Typ',
23 | 'url' : 'url'
24 | }
25 | });
26 |
--------------------------------------------------------------------------------
/docs/api/locales/ro.js:
--------------------------------------------------------------------------------
1 | define({
2 | ro: {
3 | 'Allowed values:' : 'Valori permise:',
4 | 'Compare all with predecessor': 'Compară toate cu versiunea precedentă',
5 | 'compare changes to:' : 'compară cu versiunea:',
6 | 'compared to' : 'comparat cu',
7 | 'Default value:' : 'Valoare implicită:',
8 | 'Description' : 'Descriere',
9 | 'Field' : 'Câmp',
10 | 'General' : 'General',
11 | 'Generated with' : 'Generat cu',
12 | 'Name' : 'Nume',
13 | 'No response values.' : 'Nici o valoare returnată.',
14 | 'optional' : 'opțional',
15 | 'Parameter' : 'Parametru',
16 | 'Permission:' : 'Permisiune:',
17 | 'Response' : 'Răspuns',
18 | 'Send' : 'Trimite',
19 | 'Send a Sample Request' : 'Trimite o cerere de probă',
20 | 'show up to version:' : 'arată până la versiunea:',
21 | 'Size range:' : 'Interval permis:',
22 | 'Type' : 'Tip',
23 | 'url' : 'url'
24 | }
25 | });
26 |
--------------------------------------------------------------------------------
/docs/api/locales/ru.js:
--------------------------------------------------------------------------------
1 | define({
2 | ru: {
3 | 'Allowed values:' : 'Допустимые значения:',
4 | 'Compare all with predecessor': 'Сравнить с предыдущей версией',
5 | 'compare changes to:' : 'сравнить с:',
6 | 'compared to' : 'в сравнении с',
7 | 'Default value:' : 'По умолчанию:',
8 | 'Description' : 'Описание',
9 | 'Field' : 'Название',
10 | 'General' : 'Общая информация',
11 | 'Generated with' : 'Сгенерировано с помощью',
12 | 'Name' : 'Название',
13 | 'No response values.' : 'Нет значений для ответа.',
14 | 'optional' : 'необязательный',
15 | 'Parameter' : 'Параметр',
16 | 'Permission:' : 'Разрешено:',
17 | 'Response' : 'Ответ',
18 | 'Send' : 'Отправить',
19 | 'Send a Sample Request' : 'Отправить тестовый запрос',
20 | 'show up to version:' : 'показать версию:',
21 | 'Size range:' : 'Ограничения:',
22 | 'Type' : 'Тип',
23 | 'url' : 'URL'
24 | }
25 | });
26 |
--------------------------------------------------------------------------------
/docs/api/locales/pt_br.js:
--------------------------------------------------------------------------------
1 | define({
2 | 'pt_br': {
3 | 'Allowed values:' : 'Valores permitidos:',
4 | 'Compare all with predecessor': 'Compare todos com antecessores',
5 | 'compare changes to:' : 'comparar alterações com:',
6 | 'compared to' : 'comparado com',
7 | 'Default value:' : 'Valor padrão:',
8 | 'Description' : 'Descrição',
9 | 'Field' : 'Campo',
10 | 'General' : 'Geral',
11 | 'Generated with' : 'Gerado com',
12 | 'Name' : 'Nome',
13 | 'No response values.' : 'Sem valores de resposta.',
14 | 'optional' : 'opcional',
15 | 'Parameter' : 'Parâmetro',
16 | 'Permission:' : 'Permissão:',
17 | 'Response' : 'Resposta',
18 | 'Send' : 'Enviar',
19 | 'Send a Sample Request' : 'Enviar um Exemplo de Pedido',
20 | 'show up to version:' : 'aparecer para a versão:',
21 | 'Size range:' : 'Faixa de tamanho:',
22 | 'Type' : 'Tipo',
23 | 'url' : 'url'
24 | }
25 | });
26 |
--------------------------------------------------------------------------------
/docs/api/locales/es.js:
--------------------------------------------------------------------------------
1 | define({
2 | es: {
3 | 'Allowed values:' : 'Valores permitidos:',
4 | 'Compare all with predecessor': 'Comparar todo con versión anterior',
5 | 'compare changes to:' : 'comparar cambios con:',
6 | 'compared to' : 'comparado con',
7 | 'Default value:' : 'Valor por defecto:',
8 | 'Description' : 'Descripción',
9 | 'Field' : 'Campo',
10 | 'General' : 'General',
11 | 'Generated with' : 'Generado con',
12 | 'Name' : 'Nombre',
13 | 'No response values.' : 'Sin valores en la respuesta.',
14 | 'optional' : 'opcional',
15 | 'Parameter' : 'Parámetro',
16 | 'Permission:' : 'Permisos:',
17 | 'Response' : 'Respuesta',
18 | 'Send' : 'Enviar',
19 | 'Send a Sample Request' : 'Enviar una petición de ejemplo',
20 | 'show up to version:' : 'mostrar a versión:',
21 | 'Size range:' : 'Tamaño de rango:',
22 | 'Type' : 'Tipo',
23 | 'url' : 'url'
24 | }
25 | });
26 |
--------------------------------------------------------------------------------
/docs/api/locales/nl.js:
--------------------------------------------------------------------------------
1 | define({
2 | nl: {
3 | 'Allowed values:' : 'Toegestane waarden:',
4 | 'Compare all with predecessor': 'Vergelijk alle met voorgaande versie',
5 | 'compare changes to:' : 'vergelijk veranderingen met:',
6 | 'compared to' : 'vergelijk met',
7 | 'Default value:' : 'Standaard waarde:',
8 | 'Description' : 'Omschrijving',
9 | 'Field' : 'Veld',
10 | 'General' : 'Algemeen',
11 | 'Generated with' : 'Gegenereerd met',
12 | 'Name' : 'Naam',
13 | 'No response values.' : 'Geen response waardes.',
14 | 'optional' : 'optioneel',
15 | 'Parameter' : 'Parameter',
16 | 'Permission:' : 'Permissie:',
17 | 'Response' : 'Antwoorden',
18 | 'Send' : 'Sturen',
19 | 'Send a Sample Request' : 'Stuur een sample aanvragen',
20 | 'show up to version:' : 'toon tot en met versie:',
21 | 'Size range:' : 'Maatbereik:',
22 | 'Type' : 'Type',
23 | 'url' : 'url'
24 | }
25 | });
26 |
--------------------------------------------------------------------------------
/docs/api/locales/fr.js:
--------------------------------------------------------------------------------
1 | define({
2 | fr: {
3 | 'Allowed values:' : 'Valeurs autorisées :',
4 | 'Compare all with predecessor': 'Tout comparer avec ...',
5 | 'compare changes to:' : 'comparer les changements à :',
6 | 'compared to' : 'comparer à',
7 | 'Default value:' : 'Valeur par défaut :',
8 | 'Description' : 'Description',
9 | 'Field' : 'Champ',
10 | 'General' : 'Général',
11 | 'Generated with' : 'Généré avec',
12 | 'Name' : 'Nom',
13 | 'No response values.' : 'Aucune valeur de réponse.',
14 | 'optional' : 'optionnel',
15 | 'Parameter' : 'Paramètre',
16 | 'Permission:' : 'Permission :',
17 | 'Response' : 'Réponse',
18 | 'Send' : 'Envoyer',
19 | 'Send a Sample Request' : 'Envoyer une requête représentative',
20 | 'show up to version:' : 'Montrer à partir de la version :',
21 | 'Size range:' : 'Ordre de grandeur :',
22 | 'Type' : 'Type',
23 | 'url' : 'url'
24 | }
25 | });
26 |
--------------------------------------------------------------------------------
/docs/api/locales/it.js:
--------------------------------------------------------------------------------
1 | define({
2 | it: {
3 | 'Allowed values:' : 'Valori permessi:',
4 | 'Compare all with predecessor': 'Confronta tutto con versioni precedenti',
5 | 'compare changes to:' : 'confronta modifiche con:',
6 | 'compared to' : 'confrontato con',
7 | 'Default value:' : 'Valore predefinito:',
8 | 'Description' : 'Descrizione',
9 | 'Field' : 'Campo',
10 | 'General' : 'Generale',
11 | 'Generated with' : 'Creato con',
12 | 'Name' : 'Nome',
13 | 'No response values.' : 'Nessun valore di risposta.',
14 | 'optional' : 'opzionale',
15 | 'Parameter' : 'Parametro',
16 | 'Permission:' : 'Permessi:',
17 | 'Response' : 'Risposta',
18 | 'Send' : 'Invia',
19 | 'Send a Sample Request' : 'Invia una richiesta di esempio',
20 | 'show up to version:' : 'mostra alla versione:',
21 | 'Size range:' : 'Intervallo dimensione:',
22 | 'Type' : 'Tipo',
23 | 'url' : 'url'
24 | }
25 | });
26 |
--------------------------------------------------------------------------------
/services/settings.service.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | const Settings = require("../models/settings.model");
3 | const logger = require("./logger.service");
4 |
5 | /**
6 | * @function updateSettings
7 | * @param {{_id: ObjectId, openTime: Date, closeTime: Date, confirmTime: Date}} settingsDetails
8 | * @return {Promise} The promise will resolve to a Settings object if save was successful.
9 | * @description Adds a new setting to database.
10 | */
11 | async function updateSettings(settingsDetails) {
12 | const TAG = "[Setting service # updateSettings]:";
13 | const existingSetting = await getSettings();
14 | if (existingSetting) {
15 | return logger.logQuery(TAG, "settings", {}, Settings.findOneAndUpdate({}, settingsDetails, { new: true }));
16 | } else {
17 | const setting = new Settings(settingsDetails);
18 | return setting.save();
19 | }
20 | }
21 |
22 | /**
23 | * @function getSettings
24 | * @return {Promise} The promise will resolve to a Settings object if retrieval was successful.
25 | * @description Returns the setting item
26 | */
27 | function getSettings() {
28 | const TAG = "[Setting service # getSettings]:";
29 | return logger.logQuery(TAG, "settings", {}, Settings.findOne({}));
30 | }
31 |
32 | module.exports = {
33 | updateSettings: updateSettings,
34 | getSettings: getSettings
35 | };
36 |
--------------------------------------------------------------------------------
/models/bus.model.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | const mongoose = require("mongoose");
3 | //describes the data type
4 | const BusSchema = new mongoose.Schema({
5 | origin: {
6 | country: {
7 | type: String,
8 | required: true
9 | },
10 | provinceOrState: {
11 | type: String,
12 | required: true
13 | },
14 | zip: {
15 | type: String,
16 | required: true
17 | },
18 | city: {
19 | type: String,
20 | required: true
21 | },
22 | addr1: {
23 | type: String,
24 | required: true
25 | },
26 | addr2: String
27 | },
28 | capacity: {
29 | type: Number,
30 | required: true,
31 | min: 0
32 | },
33 | hackers: {
34 | type: [
35 | {
36 | type: mongoose.Schema.Types.ObjectId,
37 | ref: "Hacker"
38 | }
39 | ]
40 | // TODO: find way to validate that this array size is smaller than the max capacity
41 | }
42 | });
43 |
44 | BusSchema.methods.toJSON = function(options) {
45 | const bs = this.toObject(options);
46 | delete bs.__v;
47 | bs.id = bs._id;
48 | delete bs._id;
49 | return bs;
50 | };
51 | //export the model
52 | module.exports = mongoose.model("Bus", BusSchema);
53 |
--------------------------------------------------------------------------------
/seed/index.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | const Constants = {
3 | Role: require("../constants/role.constant"),
4 | Settings: require("../constants/settings.constant")
5 | };
6 |
7 | const Seed = {
8 | Roles: require("./roles.seed"),
9 | Settings: require("./settings.seed")
10 | };
11 |
12 | const Services = {
13 | env: require("../services/env.service")
14 | };
15 | const path = require("path");
16 |
17 | const envLoadResult = Services.env.load(path.join(__dirname, "../.env"));
18 | if (envLoadResult.error) {
19 | Services.log.error(envLoadResult.error);
20 | }
21 |
22 | const db = require("../services/database.service");
23 | //connect to db
24 | db.connect(() => {
25 | onConnected()
26 | .catch((reason) => {
27 | console.error(reason);
28 | process.exit(1);
29 | })
30 | .then(() => {
31 | process.exit(0);
32 | });
33 | });
34 |
35 | //called when the db is connected
36 | async function onConnected() {
37 | await dropAll();
38 | console.log("Finished dropping");
39 | await storeAll();
40 | console.log("Finished seeding");
41 | }
42 |
43 | async function dropAll() {
44 | await Seed.Roles.dropAll();
45 | await Seed.Settings.drop();
46 | }
47 |
48 | async function storeAll() {
49 | await Seed.Roles.storeAll(Constants.Role.allRolesArray);
50 | await Seed.Settings.store();
51 | }
52 |
--------------------------------------------------------------------------------
/docs/api/vendor/prettify/lang-pascal.js:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | Copyright (C) 2013 Peter Kofler
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 | */
17 | PR.registerLangHandler(PR.createSimpleLexer([["str",/^(?:\'(?:[^\\\'\r\n]|\\.)*(?:\'|$))/,null,"'"],["pln",/^\s+/,null," \r\n\t\u00a0"]],[["com",/^\(\*[\s\S]*?(?:\*\)|$)|^\{[\s\S]*?(?:\}|$)/,null],["kwd",/^(?:ABSOLUTE|AND|ARRAY|ASM|ASSEMBLER|BEGIN|CASE|CONST|CONSTRUCTOR|DESTRUCTOR|DIV|DO|DOWNTO|ELSE|END|EXTERNAL|FOR|FORWARD|FUNCTION|GOTO|IF|IMPLEMENTATION|IN|INLINE|INTERFACE|INTERRUPT|LABEL|MOD|NOT|OBJECT|OF|OR|PACKED|PROCEDURE|PROGRAM|RECORD|REPEAT|SET|SHL|SHR|THEN|TO|TYPE|UNIT|UNTIL|USES|VAR|VIRTUAL|WHILE|WITH|XOR)\b/i,
18 | null],["lit",/^(?:true|false|self|nil)/i,null],["pln",/^[a-z][a-z0-9]*/i,null],["lit",/^(?:\$[a-f0-9]+|(?:\d+(?:\.\d*)?|\.\d+)(?:e[+\-]?\d+)?)/i,null,"0123456789"],["pun",/^.[^\s\w\.$@\'\/]*/,null]]),["pascal"]);
19 |
--------------------------------------------------------------------------------
/tests/util/bus.test.util.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | const Util = {
3 | Hacker: require("./hacker.test.util")
4 | };
5 | const Bus = require("../../models/bus.model");
6 | const logger = require("../../services/logger.service");
7 |
8 | const Bus1 = {
9 | origin: {
10 | country: "Country1",
11 | provinceOrState: "Province2",
12 | zip: "123456",
13 | city: "City1",
14 | addr1: "addr1-1",
15 | addr2: "addr2-1"
16 | },
17 | capacity: 10,
18 | hackers: [Util.Hacker.TeamHacker0._id]
19 | };
20 | const Busses = [Bus1];
21 |
22 | module.exports = {
23 | Bus1: Bus1,
24 | Busses: Busses,
25 | storeAll: storeAll,
26 | dropAll: dropAll
27 | };
28 |
29 | function store(attributes) {
30 | const busDocs = [];
31 | const busZips = [];
32 | for (var i = 0; i < attributes.length; i++) {
33 | busDocs.push(new Bus(attributes[i]));
34 | busZips.push(attributes[i].zip);
35 | }
36 |
37 | return Bus.collection.insertMany(busDocs);
38 | }
39 |
40 | async function storeAll() {
41 | await store(Busses);
42 | }
43 |
44 | async function dropAll() {
45 | try {
46 | await Bus.collection.drop();
47 | } catch (e) {
48 | if (e.code === 26) {
49 | logger.info("namespace %s not found", Bus.collection.name);
50 | } else {
51 | throw e;
52 | }
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/controllers/volunteer.controller.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | const Services = {
3 | Volunteer: require("../services/volunteer.service"),
4 | Logger: require("../services/logger.service")
5 | };
6 | const Util = require("../middlewares/util.middleware");
7 | const Constants = {
8 | Success: require("../constants/success.constant"),
9 | Error: require("../constants/error.constant")
10 | };
11 |
12 | /**
13 | * @function createdVolunteer
14 | * @param {{body: {volunteer: {_id: ObjectId, accountId: ObjectId}}}} req
15 | * @param {*} res
16 | * @return {JSON} Success status
17 | * @description Show the success message and the created volunteer
18 | */
19 | function createdVolunteer(req, res) {
20 | return res.status(200).json({
21 | message: Constants.Success.VOLUNTEER_CREATE,
22 | data: req.body.volunteer
23 | });
24 | }
25 |
26 | /**
27 | * @function showVolunteer
28 | * @param {{body: {volunteer: {_id: ObjectId, accountId: ObjectId}}}} req
29 | * @param {*} res
30 | * @return {JSON} Success status
31 | * @description Show the success message and retrieved volunteer
32 | */
33 | function showVolunteer(req, res) {
34 | return res.status(200).json({
35 | message: Constants.Success.VOLUNTEER_GET_BY_ID,
36 | data: req.body.volunteer.toJSON()
37 | });
38 | }
39 |
40 | module.exports = {
41 | createdVolunteer: createdVolunteer,
42 | showVolunteer: showVolunteer
43 | };
44 |
--------------------------------------------------------------------------------
/docs/api/vendor/prettify/lang-r.js:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | Copyright (C) 2012 Jeffrey B. Arnold
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 | */
17 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\r \xA0]+/,null,"\t\n\r \u00a0"],["str",/^\"(?:[^\"\\]|\\[\s\S])*(?:\"|$)/,null,'"'],["str",/^\'(?:[^\'\\]|\\[\s\S])*(?:\'|$)/,null,"'"]],[["com",/^#.*/],["kwd",/^(?:if|else|for|while|repeat|in|next|break|return|switch|function)(?![A-Za-z0-9_.])/],["lit",/^0[xX][a-fA-F0-9]+([pP][0-9]+)?[Li]?/],["lit",/^[+-]?([0-9]+(\.[0-9]+)?|\.[0-9]+)([eE][+-]?[0-9]+)?[Li]?/],["lit",/^(?:NULL|NA(?:_(?:integer|real|complex|character)_)?|Inf|TRUE|FALSE|NaN|\.\.(?:\.|[0-9]+))(?![A-Za-z0-9_.])/],
18 | ["pun",/^(?:<-|->>?|-|==|<=|>=|<|>|&&?|!=|\|\|?|\*|\+|\^|\/|!|%.*?%|=|~|\$|@|:{1,3}|[\[\](){};,?])/],["pln",/^(?:[A-Za-z]+[A-Za-z0-9_.]*|\.[a-zA-Z_][0-9a-zA-Z\._]*)(?![A-Za-z0-9_.])/],["str",/^`.+`/]]),["r","s","R","S","Splus"]);
19 |
--------------------------------------------------------------------------------
/docs/api/vendor/prettify/lang-s.js:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | Copyright (C) 2012 Jeffrey B. Arnold
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 | */
17 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\r \xA0]+/,null,"\t\n\r \u00a0"],["str",/^\"(?:[^\"\\]|\\[\s\S])*(?:\"|$)/,null,'"'],["str",/^\'(?:[^\'\\]|\\[\s\S])*(?:\'|$)/,null,"'"]],[["com",/^#.*/],["kwd",/^(?:if|else|for|while|repeat|in|next|break|return|switch|function)(?![A-Za-z0-9_.])/],["lit",/^0[xX][a-fA-F0-9]+([pP][0-9]+)?[Li]?/],["lit",/^[+-]?([0-9]+(\.[0-9]+)?|\.[0-9]+)([eE][+-]?[0-9]+)?[Li]?/],["lit",/^(?:NULL|NA(?:_(?:integer|real|complex|character)_)?|Inf|TRUE|FALSE|NaN|\.\.(?:\.|[0-9]+))(?![A-Za-z0-9_.])/],
18 | ["pun",/^(?:<-|->>?|-|==|<=|>=|<|>|&&?|!=|\|\|?|\*|\+|\^|\/|!|%.*?%|=|~|\$|@|:{1,3}|[\[\](){};,?])/],["pln",/^(?:[A-Za-z]+[A-Za-z0-9_.]*|\.[a-zA-Z_][0-9a-zA-Z\._]*)(?![A-Za-z0-9_.])/],["str",/^`.+`/]]),["r","s","R","S","Splus"]);
19 |
--------------------------------------------------------------------------------
/docs/api/vendor/prettify/lang-Splus.js:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | Copyright (C) 2012 Jeffrey B. Arnold
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 | */
17 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\r \xA0]+/,null,"\t\n\r \u00a0"],["str",/^\"(?:[^\"\\]|\\[\s\S])*(?:\"|$)/,null,'"'],["str",/^\'(?:[^\'\\]|\\[\s\S])*(?:\'|$)/,null,"'"]],[["com",/^#.*/],["kwd",/^(?:if|else|for|while|repeat|in|next|break|return|switch|function)(?![A-Za-z0-9_.])/],["lit",/^0[xX][a-fA-F0-9]+([pP][0-9]+)?[Li]?/],["lit",/^[+-]?([0-9]+(\.[0-9]+)?|\.[0-9]+)([eE][+-]?[0-9]+)?[Li]?/],["lit",/^(?:NULL|NA(?:_(?:integer|real|complex|character)_)?|Inf|TRUE|FALSE|NaN|\.\.(?:\.|[0-9]+))(?![A-Za-z0-9_.])/],
18 | ["pun",/^(?:<-|->>?|-|==|<=|>=|<|>|&&?|!=|\|\|?|\*|\+|\^|\/|!|%.*?%|=|~|\$|@|:{1,3}|[\[\](){};,?])/],["pln",/^(?:[A-Za-z]+[A-Za-z0-9_.]*|\.[a-zA-Z_][0-9a-zA-Z\._]*)(?![A-Za-z0-9_.])/],["str",/^`.+`/]]),["r","s","R","S","Splus"]);
19 |
--------------------------------------------------------------------------------
/docs/api/vendor/prettify/lang-cl.js:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | Copyright (C) 2008 Google Inc.
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 | */
17 | PR.registerLangHandler(PR.createSimpleLexer([["opn",/^\(+/,null,"("],["clo",/^\)+/,null,")"],["com",/^;[^\r\n]*/,null,";"],["pln",/^[\t\n\r \xA0]+/,null,"\t\n\r \u00a0"],["str",/^\"(?:[^\"\\]|\\[\s\S])*(?:\"|$)/,null,'"']],[["kwd",/^(?:block|c[ad]+r|catch|con[ds]|def(?:ine|un)|do|eq|eql|equal|equalp|eval-when|flet|format|go|if|labels|lambda|let|load-time-value|locally|macrolet|multiple-value-call|nil|progn|progv|quote|require|return-from|setq|symbol-macrolet|t|tagbody|the|throw|unwind)\b/,
18 | null],["lit",/^[+\-]?(?:[0#]x[0-9a-f]+|\d+\/\d+|(?:\.\d+|\d+(?:\.\d*)?)(?:[ed][+\-]?\d+)?)/i],["lit",/^\'(?:-*(?:\w|\\[\x21-\x7e])(?:[\w-]*|\\[\x21-\x7e])[=!?]?)?/],["pln",/^-*(?:[a-z_]|\\[\x21-\x7e])(?:[\w-]*|\\[\x21-\x7e])[=!?]?/i],["pun",/^[^\w\t\n\r \xA0()\"\\\';]+/]]),"cl el lisp lsp scm ss rkt".split(" "));
19 |
--------------------------------------------------------------------------------
/docs/api/vendor/prettify/lang-el.js:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | Copyright (C) 2008 Google Inc.
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 | */
17 | PR.registerLangHandler(PR.createSimpleLexer([["opn",/^\(+/,null,"("],["clo",/^\)+/,null,")"],["com",/^;[^\r\n]*/,null,";"],["pln",/^[\t\n\r \xA0]+/,null,"\t\n\r \u00a0"],["str",/^\"(?:[^\"\\]|\\[\s\S])*(?:\"|$)/,null,'"']],[["kwd",/^(?:block|c[ad]+r|catch|con[ds]|def(?:ine|un)|do|eq|eql|equal|equalp|eval-when|flet|format|go|if|labels|lambda|let|load-time-value|locally|macrolet|multiple-value-call|nil|progn|progv|quote|require|return-from|setq|symbol-macrolet|t|tagbody|the|throw|unwind)\b/,
18 | null],["lit",/^[+\-]?(?:[0#]x[0-9a-f]+|\d+\/\d+|(?:\.\d+|\d+(?:\.\d*)?)(?:[ed][+\-]?\d+)?)/i],["lit",/^\'(?:-*(?:\w|\\[\x21-\x7e])(?:[\w-]*|\\[\x21-\x7e])[=!?]?)?/],["pln",/^-*(?:[a-z_]|\\[\x21-\x7e])(?:[\w-]*|\\[\x21-\x7e])[=!?]?/i],["pun",/^[^\w\t\n\r \xA0()\"\\\';]+/]]),"cl el lisp lsp scm ss rkt".split(" "));
19 |
--------------------------------------------------------------------------------
/docs/api/vendor/prettify/lang-ss.js:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | Copyright (C) 2008 Google Inc.
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 | */
17 | PR.registerLangHandler(PR.createSimpleLexer([["opn",/^\(+/,null,"("],["clo",/^\)+/,null,")"],["com",/^;[^\r\n]*/,null,";"],["pln",/^[\t\n\r \xA0]+/,null,"\t\n\r \u00a0"],["str",/^\"(?:[^\"\\]|\\[\s\S])*(?:\"|$)/,null,'"']],[["kwd",/^(?:block|c[ad]+r|catch|con[ds]|def(?:ine|un)|do|eq|eql|equal|equalp|eval-when|flet|format|go|if|labels|lambda|let|load-time-value|locally|macrolet|multiple-value-call|nil|progn|progv|quote|require|return-from|setq|symbol-macrolet|t|tagbody|the|throw|unwind)\b/,
18 | null],["lit",/^[+\-]?(?:[0#]x[0-9a-f]+|\d+\/\d+|(?:\.\d+|\d+(?:\.\d*)?)(?:[ed][+\-]?\d+)?)/i],["lit",/^\'(?:-*(?:\w|\\[\x21-\x7e])(?:[\w-]*|\\[\x21-\x7e])[=!?]?)?/],["pln",/^-*(?:[a-z_]|\\[\x21-\x7e])(?:[\w-]*|\\[\x21-\x7e])[=!?]?/i],["pun",/^[^\w\t\n\r \xA0()\"\\\';]+/]]),"cl el lisp lsp scm ss rkt".split(" "));
19 |
--------------------------------------------------------------------------------
/docs/api/vendor/prettify/lang-lisp.js:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | Copyright (C) 2008 Google Inc.
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 | */
17 | PR.registerLangHandler(PR.createSimpleLexer([["opn",/^\(+/,null,"("],["clo",/^\)+/,null,")"],["com",/^;[^\r\n]*/,null,";"],["pln",/^[\t\n\r \xA0]+/,null,"\t\n\r \u00a0"],["str",/^\"(?:[^\"\\]|\\[\s\S])*(?:\"|$)/,null,'"']],[["kwd",/^(?:block|c[ad]+r|catch|con[ds]|def(?:ine|un)|do|eq|eql|equal|equalp|eval-when|flet|format|go|if|labels|lambda|let|load-time-value|locally|macrolet|multiple-value-call|nil|progn|progv|quote|require|return-from|setq|symbol-macrolet|t|tagbody|the|throw|unwind)\b/,
18 | null],["lit",/^[+\-]?(?:[0#]x[0-9a-f]+|\d+\/\d+|(?:\.\d+|\d+(?:\.\d*)?)(?:[ed][+\-]?\d+)?)/i],["lit",/^\'(?:-*(?:\w|\\[\x21-\x7e])(?:[\w-]*|\\[\x21-\x7e])[=!?]?)?/],["pln",/^-*(?:[a-z_]|\\[\x21-\x7e])(?:[\w-]*|\\[\x21-\x7e])[=!?]?/i],["pun",/^[^\w\t\n\r \xA0()\"\\\';]+/]]),"cl el lisp lsp scm ss rkt".split(" "));
19 |
--------------------------------------------------------------------------------
/docs/api/vendor/prettify/lang-lsp.js:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | Copyright (C) 2008 Google Inc.
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 | */
17 | PR.registerLangHandler(PR.createSimpleLexer([["opn",/^\(+/,null,"("],["clo",/^\)+/,null,")"],["com",/^;[^\r\n]*/,null,";"],["pln",/^[\t\n\r \xA0]+/,null,"\t\n\r \u00a0"],["str",/^\"(?:[^\"\\]|\\[\s\S])*(?:\"|$)/,null,'"']],[["kwd",/^(?:block|c[ad]+r|catch|con[ds]|def(?:ine|un)|do|eq|eql|equal|equalp|eval-when|flet|format|go|if|labels|lambda|let|load-time-value|locally|macrolet|multiple-value-call|nil|progn|progv|quote|require|return-from|setq|symbol-macrolet|t|tagbody|the|throw|unwind)\b/,
18 | null],["lit",/^[+\-]?(?:[0#]x[0-9a-f]+|\d+\/\d+|(?:\.\d+|\d+(?:\.\d*)?)(?:[ed][+\-]?\d+)?)/i],["lit",/^\'(?:-*(?:\w|\\[\x21-\x7e])(?:[\w-]*|\\[\x21-\x7e])[=!?]?)?/],["pln",/^-*(?:[a-z_]|\\[\x21-\x7e])(?:[\w-]*|\\[\x21-\x7e])[=!?]?/i],["pun",/^[^\w\t\n\r \xA0()\"\\\';]+/]]),"cl el lisp lsp scm ss rkt".split(" "));
19 |
--------------------------------------------------------------------------------
/docs/api/vendor/prettify/lang-rkt.js:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | Copyright (C) 2008 Google Inc.
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 | */
17 | PR.registerLangHandler(PR.createSimpleLexer([["opn",/^\(+/,null,"("],["clo",/^\)+/,null,")"],["com",/^;[^\r\n]*/,null,";"],["pln",/^[\t\n\r \xA0]+/,null,"\t\n\r \u00a0"],["str",/^\"(?:[^\"\\]|\\[\s\S])*(?:\"|$)/,null,'"']],[["kwd",/^(?:block|c[ad]+r|catch|con[ds]|def(?:ine|un)|do|eq|eql|equal|equalp|eval-when|flet|format|go|if|labels|lambda|let|load-time-value|locally|macrolet|multiple-value-call|nil|progn|progv|quote|require|return-from|setq|symbol-macrolet|t|tagbody|the|throw|unwind)\b/,
18 | null],["lit",/^[+\-]?(?:[0#]x[0-9a-f]+|\d+\/\d+|(?:\.\d+|\d+(?:\.\d*)?)(?:[ed][+\-]?\d+)?)/i],["lit",/^\'(?:-*(?:\w|\\[\x21-\x7e])(?:[\w-]*|\\[\x21-\x7e])[=!?]?)?/],["pln",/^-*(?:[a-z_]|\\[\x21-\x7e])(?:[\w-]*|\\[\x21-\x7e])[=!?]?/i],["pun",/^[^\w\t\n\r \xA0()\"\\\';]+/]]),"cl el lisp lsp scm ss rkt".split(" "));
19 |
--------------------------------------------------------------------------------
/docs/api/vendor/prettify/lang-scm.js:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | Copyright (C) 2008 Google Inc.
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 | */
17 | PR.registerLangHandler(PR.createSimpleLexer([["opn",/^\(+/,null,"("],["clo",/^\)+/,null,")"],["com",/^;[^\r\n]*/,null,";"],["pln",/^[\t\n\r \xA0]+/,null,"\t\n\r \u00a0"],["str",/^\"(?:[^\"\\]|\\[\s\S])*(?:\"|$)/,null,'"']],[["kwd",/^(?:block|c[ad]+r|catch|con[ds]|def(?:ine|un)|do|eq|eql|equal|equalp|eval-when|flet|format|go|if|labels|lambda|let|load-time-value|locally|macrolet|multiple-value-call|nil|progn|progv|quote|require|return-from|setq|symbol-macrolet|t|tagbody|the|throw|unwind)\b/,
18 | null],["lit",/^[+\-]?(?:[0#]x[0-9a-f]+|\d+\/\d+|(?:\.\d+|\d+(?:\.\d*)?)(?:[ed][+\-]?\d+)?)/i],["lit",/^\'(?:-*(?:\w|\\[\x21-\x7e])(?:[\w-]*|\\[\x21-\x7e])[=!?]?)?/],["pln",/^-*(?:[a-z_]|\\[\x21-\x7e])(?:[\w-]*|\\[\x21-\x7e])[=!?]?/i],["pun",/^[^\w\t\n\r \xA0()\"\\\';]+/]]),"cl el lisp lsp scm ss rkt".split(" "));
19 |
--------------------------------------------------------------------------------
/docs/api/locales/locale.js:
--------------------------------------------------------------------------------
1 | define([
2 | './locales/ca.js',
3 | './locales/cs.js',
4 | './locales/de.js',
5 | './locales/es.js',
6 | './locales/fr.js',
7 | './locales/it.js',
8 | './locales/nl.js',
9 | './locales/pl.js',
10 | './locales/pt_br.js',
11 | './locales/ro.js',
12 | './locales/ru.js',
13 | './locales/tr.js',
14 | './locales/vi.js',
15 | './locales/zh.js',
16 | './locales/zh_cn.js'
17 | ], function() {
18 | var langId = (navigator.language || navigator.userLanguage).toLowerCase().replace('-', '_');
19 | var language = langId.substr(0, 2);
20 | var locales = {};
21 |
22 | for (index in arguments) {
23 | for (property in arguments[index])
24 | locales[property] = arguments[index][property];
25 | }
26 | if ( ! locales['en'])
27 | locales['en'] = {};
28 |
29 | if ( ! locales[langId] && ! locales[language])
30 | language = 'en';
31 |
32 | var locale = (locales[langId] ? locales[langId] : locales[language]);
33 |
34 | function __(text) {
35 | var index = locale[text];
36 | if (index === undefined)
37 | return text;
38 | return index;
39 | };
40 |
41 | function setLanguage(language) {
42 | locale = locales[language];
43 | }
44 |
45 | return {
46 | __ : __,
47 | locales : locales,
48 | locale : locale,
49 | setLanguage: setLanguage
50 | };
51 | });
52 |
--------------------------------------------------------------------------------
/docs/api/vendor/prettify/lang-lgt.js:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | Copyright (C) 2014 Paulo Moura
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 | */
17 | PR.registerLangHandler(PR.createSimpleLexer([["str",/^\"(?:[^\"\\\n\x0C\r]|\\[\s\S])*(?:\"|$)/,null,'"'],["lit",/^[a-z][a-zA-Z0-9_]*/],["lit",/^\'(?:[^\'\\\n\x0C\r]|\\[^&])+\'?/,null,"'"],["lit",/^(?:0'.|0b[0-1]+|0o[0-7]+|0x[\da-f]+|\d+(?:\.\d+)?(?:e[+\-]?\d+)?)/i,null,"0123456789"]],[["com",/^%[^\r\n]*/,null,"%"],["com",/^\/\*[\s\S]*?\*\//],["kwd",/^\s*:-\s(c(a(lls|tegory)|oinductive)|p(ublic|r(ot(ocol|ected)|ivate))|e(l(if|se)|n(coding|sure_loaded)|xport)|i(f|n(clude|itialization|fo))|alias|d(ynamic|iscontiguous)|m(eta_(non_terminal|predicate)|od(e|ule)|ultifile)|reexport|s(et_(logtalk|prolog)_flag|ynchronized)|o(bject|p)|use(s|_module))/],
18 | ["kwd",/^\s*:-\s(e(lse|nd(if|_(category|object|protocol)))|built_in|dynamic|synchronized|threaded)/],["typ",/^[A-Z_][a-zA-Z0-9_]*/],["pun",/^[.,;{}:^<>=\\/+*?#!-]/]]),["logtalk","lgt"]);
19 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
2 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
3 |
4 | # User-specific stuff
5 | .idea/**/workspace.xml
6 | .idea/**/tasks.xml
7 | .idea/**/dictionaries
8 | .idea/**/shelf
9 |
10 | # Sensitive or high-churn files
11 | .idea/**/dataSources/
12 | .idea/**/dataSources.ids
13 | .idea/**/dataSources.local.xml
14 | .idea/**/sqlDataSources.xml
15 | .idea/**/dynamic.xml
16 | .idea/**/uiDesigner.xml
17 |
18 | # Gradle
19 | .idea/**/gradle.xml
20 | .idea/**/libraries
21 |
22 | # CMake
23 | cmake-build-debug/
24 | cmake-build-release/
25 |
26 | # Mongo Explorer plugin
27 | .idea/**/mongoSettings.xml
28 |
29 | # File-based project format
30 | *.iws
31 |
32 | # IntelliJ
33 | out/
34 |
35 | # mpeltonen/sbt-idea plugin
36 | .idea_modules/
37 |
38 | # JIRA plugin
39 | atlassian-ide-plugin.xml
40 |
41 | # Cursive Clojure plugin
42 | .idea/replstate.xml
43 |
44 | # Crashlytics plugin (for Android Studio and IntelliJ)
45 | com_crashlytics_export_strings.xml
46 | crashlytics.properties
47 | crashlytics-build.properties
48 | fabric.properties
49 |
50 | # Editor-based Rest Client
51 | .idea/httpRequests
52 |
53 | # Root Idea Folder
54 |
55 | # Node JS
56 | node_modules
57 |
58 | #env file
59 | .env
60 |
61 | #creds
62 | gcp_creds.json
63 |
64 | #certbot
65 | certbot/
66 |
67 | assets/.DS_Store
68 |
69 | #secrets
70 | secret.yaml
71 | package-lock.json
72 |
--------------------------------------------------------------------------------
/docs/api/vendor/prettify/lang-logtalk.js:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | Copyright (C) 2014 Paulo Moura
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 | */
17 | PR.registerLangHandler(PR.createSimpleLexer([["str",/^\"(?:[^\"\\\n\x0C\r]|\\[\s\S])*(?:\"|$)/,null,'"'],["lit",/^[a-z][a-zA-Z0-9_]*/],["lit",/^\'(?:[^\'\\\n\x0C\r]|\\[^&])+\'?/,null,"'"],["lit",/^(?:0'.|0b[0-1]+|0o[0-7]+|0x[\da-f]+|\d+(?:\.\d+)?(?:e[+\-]?\d+)?)/i,null,"0123456789"]],[["com",/^%[^\r\n]*/,null,"%"],["com",/^\/\*[\s\S]*?\*\//],["kwd",/^\s*:-\s(c(a(lls|tegory)|oinductive)|p(ublic|r(ot(ocol|ected)|ivate))|e(l(if|se)|n(coding|sure_loaded)|xport)|i(f|n(clude|itialization|fo))|alias|d(ynamic|iscontiguous)|m(eta_(non_terminal|predicate)|od(e|ule)|ultifile)|reexport|s(et_(logtalk|prolog)_flag|ynchronized)|o(bject|p)|use(s|_module))/],
18 | ["kwd",/^\s*:-\s(e(lse|nd(if|_(category|object|protocol)))|built_in|dynamic|synchronized|threaded)/],["typ",/^[A-Z_][a-zA-Z0-9_]*/],["pun",/^[.,;{}:^<>=\\/+*?#!-]/]]),["logtalk","lgt"]);
19 |
--------------------------------------------------------------------------------
/tests/util/role.test.util.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | const Role = require("../../models/role.model");
3 | const Constants = {
4 | General: require("../../constants/general.constant"),
5 | Role: require("../../constants/role.constant")
6 | };
7 | const Routes = require("../../constants/routes.constant");
8 | const mongoose = require("mongoose");
9 | const logger = require("../../services/logger.service");
10 |
11 | const newRole1 = {
12 | name: "newRole",
13 | routes: [Routes.hackerRoutes.getSelf, Routes.hackerRoutes.getSelfById]
14 | };
15 |
16 | const duplicateRole1 = {
17 | name: "duplicateRole",
18 | routes: [Routes.hackerRoutes.getAnyById]
19 | };
20 |
21 | function store(attributes) {
22 | const roleDocs = [];
23 | const roleNames = [];
24 | attributes.forEach((attribute) => {
25 | roleDocs.push(new Role(attribute));
26 | roleNames.push(attribute.name);
27 | });
28 |
29 | return Role.collection.insertMany(roleDocs);
30 | }
31 |
32 | async function storeAll() {
33 | await store(Constants.Role.allRolesArray);
34 | }
35 |
36 | async function dropAll() {
37 | try {
38 | await Role.collection.drop();
39 | } catch (e) {
40 | if (e.code === 26) {
41 | logger.info("namespace %s not found", Role.collection.name);
42 | } else {
43 | throw e;
44 | }
45 | }
46 | }
47 |
48 | module.exports = {
49 | newRole1: newRole1,
50 | duplicateRole1: duplicateRole1,
51 | storeAll: storeAll,
52 | dropAll: dropAll
53 | };
54 |
--------------------------------------------------------------------------------
/docs/api/vendor/prettify/lang-clj.js:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2011 Google Inc.
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | PR.registerLangHandler(PR.createSimpleLexer([["opn",/^[\(\{\[]+/,null,"([{"],["clo",/^[\)\}\]]+/,null,")]}"],["com",/^;[^\r\n]*/,null,";"],["pln",/^[\t\n\r \xA0]+/,null,"\t\n\r \u00a0"],["str",/^\"(?:[^\"\\]|\\[\s\S])*(?:\"|$)/,null,'"']],[["kwd",/^(?:def|if|do|let|quote|var|fn|loop|recur|throw|try|monitor-enter|monitor-exit|defmacro|defn|defn-|macroexpand|macroexpand-1|for|doseq|dosync|dotimes|and|or|when|not|assert|doto|proxy|defstruct|first|rest|cons|defprotocol|deftype|defrecord|reify|defmulti|defmethod|meta|with-meta|ns|in-ns|create-ns|import|intern|refer|alias|namespace|resolve|ref|deref|refset|new|set!|memfn|to-array|into-array|aset|gen-class|reduce|map|filter|find|nil?|empty?|hash-map|hash-set|vec|vector|seq|flatten|reverse|assoc|dissoc|list|list?|disj|get|union|difference|intersection|extend|extend-type|extend-protocol|prn)\b/,
17 | null],["typ",/^:[0-9a-zA-Z\-]+/]]),["clj"]);
18 |
--------------------------------------------------------------------------------
/docs/api/vendor/prettify/lang-mumps.js:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | Copyright (C) 2011 Kitware Inc.
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 | */
17 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\r \xA0]+/,null,"\t\n\r \u00a0"],["str",/^(?:"(?:[^"]|\\.)*")/,null,'"']],[["com",/^;[^\r\n]*/,null,";"],["dec",/^(?:\$(?:D|DEVICE|EC|ECODE|ES|ESTACK|ET|ETRAP|H|HOROLOG|I|IO|J|JOB|K|KEY|P|PRINCIPAL|Q|QUIT|ST|STACK|S|STORAGE|SY|SYSTEM|T|TEST|TL|TLEVEL|TR|TRESTART|X|Y|Z[A-Z]*|A|ASCII|C|CHAR|D|DATA|E|EXTRACT|F|FIND|FN|FNUMBER|G|GET|J|JUSTIFY|L|LENGTH|NA|NAME|O|ORDER|P|PIECE|QL|QLENGTH|QS|QSUBSCRIPT|Q|QUERY|R|RANDOM|RE|REVERSE|S|SELECT|ST|STACK|T|TEXT|TR|TRANSLATE|NaN))\b/i,
18 | null],["kwd",/^(?:[^\$]B|BREAK|C|CLOSE|D|DO|E|ELSE|F|FOR|G|GOTO|H|HALT|H|HANG|I|IF|J|JOB|K|KILL|L|LOCK|M|MERGE|N|NEW|O|OPEN|Q|QUIT|R|READ|S|SET|TC|TCOMMIT|TRE|TRESTART|TRO|TROLLBACK|TS|TSTART|U|USE|V|VIEW|W|WRITE|X|XECUTE)\b/i,null],["lit",/^[+-]?(?:(?:\.\d+|\d+(?:\.\d*)?)(?:E[+\-]?\d+)?)/i],["pln",/^[a-z][a-zA-Z0-9]*/i],["pun",/^[^\w\t\n\r\xA0\"\$;%\^]|_/]]),["mumps"]);
19 |
--------------------------------------------------------------------------------
/docs/api/vendor/prettify/lang-css.js:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | Copyright (C) 2009 Google Inc.
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 | */
17 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[ \t\r\n\f]+/,null," \t\r\n\f"]],[["str",/^\"(?:[^\n\r\f\\\"]|\\(?:\r\n?|\n|\f)|\\[\s\S])*\"/,null],["str",/^\'(?:[^\n\r\f\\\']|\\(?:\r\n?|\n|\f)|\\[\s\S])*\'/,null],["lang-css-str",/^url\(([^\)\"\']+)\)/i],["kwd",/^(?:url|rgb|\!important|@import|@page|@media|@charset|inherit)(?=[^\-\w]|$)/i,null],["lang-css-kw",/^(-?(?:[_a-z]|(?:\\[0-9a-f]+ ?))(?:[_a-z0-9\-]|\\(?:\\[0-9a-f]+ ?))*)\s*:/i],["com",/^\/\*[^*]*\*+(?:[^\/*][^*]*\*+)*\//],
18 | ["com",/^(?:\x3c!--|--\x3e)/],["lit",/^(?:\d+|\d*\.\d+)(?:%|[a-z]+)?/i],["lit",/^#(?:[0-9a-f]{3}){1,2}\b/i],["pln",/^-?(?:[_a-z]|(?:\\[\da-f]+ ?))(?:[_a-z\d\-]|\\(?:\\[\da-f]+ ?))*/i],["pun",/^[^\s\w\'\"]+/]]),["css"]);PR.registerLangHandler(PR.createSimpleLexer([],[["kwd",/^-?(?:[_a-z]|(?:\\[\da-f]+ ?))(?:[_a-z\d\-]|\\(?:\\[\da-f]+ ?))*/i]]),["css-kw"]);PR.registerLangHandler(PR.createSimpleLexer([],[["str",/^[^\)\"\']+/]]),["css-str"]);
19 |
--------------------------------------------------------------------------------
/models/travel.model.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | const Constants = require("../constants/general.constant");
3 | const mongoose = require("mongoose");
4 | //describes the data type
5 | const TravelSchema = new mongoose.Schema({
6 | accountId: {
7 | // The account this travel data is associated with
8 | type: mongoose.Schema.Types.ObjectId,
9 | ref: "Account",
10 | required: true
11 | },
12 | hackerId: {
13 | // The hacker this travel data is associated with
14 | type: mongoose.Schema.Types.ObjectId,
15 | ref: "Hacker",
16 | required: true
17 | },
18 | status: {
19 | // Has this hacker been approved for funds, etc.
20 | type: String,
21 | enum: Constants.TRAVEL_STATUSES,
22 | required: true,
23 | default: "None"
24 | },
25 | request: {
26 | // Amount of money hacker has requested for travel
27 | amount: {
28 | type: Number,
29 | required: true
30 | },
31 | reason: {
32 | type: String,
33 | required: true,
34 | default: ""
35 | }
36 | },
37 | offer: {
38 | // Amount of money we have offered hacker for travel
39 | type: Number,
40 | default: 0
41 | }
42 | });
43 |
44 | TravelSchema.methods.toJSON = function(options) {
45 | const ts = this.toObject(options);
46 | delete ts.__v;
47 | ts.id = ts._id;
48 | delete ts._id;
49 | return ts;
50 | };
51 |
52 | //export the model
53 | module.exports = mongoose.model("Travel", TravelSchema);
54 |
--------------------------------------------------------------------------------
/docs/api/vendor/prettify/lang-scala.js:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | Copyright (C) 2010 Google Inc.
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 | */
17 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\r \xA0]+/,null,"\t\n\r \u00a0"],["str",/^(?:"(?:(?:""(?:""?(?!")|[^\\"]|\\.)*"{0,3})|(?:[^"\r\n\\]|\\.)*"?))/,null,'"'],["lit",/^`(?:[^\r\n\\`]|\\.)*`?/,null,"`"],["pun",/^[!#%&()*+,\-:;<=>?@\[\\\]^{|}~]+/,null,"!#%&()*+,-:;<=>?@[\\]^{|}~"]],[["str",/^'(?:[^\r\n\\']|\\(?:'|[^\r\n']+))'/],["lit",/^'[a-zA-Z_$][\w$]*(?!['$\w])/],["kwd",/^(?:abstract|case|catch|class|def|do|else|extends|final|finally|for|forSome|if|implicit|import|lazy|match|new|object|override|package|private|protected|requires|return|sealed|super|throw|trait|try|type|val|var|while|with|yield)\b/],
18 | ["lit",/^(?:true|false|null|this)\b/],["lit",/^(?:(?:0(?:[0-7]+|X[0-9A-F]+))L?|(?:(?:0|[1-9][0-9]*)(?:(?:\.[0-9]+)?(?:E[+\-]?[0-9]+)?F?|L?))|\\.[0-9]+(?:E[+\-]?[0-9]+)?F?)/i],["typ",/^[$_]*[A-Z][_$A-Z0-9]*[a-z][\w$]*/],["pln",/^[$a-zA-Z_][\w$]*/],["com",/^\/(?:\/.*|\*(?:\/|\**[^*/])*(?:\*+\/?)?)/],["pun",/^(?:\.+|\/)/]]),["scala"]);
19 |
--------------------------------------------------------------------------------
/docs/getting-started.md:
--------------------------------------------------------------------------------
1 | # How to get started
2 |
3 | ## What you will need before you can use this
4 |
5 | * A google cloud provider account:
6 | * Google storage bucket.
7 | * Sendgrid account and the sendgrid_api_key
8 |
9 | ## Setting up this repo
10 |
11 | 1. Clone the repository: `git clone https://github.com/hackmcgill/hackerAPI.git`
12 | 2. Make sure you have the following tools:
13 | 1. `git`:
14 | 2. `mongodb`:
15 | 1. Make sure you also have the `/data/db` directory.
16 | 2. To test the installation, run `mongod`.
17 | 3. `node`:
18 | 4. `npm`: .
19 | 5. `Postman`: . We use this for testing the API locally.
20 | 3. Make sure you have the following (only if you are going to be publishing this as a kubernetes cluster on google cloud):
21 | 1. `kubectl`:
22 | 2. `gcloud`:
23 | 4. Create a `.env` file in the root directory, and populate the fields as per `.env.example`.
24 | 5. run `npm install`
25 |
26 | ## Setting up the database
27 |
28 | 1. Determine which environment the database you want to seed belongs to (`deployment`, `development`, or `test`).
29 | 2. Navigate to `package.json`, and confirm that at the `seed` script, `NODE_ENV` is set to the proper environment.
30 | 3. Run `npm run seed`.
31 |
32 | ## Testing the API
33 |
34 | In order to test that you have set up the API properly, run `npm run test`.
--------------------------------------------------------------------------------
/services/volunteer.service.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | const Volunteer = require("../models/volunteer.model");
3 | const logger = require("./logger.service");
4 |
5 | /**
6 | * @function createVolunteer
7 | * @param {{_id: ObjectId, accountId: ObjectId}} volunteerDetails
8 | * @return {Promise} The promise will resolve to a volunteer object if save was successful.
9 | * @description Adds a new volunteer to database.
10 | */
11 | function createVolunteer(volunteerDetails) {
12 | const TAG = `[Volunteer Service # createTeam]:`;
13 |
14 | const volunteer = new Volunteer(volunteerDetails);
15 |
16 | return volunteer.save();
17 | }
18 |
19 | /**
20 | * @function findById
21 | * @param {ObjectId} id
22 | * @return {DocumentQuery} The document query will resolve to volunteer or null.
23 | * @description Finds an volunteer by the id, which is the mongoId.
24 | */
25 | function findById(id) {
26 | const TAG = `[Volunteer Service # findById ]:`;
27 |
28 | return logger.logQuery(TAG, "volunteer", id, Volunteer.findById(id));
29 | }
30 |
31 | /**
32 | * @function findByAccountId
33 | * @param {ObjectId} accountId
34 | * @return {DocumentQuery} A volunteer document queried by accountId
35 | */
36 | function findByAccountId(accountId) {
37 | const TAG = `[ Volunteer Service # findByAccountId ]:`;
38 |
39 | const query = {
40 | accountId: accountId
41 | };
42 |
43 | return logger.logUpdate(TAG, "volunteer", Volunteer.findOne(query));
44 | }
45 |
46 | module.exports = {
47 | createVolunteer: createVolunteer,
48 | findById: findById,
49 | findByAccountId: findByAccountId
50 | };
51 |
--------------------------------------------------------------------------------
/docs/api/vendor/prettify/lang-aea.js:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | Copyright (C) 2009 Onno Hommes.
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 | */
17 | PR.registerLangHandler(PR.createSimpleLexer([["com",/^#[^\r\n]*/,null,"#"],["pln",/^[\t\n\r \xA0]+/,null,"\t\n\r \u00a0"],["str",/^\"(?:[^\"\\]|\\[\s\S])*(?:\"|$)/,null,'"']],[["kwd",/^(?:ADS|AD|AUG|BZF|BZMF|CAE|CAF|CA|CCS|COM|CS|DAS|DCA|DCOM|DCS|DDOUBL|DIM|DOUBLE|DTCB|DTCF|DV|DXCH|EDRUPT|EXTEND|INCR|INDEX|NDX|INHINT|LXCH|MASK|MSK|MP|MSU|NOOP|OVSK|QXCH|RAND|READ|RELINT|RESUME|RETURN|ROR|RXOR|SQUARE|SU|TCR|TCAA|OVSK|TCF|TC|TS|WAND|WOR|WRITE|XCH|XLQ|XXALQ|ZL|ZQ|ADD|ADZ|SUB|SUZ|MPY|MPR|MPZ|DVP|COM|ABS|CLA|CLZ|LDQ|STO|STQ|ALS|LLS|LRS|TRA|TSQ|TMI|TOV|AXT|TIX|DLY|INP|OUT)\s/,
18 | null],["typ",/^(?:-?GENADR|=MINUS|2BCADR|VN|BOF|MM|-?2CADR|-?[1-6]DNADR|ADRES|BBCON|[SE]?BANK\=?|BLOCK|BNKSUM|E?CADR|COUNT\*?|2?DEC\*?|-?DNCHAN|-?DNPTR|EQUALS|ERASE|MEMORY|2?OCT|REMADR|SETLOC|SUBRO|ORG|BSS|BES|SYN|EQU|DEFINE|END)\s/,null],["lit",/^\'(?:-*(?:\w|\\[\x21-\x7e])(?:[\w-]*|\\[\x21-\x7e])[=!?]?)?/],["pln",/^-*(?:[!-z_]|\\[\x21-\x7e])(?:[\w-]*|\\[\x21-\x7e])[=!?]?/i],["pun",/^[^\w\t\n\r \xA0()\"\\\';]+/]]),["apollo","agc","aea"]);
19 |
--------------------------------------------------------------------------------
/docs/api/vendor/prettify/lang-agc.js:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | Copyright (C) 2009 Onno Hommes.
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 | */
17 | PR.registerLangHandler(PR.createSimpleLexer([["com",/^#[^\r\n]*/,null,"#"],["pln",/^[\t\n\r \xA0]+/,null,"\t\n\r \u00a0"],["str",/^\"(?:[^\"\\]|\\[\s\S])*(?:\"|$)/,null,'"']],[["kwd",/^(?:ADS|AD|AUG|BZF|BZMF|CAE|CAF|CA|CCS|COM|CS|DAS|DCA|DCOM|DCS|DDOUBL|DIM|DOUBLE|DTCB|DTCF|DV|DXCH|EDRUPT|EXTEND|INCR|INDEX|NDX|INHINT|LXCH|MASK|MSK|MP|MSU|NOOP|OVSK|QXCH|RAND|READ|RELINT|RESUME|RETURN|ROR|RXOR|SQUARE|SU|TCR|TCAA|OVSK|TCF|TC|TS|WAND|WOR|WRITE|XCH|XLQ|XXALQ|ZL|ZQ|ADD|ADZ|SUB|SUZ|MPY|MPR|MPZ|DVP|COM|ABS|CLA|CLZ|LDQ|STO|STQ|ALS|LLS|LRS|TRA|TSQ|TMI|TOV|AXT|TIX|DLY|INP|OUT)\s/,
18 | null],["typ",/^(?:-?GENADR|=MINUS|2BCADR|VN|BOF|MM|-?2CADR|-?[1-6]DNADR|ADRES|BBCON|[SE]?BANK\=?|BLOCK|BNKSUM|E?CADR|COUNT\*?|2?DEC\*?|-?DNCHAN|-?DNPTR|EQUALS|ERASE|MEMORY|2?OCT|REMADR|SETLOC|SUBRO|ORG|BSS|BES|SYN|EQU|DEFINE|END)\s/,null],["lit",/^\'(?:-*(?:\w|\\[\x21-\x7e])(?:[\w-]*|\\[\x21-\x7e])[=!?]?)?/],["pln",/^-*(?:[!-z_]|\\[\x21-\x7e])(?:[\w-]*|\\[\x21-\x7e])[=!?]?/i],["pun",/^[^\w\t\n\r \xA0()\"\\\';]+/]]),["apollo","agc","aea"]);
19 |
--------------------------------------------------------------------------------
/docs/api/vendor/prettify/lang-apollo.js:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | Copyright (C) 2009 Onno Hommes.
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 | */
17 | PR.registerLangHandler(PR.createSimpleLexer([["com",/^#[^\r\n]*/,null,"#"],["pln",/^[\t\n\r \xA0]+/,null,"\t\n\r \u00a0"],["str",/^\"(?:[^\"\\]|\\[\s\S])*(?:\"|$)/,null,'"']],[["kwd",/^(?:ADS|AD|AUG|BZF|BZMF|CAE|CAF|CA|CCS|COM|CS|DAS|DCA|DCOM|DCS|DDOUBL|DIM|DOUBLE|DTCB|DTCF|DV|DXCH|EDRUPT|EXTEND|INCR|INDEX|NDX|INHINT|LXCH|MASK|MSK|MP|MSU|NOOP|OVSK|QXCH|RAND|READ|RELINT|RESUME|RETURN|ROR|RXOR|SQUARE|SU|TCR|TCAA|OVSK|TCF|TC|TS|WAND|WOR|WRITE|XCH|XLQ|XXALQ|ZL|ZQ|ADD|ADZ|SUB|SUZ|MPY|MPR|MPZ|DVP|COM|ABS|CLA|CLZ|LDQ|STO|STQ|ALS|LLS|LRS|TRA|TSQ|TMI|TOV|AXT|TIX|DLY|INP|OUT)\s/,
18 | null],["typ",/^(?:-?GENADR|=MINUS|2BCADR|VN|BOF|MM|-?2CADR|-?[1-6]DNADR|ADRES|BBCON|[SE]?BANK\=?|BLOCK|BNKSUM|E?CADR|COUNT\*?|2?DEC\*?|-?DNCHAN|-?DNPTR|EQUALS|ERASE|MEMORY|2?OCT|REMADR|SETLOC|SUBRO|ORG|BSS|BES|SYN|EQU|DEFINE|END)\s/,null],["lit",/^\'(?:-*(?:\w|\\[\x21-\x7e])(?:[\w-]*|\\[\x21-\x7e])[=!?]?)?/],["pln",/^-*(?:[!-z_]|\\[\x21-\x7e])(?:[\w-]*|\\[\x21-\x7e])[=!?]?/i],["pun",/^[^\w\t\n\r \xA0()\"\\\';]+/]]),["apollo","agc","aea"]);
19 |
--------------------------------------------------------------------------------
/docs/api/vendor/prettify/lang-dart.js:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | Copyright (C) 2013 Google Inc.
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 | */
17 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\r \xA0]+/,null,"\t\n\r \u00a0"]],[["com",/^#!(?:.*)/],["kwd",/^\b(?:import|library|part of|part|as|show|hide)\b/i],["com",/^\/\/(?:.*)/],["com",/^\/\*[^*]*\*+(?:[^\/*][^*]*\*+)*\//],["kwd",/^\b(?:class|interface)\b/i],["kwd",/^\b(?:assert|async|await|break|case|catch|continue|default|do|else|finally|for|if|in|is|new|return|super|switch|sync|this|throw|try|while)\b/i],["kwd",/^\b(?:abstract|const|extends|factory|final|get|implements|native|operator|set|static|typedef|var)\b/i],
18 | ["typ",/^\b(?:bool|double|Dynamic|int|num|Object|String|void)\b/i],["kwd",/^\b(?:false|null|true)\b/i],["str",/^r?[\']{3}[\s|\S]*?[^\\][\']{3}/],["str",/^r?[\"]{3}[\s|\S]*?[^\\][\"]{3}/],["str",/^r?\'(\'|(?:[^\n\r\f])*?[^\\]\')/],["str",/^r?\"(\"|(?:[^\n\r\f])*?[^\\]\")/],["typ",/^[A-Z]\w*/],["pln",/^[a-z_$][a-z0-9_]*/i],["pun",/^[~!%^&*+=|?:<>/-]/],["lit",/^\b0x[0-9a-f]+/i],["lit",/^\b\d+(?:\.\d*)?(?:e[+-]?\d+)?/i],["lit",
19 | /^\b\.\d+(?:e[+-]?\d+)?/i],["pun",/^[(){}\[\],.;]/]]),["dart"]);
20 |
--------------------------------------------------------------------------------
/middlewares/role.middleware.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | const mongoose = require("mongoose");
3 | const Services = {
4 | Role: require("../services/role.service")
5 | };
6 | const Constants = {
7 | Error: require("../constants/error.constant")
8 | };
9 |
10 | /**
11 | * @function parseRole
12 | * @param {{body: name: String, routes: route[]}}} req
13 | * @param {*} res
14 | * @param {(err?)=>void} next
15 | * @return {void}
16 | * @description
17 | * Moves name and routes from req.body to req.body.roleDetails.
18 | * Adds _id to roleDetails.
19 | */
20 | function parseRole(req, res, next) {
21 | const roleDetails = {
22 | _id: new mongoose.Types.ObjectId(),
23 | name: req.body.name,
24 | routes: req.body.routes
25 | };
26 |
27 | delete req.body.name;
28 | delete req.body.routes;
29 |
30 | req.body.roleDetails = roleDetails;
31 |
32 | return next();
33 | }
34 |
35 | /**
36 | * @function createRole
37 | * @param {{body: {roleDetails: object}}} req
38 | * @param {*} res
39 | * @param {(err?)=>void} next
40 | * @return {void}
41 | * @description
42 | * Creates role document
43 | */
44 | async function createRole(req, res, next) {
45 | const roleDetails = req.body.roleDetails;
46 |
47 | const role = await Services.Role.createRole(roleDetails);
48 |
49 | if (role) {
50 | delete req.body.roleDetails;
51 | req.body.role = role;
52 | return next();
53 | } else {
54 | return next({
55 | status: 500,
56 | message: Constants.Error.ROLE_CREATE_500_MESSAGE,
57 | data: {}
58 | });
59 | }
60 | }
61 |
62 | module.exports = {
63 | parseRole: parseRole,
64 | createRole: createRole
65 | };
66 |
--------------------------------------------------------------------------------
/.github/PULL_REQUEST_TEMPLATE.md:
--------------------------------------------------------------------------------
1 | ### Tickets:
2 |
3 | - HAC-
4 | ### List of changes:
5 |
6 | Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.
7 |
8 | -
9 |
10 | ## Type of change
11 |
12 | Please delete options that are not relevant.
13 |
14 | - [ ] Bug fix (non-breaking change which fixes an issue)
15 | - [ ] New feature (non-breaking change which adds functionality)
16 | - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
17 | - [ ] New release
18 | - [ ] This change requires a documentation update
19 |
20 | ### How has this been tested?
21 |
22 | Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
23 |
24 | - [ ] Test A
25 | - [ ] Test B
26 |
27 | **Test Configuration**:
28 |
29 | **Firmware version:**
30 | **Hardware:**
31 | **Toolchain:**
32 | **SDK:**
33 |
34 | ### Questions for code reviewers?
35 |
36 | ### Checklist:
37 |
38 | - [ ] My code follows the style guidelines of this project
39 | - [ ] I have performed a self-review of my own code
40 | - [ ] I have commented my code, particularly in hard-to-understand areas
41 | - [ ] My changes generate no new warnings
42 | - [ ] Listed change(s) in the Changelog
43 | - [ ] I have added tests that prove my fix is effective or that my feature works
44 | - [ ] New and existing unit tests pass locally with my changes
45 | - [ ] I have made corresponding changes to the documentation
46 | - [ ] Any dependent changes have been merged and published in downstream modules
47 |
--------------------------------------------------------------------------------
/controllers/auth.controller.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | const Success = require("../constants/success.constant");
4 |
5 | module.exports = {
6 | onSuccessfulLogin: function(req, res) {
7 | return res.status(200).json({
8 | message: Success.AUTH_LOGIN,
9 | data: {}
10 | });
11 | },
12 | logout: function(req, res) {
13 | req.logout();
14 | return res.status(200).json({
15 | message: Success.AUTH_LOGOUT,
16 | data: {}
17 | });
18 | },
19 | sentResetEmail: function(req, res) {
20 | return res.status(200).json({
21 | message: Success.AUTH_SEND_RESET_EMAIL,
22 | data: {}
23 | });
24 | },
25 | resetPassword: function(req, res) {
26 | return res.status(200).json({
27 | message: Success.AUTH_RESET_PASSWORD,
28 | data: {}
29 | });
30 | },
31 | confirmAccount: function(req, res) {
32 | return res.status(200).json({
33 | message: Success.AUTH_CONFIRM_ACCOUNT,
34 | data: {}
35 | });
36 | },
37 | retrieveRoleBindings: function(req, res) {
38 | return res.status(200).json({
39 | message: Success.AUTH_GET_ROLE_BINDINGS,
40 | data: req.roleBindings.toJSON()
41 | });
42 | },
43 | sentConfirmationEmail: function(req, res) {
44 | return res.status(200).json({
45 | message: Success.AUTH_SEND_CONFIRMATION_EMAIL,
46 | data: {}
47 | });
48 | },
49 | retrievedRoles: function(req, res) {
50 | return res.status(200).json({
51 | message: Success.AUTH_GET_ROLES,
52 | data: req.roles
53 | });
54 | }
55 | };
56 |
--------------------------------------------------------------------------------
/docs/api/vendor/prettify/lang-fs.js:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | Copyright (C) 2008 Google Inc.
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 | */
17 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\r \xA0]+/,null,"\t\n\r \u00a0"],["com",/^#(?:if[\t\n\r \xA0]+(?:[a-z_$][\w\']*|``[^\r\n\t`]*(?:``|$))|else|endif|light)/i,null,"#"],["str",/^(?:\"(?:[^\"\\]|\\[\s\S])*(?:\"|$)|\'(?:[^\'\\]|\\[\s\S])(?:\'|$))/,null,"\"'"]],[["com",/^(?:\/\/[^\r\n]*|\(\*[\s\S]*?\*\))/],["kwd",/^(?:abstract|and|as|assert|begin|class|default|delegate|do|done|downcast|downto|elif|else|end|exception|extern|false|finally|for|fun|function|if|in|inherit|inline|interface|internal|lazy|let|match|member|module|mutable|namespace|new|null|of|open|or|override|private|public|rec|return|static|struct|then|to|true|try|type|upcast|use|val|void|when|while|with|yield|asr|land|lor|lsl|lsr|lxor|mod|sig|atomic|break|checked|component|const|constraint|constructor|continue|eager|event|external|fixed|functor|global|include|method|mixin|object|parallel|process|protected|pure|sealed|trait|virtual|volatile)\b/],
18 | ["lit",/^[+\-]?(?:0x[\da-f]+|(?:(?:\.\d+|\d+(?:\.\d*)?)(?:e[+\-]?\d+)?))/i],["pln",/^(?:[a-z_][\w']*[!?#]?|``[^\r\n\t`]*(?:``|$))/i],["pun",/^[^\t\n\r \xA0\"\'\w]+/]]),["fs","ml"]);
19 |
--------------------------------------------------------------------------------
/docs/api/vendor/prettify/lang-ml.js:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | Copyright (C) 2008 Google Inc.
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 | */
17 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\r \xA0]+/,null,"\t\n\r \u00a0"],["com",/^#(?:if[\t\n\r \xA0]+(?:[a-z_$][\w\']*|``[^\r\n\t`]*(?:``|$))|else|endif|light)/i,null,"#"],["str",/^(?:\"(?:[^\"\\]|\\[\s\S])*(?:\"|$)|\'(?:[^\'\\]|\\[\s\S])(?:\'|$))/,null,"\"'"]],[["com",/^(?:\/\/[^\r\n]*|\(\*[\s\S]*?\*\))/],["kwd",/^(?:abstract|and|as|assert|begin|class|default|delegate|do|done|downcast|downto|elif|else|end|exception|extern|false|finally|for|fun|function|if|in|inherit|inline|interface|internal|lazy|let|match|member|module|mutable|namespace|new|null|of|open|or|override|private|public|rec|return|static|struct|then|to|true|try|type|upcast|use|val|void|when|while|with|yield|asr|land|lor|lsl|lsr|lxor|mod|sig|atomic|break|checked|component|const|constraint|constructor|continue|eager|event|external|fixed|functor|global|include|method|mixin|object|parallel|process|protected|pure|sealed|trait|virtual|volatile)\b/],
18 | ["lit",/^[+\-]?(?:0x[\da-f]+|(?:(?:\.\d+|\d+(?:\.\d*)?)(?:e[+\-]?\d+)?))/i],["pln",/^(?:[a-z_][\w']*[!?#]?|``[^\r\n\t`]*(?:``|$))/i],["pun",/^[^\t\n\r \xA0\"\'\w]+/]]),["fs","ml"]);
19 |
--------------------------------------------------------------------------------
/tests/util/resetPassword.test.util.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | const Util = {
3 | Account: require("./account.test.util")
4 | };
5 |
6 | const Services = {
7 | resetPassword: require("../../services/resetPassword.service")
8 | };
9 |
10 | const mongoose = require("mongoose");
11 | const ResetPassword = require("../../models/passwordResetToken.model");
12 |
13 | const logger = require("../../services/logger.service");
14 |
15 | const ResetPasswordToken1 = {
16 | _id: new mongoose.Types.ObjectId(),
17 | accountId: Util.Account.hackerAccounts.stored.team[0]._id
18 | };
19 |
20 | const ResetToken = Services.resetPassword.generateToken(
21 | ResetPasswordToken1._id,
22 | ResetPasswordToken1.accountId
23 | );
24 |
25 | const ResetPasswords = [ResetPasswordToken1];
26 |
27 | function store(attributes) {
28 | const resetPasswordDocs = [];
29 | const resetPasswordIds = [];
30 | for (var i = 0; i < attributes.length; i++) {
31 | resetPasswordDocs.push(new ResetPassword(attributes[i]));
32 | resetPasswordIds.push(attributes[i]._id);
33 | }
34 | return ResetPassword.collection.insertMany(resetPasswordDocs);
35 | }
36 |
37 | async function storeAll() {
38 | await store(ResetPasswords);
39 | }
40 |
41 | async function dropAll() {
42 | try {
43 | await ResetPassword.collection.drop();
44 | } catch (e) {
45 | if (e.code === 26) {
46 | logger.info(
47 | "namespace %s not found",
48 | ResetPassword.collection.name
49 | );
50 | } else {
51 | throw e;
52 | }
53 | }
54 | }
55 |
56 | module.exports = {
57 | ResetToken: ResetToken,
58 | ResetPasswords: ResetPasswords,
59 | storeAll: storeAll,
60 | dropAll: dropAll
61 | };
62 |
--------------------------------------------------------------------------------
/tests/storage.spec.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | const path = require("path");
3 | //load up env variables
4 | const dotenv = require("dotenv");
5 | require("../services/env.service").load(dotenv);
6 |
7 | const StorageService = require("../services/storage.service");
8 |
9 | const assert = require("chai").assert;
10 |
11 | var fs = require("fs");
12 |
13 | describe("Storage service", function() {
14 | this.timeout(0);
15 | const file = {
16 | mimetype: "application/pdf",
17 | buffer: fs.readFileSync(__dirname + "/testResume.pdf")
18 | };
19 | it("Should upload new file", (done) => {
20 | const gcfilename = "resumes/testResume.pdf";
21 | StorageService.upload(file, gcfilename)
22 | .then((addr) => {
23 | assert.equal(addr, StorageService.getPublicUrl(gcfilename));
24 | done();
25 | })
26 | .catch(done);
27 | });
28 | it("should get test file", (done) => {
29 | StorageService.download("resumes/testResume.pdf")
30 | .then((buffer) => {
31 | assert.deepEqual(
32 | buffer[0],
33 | file.buffer,
34 | "Two buffers are not equal"
35 | );
36 | done();
37 | })
38 | .catch(done);
39 | });
40 | it("should delete test file", (done) => {
41 | StorageService.delete("resumes/testResume.pdf")
42 | .then(() => {
43 | StorageService.exists("resumes/testResume.pdf")
44 | .then((exists) => {
45 | assert.isFalse(exists[0]);
46 | done();
47 | })
48 | .catch(done);
49 | })
50 | .catch(done);
51 | });
52 | });
53 |
--------------------------------------------------------------------------------
/.env.example:
--------------------------------------------------------------------------------
1 | #The port on which to run the server
2 | PORT=
3 | #The address on which the server is being run:
4 | ADDRESS=
5 |
6 | #front-end server
7 | FRONTEND_ADDRESS_DEV=localhost:1337
8 | FRONTEND_ADDRESS_DEPLOY=app.mchacks.ca
9 | FRONTEND_ADDRESS_BETA=develop--mchacks-dashboard.netlify.com
10 |
11 | #The info for the deployment database
12 | DB_ADDRESS_DEPLOY=
13 | DB_USER_DEPLOY=
14 | DB_PASS_DEPLOY=
15 |
16 | #The info for the development database
17 | DB_ADDRESS_DEV=
18 | DB_USER_DEV=
19 | DB_PASS_DEV=
20 |
21 | #The info for the test database
22 | DB_ADDRESS_TEST=
23 | DB_USER_TEST=
24 | DB_PASS_TEST=
25 |
26 | #Secret key for the cookies
27 | COOKIE_SECRET=
28 |
29 | #Secret key for the invite tokens
30 | JWT_INVITE_SECRET=
31 |
32 | #Reset password secret
33 | JWT_RESET_PWD_SECRET=
34 |
35 | #Secret key fo account confirmation token
36 | JWT_CONFIRM_ACC_SECRET=
37 |
38 | #mail information
39 | SENDGRID_API_KEY=
40 | NO_REPLY_EMAIL=
41 |
42 | #Storage information
43 | BUCKET_NAME=
44 |
45 | #Service account information (This is found in the json when you create a service account).
46 | TYPE=service_account
47 | PROJECT_ID=
48 | PRIVATE_KEY_ID=
49 | PRIVATE_KEY=
50 | CLIENT_EMAIL=
51 | CLIENT_ID=
52 | AUTH_URI=
53 | TOKEN_URI=
54 | AUTH_PROVIDER_X509_CERT_URL=
55 | CLIENT_X509_CERT_URL=
56 |
--------------------------------------------------------------------------------
/tests/util/volunteer.test.util.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | const Util = {
3 | Account: require("./account.test.util")
4 | };
5 | const mongoose = require("mongoose");
6 | const Volunteer = require("../../models/volunteer.model");
7 | const logger = require("../../services/logger.service");
8 |
9 | const newVolunteer0 = {
10 | accountId: Util.Account.volunteerAccounts.new[0]._id
11 | };
12 |
13 | const duplicateVolunteer1 = {
14 | accountId: Util.Account.volunteerAccounts.stored[0]._id
15 | };
16 |
17 | const Volunteer0 = {
18 | _id: new mongoose.Types.ObjectId(),
19 | accountId: Util.Account.volunteerAccounts.stored[0]._id
20 | };
21 |
22 | const invalidVolunteer0 = {
23 | _id: new mongoose.Types.ObjectId(),
24 | accountId: Util.Account.staffAccounts.stored[0]._id
25 | };
26 |
27 | const Volunteers = [Volunteer0];
28 |
29 | function store(attributes) {
30 | const volunteerDocs = [];
31 | const volunteerIds = [];
32 | attributes.forEach((attribute) => {
33 | volunteerDocs.push(new Volunteer(attribute));
34 | volunteerIds.push(attribute._id);
35 | });
36 |
37 | return Volunteer.collection.insertMany(volunteerDocs);
38 | }
39 |
40 | async function storeAll() {
41 | await store(Volunteers);
42 | }
43 |
44 | async function dropAll() {
45 | try {
46 | await Volunteer.collection.drop();
47 | } catch (e) {
48 | if (e.code === 26) {
49 | logger.info("namespace %s not found", Volunteer.collection.name);
50 | } else {
51 | throw e;
52 | }
53 | }
54 | }
55 |
56 | module.exports = {
57 | duplicateVolunteer1: duplicateVolunteer1,
58 | newVolunteer0: newVolunteer0,
59 | Volunteer0: Volunteer0,
60 | invalidVolunteer0: invalidVolunteer0,
61 |
62 | Volunteers: Volunteers,
63 | storeAll: storeAll,
64 | dropAll: dropAll
65 | };
66 |
--------------------------------------------------------------------------------
/services/env.service.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | const dotenv = require("dotenv");
3 | const fs = require("fs");
4 | const path = require("path");
5 | const Logger = require("./logger.service");
6 | module.exports = {
7 | load: function(path) {
8 | const result = dotenv.config({
9 | path: path
10 | });
11 | createGCPFile();
12 | return result;
13 | },
14 | isDevelopment: function() {
15 | return process.env.NODE_ENV === "development";
16 | },
17 | isProduction: function() {
18 | return process.env.NODE_ENV === "deployment";
19 | },
20 | isTest: function() {
21 | return process.env.NODE_ENV === "test";
22 | }
23 | };
24 |
25 | function createGCPFile() {
26 | const creds = {
27 | type: process.env.TYPE,
28 | project_id: process.env.PROJECT_ID,
29 | private_key_id: process.env.PRIVATE_KEY_ID,
30 | private_key: process.env.PRIVATE_KEY,
31 | client_email: process.env.CLIENT_EMAIL,
32 | client_id: process.env.CLIENT_ID,
33 | auth_uri: process.env.AUTH_URI,
34 | token_uri: process.env.TOKEN_URI,
35 | auth_provider_x509_cert_url: process.env.AUTH_PROVIDER_X509_CERT_URL,
36 | client_x509_cert_url: process.env.CLIENT_X509_CERT_URL
37 | };
38 | for (var property in creds) {
39 | if (creds.hasOwnProperty(property)) {
40 | if (typeof property === "undefined") {
41 | Logger.error(`GCP credential ${property} was undefined.`);
42 | }
43 | }
44 | }
45 | const stringified = JSON.stringify(creds);
46 | const unEscaped = stringified.replace(/\\\\n/g, "\\n");
47 | const fileLocation = path.join(__dirname, "../gcp_creds.json");
48 | fs.writeFileSync(fileLocation, unEscaped);
49 | process.env.GOOGLE_APPLICATION_CREDENTIALS = fileLocation;
50 | }
51 |
--------------------------------------------------------------------------------
/services/role.service.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | const Role = require("../models/role.model");
3 | const logger = require("./logger.service");
4 | const mongoose = require("mongoose");
5 |
6 | /**
7 | * @function createRole
8 | * @param {{_id: ObjectId, name: String, routes: route[]}} roleDetails
9 | * @return {Promise} The promise will resolve to a role object if save was successful.
10 | * @description Adds a new role to database.
11 | */
12 | function createRole(roleDetails) {
13 | const role = new Role(roleDetails);
14 |
15 | return role.save();
16 | }
17 |
18 | /**
19 | * @function getRole
20 | * @param {string} roleName The name of the role that you're looking for.
21 | * @description
22 | * Returns the role defined by the role name
23 | */
24 | function getRole(roleName) {
25 | const TAG = "[Role Service # getRole]:";
26 | const query = {
27 | name: roleName
28 | };
29 | //get the roleBinding for account
30 | //Populate roles for roleBinding
31 | return logger.logQuery(TAG, "role", query, Role.findOne(query));
32 | }
33 |
34 | /**
35 | * @function getById
36 | * @param {ObjectId} id The role id
37 | * @description
38 | * Returns the role specified by the id.
39 | */
40 | function getById(id) {
41 | const TAG = "[Role Service # getById]:";
42 | const query = {
43 | _id: id
44 | };
45 | //get the roleBinding for account
46 | //Populate roles for roleBinding
47 | return logger.logQuery(TAG, "role", query, Role.findById(query));
48 | }
49 |
50 | /**
51 | * @function getAll
52 | * @description
53 | * Returns all the roles in the database
54 | */
55 | function getAll() {
56 | const TAG = "[Role Service # getAll]:";
57 | return logger.logQuery(TAG, "role", {}, Role.find({}));
58 | }
59 |
60 | module.exports = {
61 | getRole: getRole,
62 | getById: getById,
63 | getAll: getAll,
64 | createRole: createRole
65 | };
66 |
--------------------------------------------------------------------------------
/controllers/sponsor.controller.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | const Services = {
3 | Sponsor: require("../services/sponsor.service"),
4 | Logger: require("../services/logger.service")
5 | };
6 | const Util = require("../middlewares/util.middleware");
7 | const Constants = {
8 | Success: require("../constants/success.constant"),
9 | Error: require("../constants/error.constant")
10 | };
11 |
12 | /**
13 | * @function showSponsor
14 | * @param {{body: {sponsor: Object}}} req
15 | * @param {*} res
16 | * @return {JSON} Success status and sponsor object
17 | * @description Returns the JSON of sponsor object located in req.body.sponsor
18 | */
19 | function showSponsor(req, res) {
20 | return res.status(200).json({
21 | message: Constants.Success.SPONSOR_READ,
22 | data: req.body.sponsor.toJSON()
23 | });
24 | }
25 |
26 | /**
27 | * @function createdSponsor
28 | * @param {{body: {sponsor: {_id: ObjectId, accountId: ObjectId, tier: number, company: string, contractURL: string, nominees: ObjectId[]}}}} req
29 | * @param {*} res
30 | * @return {JSON} Success status
31 | * @description returns success message
32 | */
33 | function createdSponsor(req, res) {
34 | return res.status(200).json({
35 | message: Constants.Success.SPONSOR_CREATE,
36 | data: req.body.sponsor.toJSON()
37 | });
38 | }
39 |
40 | /**
41 | * @function updatedSponsor
42 | * @param {{body: {sponsor: {_id: ObjectId, accountId: ObjectId, tier: number, company: string, contractURL: string, nominees: ObjectId[]}}}} req
43 | * @param {*} res
44 | * @return {JSON} Success status
45 | * @description returns success message
46 | */
47 | function updatedSponsor(req, res) {
48 | return res.status(200).json({
49 | message: Constants.Success.SPONSOR_UPDATE,
50 | data: req.body.sponsor.toJSON()
51 | });
52 | }
53 |
54 | module.exports = {
55 | createdSponsor: createdSponsor,
56 | showSponsor: showSponsor,
57 | updatedSponsor: updatedSponsor
58 | };
59 |
--------------------------------------------------------------------------------
/middlewares/search.middleware.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | const Services = {
3 | Search: require("../services/search.service")
4 | };
5 | const Middleware = {
6 | Util: require("../middlewares/util.middleware")
7 | };
8 |
9 | /**
10 | * @function parseQuery
11 | * @param {JSON} req
12 | * @param {JSON} res
13 | * @param {JSON} next
14 | * @description parses the json in the parameter
15 | */
16 | function parseQuery(req, res, next) {
17 | let query = req.body.q;
18 |
19 | req.body.q = JSON.parse(query);
20 |
21 | //Default page
22 | if (!req.body.hasOwnProperty("page")) {
23 | req.body.page = 0;
24 | } else {
25 | req.body.page = parseInt(req.body.page);
26 | }
27 | //Default limit
28 | if (!req.body.hasOwnProperty("limit")) {
29 | req.body.limit = 10000;
30 | } else {
31 | req.body.limit = parseInt(req.body.limit);
32 | }
33 | //Default sorting
34 | if (!req.body.hasOwnProperty("sort")) {
35 | req.body.sort = "";
36 | req.body.sort_by = "";
37 | }
38 |
39 | if (!req.body.hasOwnProperty("expand")) {
40 | req.body.expand = false;
41 | }
42 |
43 | return next();
44 | }
45 |
46 | /**
47 | * Middleware that executes the query passed
48 | * @param {{body: {model: string, q: Array, page: Integer, limit: Integer}}} req
49 | * @param {*} res
50 | * @param {(err?)=>void} next
51 | * @returns {Promise.}
52 | */
53 | async function executeQuery(req, res, next) {
54 | req.body.results = await Services.Search.executeQuery(
55 | req.body.model,
56 | req.body.q,
57 | req.body.page,
58 | req.body.limit,
59 | req.body.sort,
60 | req.body.sort_by,
61 | req.body.expand
62 | );
63 | return next();
64 | }
65 |
66 | function setExpandTrue(req, res, next) {
67 | req.body.expand = true;
68 | next();
69 | }
70 |
71 | module.exports = {
72 | parseQuery: parseQuery,
73 | executeQuery: Middleware.Util.asyncMiddleware(executeQuery),
74 | setExpandTrue: setExpandTrue
75 | };
76 |
--------------------------------------------------------------------------------
/middlewares/validators/account.validator.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | const VALIDATOR = require("./validator.helper");
3 | const Constants = require("../../constants/general.constant");
4 |
5 | module.exports = {
6 | newAccountValidator: [
7 | VALIDATOR.stringValidator("body", "firstName", false),
8 | VALIDATOR.stringValidator("body", "lastName", false),
9 | VALIDATOR.stringValidator("body", "pronoun", false),
10 | VALIDATOR.stringValidator("body", "gender", false),
11 | VALIDATOR.regexValidator("body", "email", false, Constants.EMAIL_REGEX),
12 | VALIDATOR.alphaArrayValidator("body", "dietaryRestrictions", false),
13 | VALIDATOR.stringValidator("body", "gender", false),
14 | VALIDATOR.passwordValidator("body", "password", false),
15 | VALIDATOR.jwtValidator(
16 | "header",
17 | "token",
18 | process.env.JWT_CONFIRM_ACC_SECRET,
19 | true
20 | ),
21 | VALIDATOR.ageValidator("body", "age", false),
22 | VALIDATOR.phoneNumberValidator("body", "phoneNumber", true)
23 | ],
24 | updateAccountValidator: [
25 | VALIDATOR.stringValidator("body", "firstName", true),
26 | VALIDATOR.stringValidator("body", "lastName", true),
27 | VALIDATOR.stringValidator("body", "pronoun", true),
28 | VALIDATOR.stringValidator("body", "gender", true),
29 | VALIDATOR.regexValidator("body", "email", true, Constants.EMAIL_REGEX),
30 | VALIDATOR.alphaArrayValidator("body", "dietaryRestrictions", true),
31 | VALIDATOR.stringValidator("body", "gender", true),
32 | VALIDATOR.ageValidator("body", "age", true),
33 | VALIDATOR.phoneNumberValidator("body", "phoneNumber", true)
34 | ],
35 | inviteAccountValidator: [
36 | VALIDATOR.regexValidator("body", "email", false, Constants.EMAIL_REGEX),
37 | VALIDATOR.enumValidator(
38 | "body",
39 | "accountType",
40 | Constants.EXTENDED_USER_TYPES,
41 | false
42 | )
43 | ]
44 | };
45 |
--------------------------------------------------------------------------------
/scripts/interest_form_emails.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | """
3 | This script sends templated emails to a list of recipients from a CSV file.
4 |
5 | USAGE:
6 | python interest_form_emails.py
7 |
8 | REQUIREMENTS:
9 | - CSV file must contain an "Email" column with valid email addresses
10 | """
11 |
12 | import os
13 | import sys
14 | import csv
15 | import time
16 | from sendgrid import SendGridAPIClient
17 | from sendgrid.helpers.mail import Mail
18 |
19 | FROM_EMAIL = "contact@mchacks.ca"
20 | TEMPLATE_ID = "d-8cbb9f9e07f04712bc88aecba33d49f3"
21 |
22 |
23 | def send_email(to_email):
24 |
25 | message = Mail(
26 | from_email=FROM_EMAIL,
27 | to_emails=to_email,
28 | )
29 | message.template_id = TEMPLATE_ID
30 |
31 | try:
32 | sg = SendGridAPIClient(os.getenv("SENDGRID_API_KEY"))
33 | response = sg.send(message)
34 | return True
35 | except Exception as e:
36 | print(f"Error sending to {to_email}: {e}")
37 | return False
38 |
39 |
40 | def parse_csv(csv_filename):
41 | if not os.path.exists(csv_filename):
42 | print(f"Error: File '{csv_filename}' not found")
43 | return
44 |
45 | sent_count = 0
46 | failed_count = 0
47 |
48 | try:
49 | with open(csv_filename, "r", newline="", encoding="utf-8") as csvfile:
50 | reader = csv.DictReader(csvfile)
51 |
52 | for _, row in enumerate(reader, start=1):
53 | email = row.get("Email", "").strip()
54 |
55 | if not email or "@" not in email:
56 | continue
57 |
58 | if send_email(email):
59 | sent_count += 1
60 | else:
61 | failed_count += 1
62 |
63 | time.sleep(0.1) # Add delay to avoid rate limiting
64 |
65 | print(f"\nSent: {sent_count} | Failed: {failed_count}")
66 |
67 | except Exception as e:
68 | print(f"Error: {e}")
69 |
70 |
71 | if __name__ == "__main__":
72 | parse_csv(sys.argv[1])
73 |
--------------------------------------------------------------------------------
/docs/api/vendor/prettify/lang-swift.js:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | Copyright (C) 2015 Google Inc.
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 | */
15 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[ \n\r\t\v\f\0]+/,null," \n\r\t\v\f\x00"],["str",/^"(?:[^"\\]|(?:\\.)|(?:\\\((?:[^"\\)]|\\.)*\)))*"/,null,'"']],[["lit",/^(?:(?:0x[\da-fA-F][\da-fA-F_]*\.[\da-fA-F][\da-fA-F_]*[pP]?)|(?:\d[\d_]*\.\d[\d_]*[eE]?))[+-]?\d[\d_]*/,null],["lit",/^-?(?:(?:0(?:(?:b[01][01_]*)|(?:o[0-7][0-7_]*)|(?:x[\da-fA-F][\da-fA-F_]*)))|(?:\d[\d_]*))/,null],["lit",/^(?:true|false|nil)\b/,null],["kwd",/^\b(?:__COLUMN__|__FILE__|__FUNCTION__|__LINE__|#available|#else|#elseif|#endif|#if|#line|arch|arm|arm64|associativity|as|break|case|catch|class|continue|convenience|default|defer|deinit|didSet|do|dynamic|dynamicType|else|enum|fallthrough|final|for|func|get|import|indirect|infix|init|inout|internal|i386|if|in|iOS|iOSApplicationExtension|is|lazy|left|let|mutating|none|nonmutating|operator|optional|OSX|OSXApplicationExtension|override|postfix|precedence|prefix|private|protocol|Protocol|public|required|rethrows|return|right|safe|self|set|static|struct|subscript|super|switch|throw|try|Type|typealias|unowned|unsafe|var|weak|watchOS|while|willSet|x86_64)\b/,
16 | null],["com",/^\/\/.*?[\n\r]/,null],["com",/^\/\*[\s\S]*?(?:\*\/|$)/,null],["pun",/^<<=|<=|<<|>>=|>=|>>|===|==|\.\.\.|&&=|\.\.<|!==|!=|&=|~=|~|\(|\)|\[|\]|{|}|@|#|;|\.|,|:|\|\|=|\?\?|\|\||&&|&\*|&\+|&-|&=|\+=|-=|\/=|\*=|\^=|%=|\|=|->|`|==|\+\+|--|\/|\+|!|\*|%|<|>|&|\||\^|\?|=|-|_/,null],["typ",/^\b(?:[@_]?[A-Z]+[a-z][A-Za-z_$@0-9]*|\w+_t\b)/,null]]),["swift"]);
17 |
--------------------------------------------------------------------------------
/docs/api/vendor/prettify/lang-vhd.js:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | Copyright (C) 2010 benoit@ryder.fr
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 | */
17 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\r \xA0]+/,null,"\t\n\r \u00a0"]],[["str",/^(?:[BOX]?"(?:[^\"]|"")*"|'.')/i],["com",/^--[^\r\n]*/],["kwd",/^(?:abs|access|after|alias|all|and|architecture|array|assert|attribute|begin|block|body|buffer|bus|case|component|configuration|constant|disconnect|downto|else|elsif|end|entity|exit|file|for|function|generate|generic|group|guarded|if|impure|in|inertial|inout|is|label|library|linkage|literal|loop|map|mod|nand|new|next|nor|not|null|of|on|open|or|others|out|package|port|postponed|procedure|process|pure|range|record|register|reject|rem|report|return|rol|ror|select|severity|shared|signal|sla|sll|sra|srl|subtype|then|to|transport|type|unaffected|units|until|use|variable|wait|when|while|with|xnor|xor)(?=[^\w-]|$)/i,
18 | null],["typ",/^(?:bit|bit_vector|character|boolean|integer|real|time|string|severity_level|positive|natural|signed|unsigned|line|text|std_u?logic(?:_vector)?)(?=[^\w-]|$)/i,null],["typ",/^\'(?:ACTIVE|ASCENDING|BASE|DELAYED|DRIVING|DRIVING_VALUE|EVENT|HIGH|IMAGE|INSTANCE_NAME|LAST_ACTIVE|LAST_EVENT|LAST_VALUE|LEFT|LEFTOF|LENGTH|LOW|PATH_NAME|POS|PRED|QUIET|RANGE|REVERSE_RANGE|RIGHT|RIGHTOF|SIMPLE_NAME|STABLE|SUCC|TRANSACTION|VAL|VALUE)(?=[^\w-]|$)/i,null],["lit",/^\d+(?:_\d+)*(?:#[\w\\.]+#(?:[+\-]?\d+(?:_\d+)*)?|(?:\.\d+(?:_\d+)*)?(?:E[+\-]?\d+(?:_\d+)*)?)/i],
19 | ["pln",/^(?:[a-z]\w*|\\[^\\]*\\)/i],["pun",/^[^\w\t\n\r \xA0\"\'][^\w\t\n\r \xA0\-\"\']*/]]),["vhdl","vhd"]);
20 |
--------------------------------------------------------------------------------
/docs/api/vendor/prettify/lang-vhdl.js:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | Copyright (C) 2010 benoit@ryder.fr
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 | */
17 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\r \xA0]+/,null,"\t\n\r \u00a0"]],[["str",/^(?:[BOX]?"(?:[^\"]|"")*"|'.')/i],["com",/^--[^\r\n]*/],["kwd",/^(?:abs|access|after|alias|all|and|architecture|array|assert|attribute|begin|block|body|buffer|bus|case|component|configuration|constant|disconnect|downto|else|elsif|end|entity|exit|file|for|function|generate|generic|group|guarded|if|impure|in|inertial|inout|is|label|library|linkage|literal|loop|map|mod|nand|new|next|nor|not|null|of|on|open|or|others|out|package|port|postponed|procedure|process|pure|range|record|register|reject|rem|report|return|rol|ror|select|severity|shared|signal|sla|sll|sra|srl|subtype|then|to|transport|type|unaffected|units|until|use|variable|wait|when|while|with|xnor|xor)(?=[^\w-]|$)/i,
18 | null],["typ",/^(?:bit|bit_vector|character|boolean|integer|real|time|string|severity_level|positive|natural|signed|unsigned|line|text|std_u?logic(?:_vector)?)(?=[^\w-]|$)/i,null],["typ",/^\'(?:ACTIVE|ASCENDING|BASE|DELAYED|DRIVING|DRIVING_VALUE|EVENT|HIGH|IMAGE|INSTANCE_NAME|LAST_ACTIVE|LAST_EVENT|LAST_VALUE|LEFT|LEFTOF|LENGTH|LOW|PATH_NAME|POS|PRED|QUIET|RANGE|REVERSE_RANGE|RIGHT|RIGHTOF|SIMPLE_NAME|STABLE|SUCC|TRANSACTION|VAL|VALUE)(?=[^\w-]|$)/i,null],["lit",/^\d+(?:_\d+)*(?:#[\w\\.]+#(?:[+\-]?\d+(?:_\d+)*)?|(?:\.\d+(?:_\d+)*)?(?:E[+\-]?\d+(?:_\d+)*)?)/i],
19 | ["pln",/^(?:[a-z]\w*|\\[^\\]*\\)/i],["pun",/^[^\w\t\n\r \xA0\"\'][^\w\t\n\r \xA0\-\"\']*/]]),["vhdl","vhd"]);
20 |
--------------------------------------------------------------------------------
/docs/api/vendor/prettify/lang-n.js:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | Copyright (C) 2011 Zimin A.V.
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 | */
17 | PR.registerLangHandler(PR.createSimpleLexer([["str",/^(?:\'(?:[^\\\'\r\n]|\\.)*\'|\"(?:[^\\\"\r\n]|\\.)*(?:\"|$))/,null,'"'],["com",/^#(?:(?:define|elif|else|endif|error|ifdef|include|ifndef|line|pragma|undef|warning)\b|[^\r\n]*)/,null,"#"],["pln",/^\s+/,null," \r\n\t\u00a0"]],[["str",/^@\"(?:[^\"]|\"\")*(?:\"|$)/,null],["str",/^<#(?:[^#>])*(?:#>|$)/,null],["str",/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h|[a-z]\w*)>/,null],["com",/^\/\/[^\r\n]*/,
18 | null],["com",/^\/\*[\s\S]*?(?:\*\/|$)/,null],["kwd",/^(?:abstract|and|as|base|catch|class|def|delegate|enum|event|extern|false|finally|fun|implements|interface|internal|is|macro|match|matches|module|mutable|namespace|new|null|out|override|params|partial|private|protected|public|ref|sealed|static|struct|syntax|this|throw|true|try|type|typeof|using|variant|virtual|volatile|when|where|with|assert|assert2|async|break|checked|continue|do|else|ensures|for|foreach|if|late|lock|new|nolate|otherwise|regexp|repeat|requires|return|surroundwith|unchecked|unless|using|while|yield)\b/,
19 | null],["typ",/^(?:array|bool|byte|char|decimal|double|float|int|list|long|object|sbyte|short|string|ulong|uint|ufloat|ulong|ushort|void)\b/,null],["lit",/^@[a-z_$][a-z_$@0-9]*/i,null],["typ",/^@[A-Z]+[a-z][A-Za-z_$@0-9]*/,null],["pln",/^'?[A-Za-z_$][a-z_$@0-9]*/i,null],["lit",/^(?:0x[a-f0-9]+|(?:\d(?:_\d+)*\d*(?:\.\d*)?|\.\d\+)(?:e[+\-]?\d+)?)[a-z]*/i,null,"0123456789"],["pun",/^.[^\s\w\.$@\'\"\`\/\#]*/,null]]),["n","nemerle"]);
20 |
--------------------------------------------------------------------------------
/docs/api/vendor/prettify/lang-nemerle.js:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | Copyright (C) 2011 Zimin A.V.
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 | */
17 | PR.registerLangHandler(PR.createSimpleLexer([["str",/^(?:\'(?:[^\\\'\r\n]|\\.)*\'|\"(?:[^\\\"\r\n]|\\.)*(?:\"|$))/,null,'"'],["com",/^#(?:(?:define|elif|else|endif|error|ifdef|include|ifndef|line|pragma|undef|warning)\b|[^\r\n]*)/,null,"#"],["pln",/^\s+/,null," \r\n\t\u00a0"]],[["str",/^@\"(?:[^\"]|\"\")*(?:\"|$)/,null],["str",/^<#(?:[^#>])*(?:#>|$)/,null],["str",/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h|[a-z]\w*)>/,null],["com",/^\/\/[^\r\n]*/,
18 | null],["com",/^\/\*[\s\S]*?(?:\*\/|$)/,null],["kwd",/^(?:abstract|and|as|base|catch|class|def|delegate|enum|event|extern|false|finally|fun|implements|interface|internal|is|macro|match|matches|module|mutable|namespace|new|null|out|override|params|partial|private|protected|public|ref|sealed|static|struct|syntax|this|throw|true|try|type|typeof|using|variant|virtual|volatile|when|where|with|assert|assert2|async|break|checked|continue|do|else|ensures|for|foreach|if|late|lock|new|nolate|otherwise|regexp|repeat|requires|return|surroundwith|unchecked|unless|using|while|yield)\b/,
19 | null],["typ",/^(?:array|bool|byte|char|decimal|double|float|int|list|long|object|sbyte|short|string|ulong|uint|ufloat|ulong|ushort|void)\b/,null],["lit",/^@[a-z_$][a-z_$@0-9]*/i,null],["typ",/^@[A-Z]+[a-z][A-Za-z_$@0-9]*/,null],["pln",/^'?[A-Za-z_$][a-z_$@0-9]*/i,null],["lit",/^(?:0x[a-f0-9]+|(?:\d(?:_\d+)*\d*(?:\.\d*)?|\.\d\+)(?:e[+\-]?\d+)?)[a-z]*/i,null,"0123456789"],["pun",/^.[^\s\w\.$@\'\"\`\/\#]*/,null]]),["n","nemerle"]);
20 |
--------------------------------------------------------------------------------
/scripts/migrate_email_templates.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | const env = require("../services/env.service");
3 | const db = require("../services/database.service");
4 |
5 | const fs = require("fs").promises;
6 | const path = require("path");
7 | const templatesDirPath = path.join(__dirname, "../assets/email/marketingEmail/");
8 |
9 | const EmailTemplate = require("../models/emailTemplate.model");
10 |
11 | // load env
12 | const envLoadResult = env.load(path.join(__dirname, "../.env"));
13 | if (envLoadResult.error) {
14 | console.error(envLoadResult.error);
15 | }
16 |
17 | // connect to db
18 | db.connect(() => {
19 | onConnected()
20 | .catch((reason) => {
21 | console.error(reason);
22 | process.exit(1);
23 | })
24 | .then(() => {
25 | process.exit(0);
26 | });
27 | });
28 |
29 | /**
30 | * Called when the db is connected.
31 | */
32 | async function onConnected() {
33 | await migrateAll();
34 | console.log("Finished migrating.");
35 | }
36 |
37 | /**
38 | * Inserts all email templates in assets to the db.
39 | */
40 | async function migrateAll() {
41 | const filenames = await fs.readdir(templatesDirPath);
42 | for (const filename of filenames) {
43 | const filepath = path.join(templatesDirPath, filename);
44 | const data = await fs.readFile(filepath, 'utf-8');
45 | const emailTemplateDoc = new EmailTemplate(
46 | {
47 | name: filename,
48 | content: data
49 | }
50 | );
51 | await insertOne(emailTemplateDoc);
52 | }
53 | }
54 |
55 |
56 | /**
57 | * Inserts an EmailTemplate document to the db. Prevents duplicate name.
58 | * @param {EmailTemplate} emailTemplateDoc
59 | */
60 | async function insertOne(emailTemplateDoc) {
61 | const dup = await EmailTemplate.collection.findOne({ name: emailTemplateDoc.name });
62 | if (!dup) {
63 | await EmailTemplate.collection.insertOne(emailTemplateDoc);
64 | console.log(`${emailTemplateDoc.name} is migrated.`);
65 | } else {
66 | console.error(`${emailTemplateDoc.name} already in database.`);
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/bin/www.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | /**
3 | * Module dependencies.
4 | */
5 | const app = require("../app").app;
6 | const debug = require("debug")("hackboard:server");
7 | const http = require("http");
8 | const version = require("../services/version.service");
9 |
10 | /**
11 | * Get port from environment and store in Express.
12 | */
13 |
14 | const port = normalizePort(process.env.PORT || "3000");
15 | app.set("port", port);
16 |
17 | /**
18 | * Create HTTP server.
19 | */
20 |
21 | const server = http.createServer(app);
22 |
23 | /**
24 | * Normalize a port into a number, string, or false.
25 | */
26 |
27 | function normalizePort(val) {
28 | const p = parseInt(val, 10);
29 |
30 | if (Number.isNaN(p)) {
31 | // named pipe
32 | return val;
33 | }
34 |
35 | if (p >= 0) {
36 | // port number
37 | return p;
38 | }
39 | return false;
40 | }
41 |
42 | /**
43 | * Event listener for HTTP server "error" event.
44 | */
45 |
46 | function onError(error) {
47 | if (error.syscall !== "listen") {
48 | throw error;
49 | }
50 |
51 | const bind = typeof port === "string" ? "Pipe " + port : "Port " + port;
52 |
53 | // handle specific listen errors with friendly messages
54 | switch (error.code) {
55 | case "EACCES":
56 | console.error(bind + " requires elevated privileges");
57 | process.exit(1);
58 | break;
59 | case "EADDRINUSE":
60 | console.error(bind + " is already in use");
61 | process.exit(1);
62 | break;
63 | default:
64 | throw error;
65 | }
66 | }
67 |
68 | /**
69 | * Event listener for HTTP server "listening" event.
70 | */
71 |
72 | function onListening() {
73 | const addr = server.address();
74 | const bind =
75 | typeof addr === "string" ? "pipe " + addr : "port " + addr.port;
76 | debug("Listening on " + bind);
77 | debug(`VERSION ${version.get()}`);
78 | }
79 |
80 | /**
81 | * Listen on provided port, on all network interfaces.
82 | */
83 |
84 | server.listen(port);
85 | server.on("error", onError);
86 | server.on("listening", onListening);
87 |
--------------------------------------------------------------------------------
/docs/api/vendor/prettify.css:
--------------------------------------------------------------------------------
1 | /* Pretty printing styles. Used with prettify.js. */
2 | /* Vim sunburst theme by David Leibovic */
3 |
4 | pre .str, code .str { color: #65B042; } /* string - green */
5 | pre .kwd, code .kwd { color: #E28964; } /* keyword - dark pink */
6 | pre .com, code .com { color: #AEAEAE; font-style: italic; } /* comment - gray */
7 | pre .typ, code .typ { color: #89bdff; } /* type - light blue */
8 | pre .lit, code .lit { color: #3387CC; } /* literal - blue */
9 | pre .pun, code .pun { color: #fff; } /* punctuation - white */
10 | pre .pln, code .pln { color: #fff; } /* plaintext - white */
11 | pre .tag, code .tag { color: #89bdff; } /* html/xml tag - light blue */
12 | pre .atn, code .atn { color: #bdb76b; } /* html/xml attribute name - khaki */
13 | pre .atv, code .atv { color: #65B042; } /* html/xml attribute value - green */
14 | pre .dec, code .dec { color: #3387CC; } /* decimal - blue */
15 |
16 | pre.prettyprint, code.prettyprint {
17 | background-color: #000;
18 | -moz-border-radius: 8px;
19 | -webkit-border-radius: 8px;
20 | -o-border-radius: 8px;
21 | -ms-border-radius: 8px;
22 | -khtml-border-radius: 8px;
23 | border-radius: 8px;
24 | }
25 |
26 | pre.prettyprint {
27 | width: 95%;
28 | margin: 1em auto;
29 | padding: 1em;
30 | white-space: pre-wrap;
31 | }
32 |
33 |
34 | /* Specify class=linenums on a pre to get line numbering */
35 | ol.linenums { margin-top: 0; margin-bottom: 0; color: #AEAEAE; } /* IE indents via margin-left */
36 | li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8 { list-style-type: none }
37 | /* Alternate shading for lines */
38 | li.L1,li.L3,li.L5,li.L7,li.L9 { }
39 |
40 | @media print {
41 | pre .str, code .str { color: #060; }
42 | pre .kwd, code .kwd { color: #006; font-weight: bold; }
43 | pre .com, code .com { color: #600; font-style: italic; }
44 | pre .typ, code .typ { color: #404; font-weight: bold; }
45 | pre .lit, code .lit { color: #044; }
46 | pre .pun, code .pun { color: #440; }
47 | pre .pln, code .pln { color: #000; }
48 | pre .tag, code .tag { color: #006; font-weight: bold; }
49 | pre .atn, code .atn { color: #404; }
50 | pre .atv, code .atv { color: #060; }
51 | }
52 |
--------------------------------------------------------------------------------
/tests/setup.spec.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | const winston = require("winston");
3 | winston.remove(winston.transports.Console);
4 | const Util = {
5 | Account: require("./util/account.test.util"),
6 | Bus: require("./util/bus.test.util"),
7 | Hacker: require("./util/hacker.test.util"),
8 | Role: require("./util/role.test.util"),
9 | RoleBinding: require("./util/roleBinding.test.util"),
10 | Settings: require("./util/settings.test.util"),
11 | Sponsor: require("./util/sponsor.test.util"),
12 | Staff: require("./util/staff.test.util"),
13 | Team: require("./util/team.test.util"),
14 | Volunteer: require("./util/volunteer.test.util"),
15 | AccountConfirmation: require("./util/accountConfirmation.test.util"),
16 | ResetPassword: require("./util/resetPassword.test.util.js"),
17 | };
18 |
19 | //make sure that we are connected to the database
20 | before(function (done) {
21 | this.timeout(60000);
22 | /**
23 | * Give the database time to create an index on existing schemas before we delete them.
24 | * Hacky way to get around a new error.
25 | */
26 | setTimeout(() => {
27 | dropAll().then(done).catch(done);
28 | }, 1000);
29 | });
30 |
31 | after(function (done) {
32 | this.timeout(60000);
33 | dropAll()
34 | .then(() => {
35 | done();
36 | })
37 | .catch((error) => {
38 | done(error);
39 | });
40 | });
41 |
42 | afterEach(function (done) {
43 | this.timeout(60000);
44 | dropAll()
45 | .then(() => {
46 | done();
47 | })
48 | .catch((error) => {
49 | done(error);
50 | });
51 | });
52 |
53 | async function dropAll() {
54 | await Util.RoleBinding.dropAll();
55 | await Util.Role.dropAll();
56 | await Util.ResetPassword.dropAll();
57 | await Util.AccountConfirmation.dropAll();
58 | await Util.Volunteer.dropAll();
59 | await Util.Settings.dropAll();
60 | await Util.Staff.dropAll();
61 | await Util.Team.dropAll();
62 | await Util.Sponsor.dropAll();
63 | await Util.Bus.dropAll();
64 | await Util.Hacker.dropAll();
65 | await Util.Account.dropAll();
66 | }
67 |
--------------------------------------------------------------------------------
/controllers/travel.controller.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | const Constants = {
3 | Success: require("../constants/success.constant"),
4 | Error: require("../constants/error.constant")
5 | };
6 |
7 | function okay(req, res) {
8 | return res.status(200).json({
9 | message: "good"
10 | });
11 | }
12 |
13 | /**
14 | * @function showTravel
15 | * @param {{body: {travel: Object}}} req
16 | * @param {*} res
17 | * @return {JSON} Success status and travel object
18 | * @description Returns the JSON of travel object located in req.body.travel
19 | */
20 | function showTravel(req, res) {
21 | return res.status(200).json({
22 | message: Constants.Success.TRAVEL_READ,
23 | data: req.body.travel.toJSON()
24 | });
25 | }
26 |
27 | /**
28 | * @function createTravel
29 | * @param {{body: {travel: {_id: ObjectId, accountId: ObjectId, hackerId: objectId, status: string, request: number, offer: number}}}} req
30 | * @param {*} res
31 | * @return {JSON} Success status
32 | * @description
33 | * Create a travel's record based off information stored in req.body.travel
34 | * Returns a 200 status for the created travel.
35 | */
36 | function createdTravel(req, res) {
37 | return res.status(200).json({
38 | message: Constants.Success.TRAVEL_CREATE,
39 | data: req.body.travel.toJSON()
40 | });
41 | }
42 |
43 | /**
44 | * @function updatedTravel
45 | * @param {{params: {id: ObjectId}, body: {Object}}} req
46 | * @param {*} res
47 | * @return {JSON} Success or error status
48 | * @description
49 | * Change a travel's information based on the trave;'s mongoID specified in req.params.id.
50 | * The id is moved to req.body.id from req.params.id by validation.
51 | * Returns a 200 status for an updated travel.
52 | * The new information is located in req.body.
53 | */
54 | function updatedTravel(req, res) {
55 | return res.status(200).json({
56 | message: Constants.Success.TRAVEL_UPDATE,
57 | data: req.body
58 | });
59 | }
60 |
61 | module.exports = {
62 | okay: okay,
63 | showTravel: showTravel,
64 | updatedTravel: updatedTravel,
65 | createdTravel: createdTravel
66 | };
67 |
--------------------------------------------------------------------------------
/tests/util/sponsor.test.util.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | const Util = {
3 | Account: require("./account.test.util"),
4 | Hacker: require("./hacker.test.util")
5 | };
6 | const Sponsor = require("../../models/sponsor.model");
7 | const mongoose = require("mongoose");
8 | const logger = require("../../services/logger.service");
9 |
10 | const T1Sponsor0 = {
11 | _id: new mongoose.Types.ObjectId(),
12 | accountId: Util.Account.sponsorT1Accounts.stored[0]._id,
13 | tier: 1,
14 | company: "Best company NA",
15 | contractURL: "https://linkto.con",
16 | nominees: [Util.Hacker.TeamHacker0._id]
17 | };
18 |
19 | const newT2Sponsor0 = {
20 | // no _id as that will be generated
21 | accountId: Util.Account.sponsorT2Accounts.new[0]._id,
22 | tier: 2,
23 | company: "Best company EU",
24 | contractURL: "https://linktocontract2.con",
25 | nominees: [Util.Hacker.NoTeamHacker0._id]
26 | };
27 |
28 | const duplicateAccountLinkSponsor1 = {
29 | _id: new mongoose.Types.ObjectId(),
30 | accountId: Util.Account.sponsorT1Accounts.stored[0]._id,
31 | tier: 3,
32 | company: "Best company NA1",
33 | contractURL: "https://linkto1.con",
34 | nominees: [Util.Hacker.TeamHacker0._id]
35 | };
36 |
37 | const Sponsors = [T1Sponsor0];
38 |
39 | function store(attributes) {
40 | const sponsorDocs = [];
41 | const sponsorComps = [];
42 | attributes.forEach((attribute) => {
43 | sponsorDocs.push(new Sponsor(attribute));
44 | sponsorComps.push(attribute.company);
45 | });
46 |
47 | return Sponsor.collection.insertMany(sponsorDocs);
48 | }
49 |
50 | async function storeAll() {
51 | await store(Sponsors);
52 | }
53 |
54 | async function dropAll() {
55 | try {
56 | await Sponsor.collection.drop();
57 | } catch (e) {
58 | if (e.code === 26) {
59 | logger.info("namespace %s not found", Sponsor.collection.name);
60 | } else {
61 | throw e;
62 | }
63 | }
64 | }
65 |
66 | module.exports = {
67 | T1Sponsor0: T1Sponsor0,
68 | newT2Sponsor0: newT2Sponsor0,
69 |
70 | duplicateAccountLinkSponsor1: duplicateAccountLinkSponsor1,
71 |
72 | Sponsors: Sponsors,
73 | storeAll: storeAll,
74 | dropAll: dropAll
75 | };
76 |
--------------------------------------------------------------------------------
/middlewares/email.middleware.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | const Services = {
4 | AutomatedEmail: require("../services/automatedEmails.service"),
5 | };
6 | const Constants = {
7 | Error: require("../constants/error.constant"),
8 | General: require("../constants/general.constant"),
9 | };
10 |
11 | /**
12 | * Middleware to validate status parameter
13 | * @param {{params: {status: string}}} req
14 | * @param {*} res
15 | * @param {(err?)=>void} next
16 | */
17 | function validateStatus(req, res, next) {
18 | const { status } = req.params;
19 | const validStatuses = [
20 | Constants.General.HACKER_STATUS_ACCEPTED,
21 | Constants.General.HACKER_STATUS_DECLINED,
22 | ];
23 |
24 | if (!validStatuses.includes(status)) {
25 | return res.status(400).json({
26 | message: "Invalid status",
27 | data: {},
28 | });
29 | }
30 |
31 | next();
32 | }
33 |
34 | /**
35 | * Middleware to get count of hackers with specified status
36 | * @param {{params: {status: string}}} req
37 | * @param {*} res
38 | * @param {(err?)=>void} next
39 | */
40 | async function getStatusCount(req, res, next) {
41 | const { status } = req.params;
42 |
43 | try {
44 | const count = await Services.AutomatedEmail.getStatusCount(status);
45 | req.body.count = count;
46 | next();
47 | } catch (err) {
48 | return res.status(500).json({
49 | message: err.message,
50 | data: {},
51 | });
52 | }
53 | }
54 |
55 | /**
56 | * Middleware to send automated status emails
57 | * @param {{params: {status: string}}} req
58 | * @param {*} res
59 | * @param {(err?)=>void} next
60 | */
61 | async function sendAutomatedStatusEmails(req, res, next) {
62 | const { status } = req.params;
63 |
64 | try {
65 | const results =
66 | await Services.AutomatedEmail.sendAutomatedStatusEmails(status);
67 | req.body.results = results;
68 | next();
69 | } catch (err) {
70 | return res.status(500).json({
71 | message: err.message,
72 | data: {},
73 | });
74 | }
75 | }
76 |
77 | module.exports = {
78 | validateStatus,
79 | getStatusCount,
80 | sendAutomatedStatusEmails,
81 | };
82 |
--------------------------------------------------------------------------------
/docs/api/vendor/prettify/lang-rust.js:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | Copyright (C) 2015 Chris Morgan
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 | */
17 | PR.registerLangHandler(PR.createSimpleLexer([],[["pln",/^[\t\n\r \xA0]+/],["com",/^\/\/.*/],["com",/^\/\*[\s\S]*?(?:\*\/|$)/],["str",/^b"(?:[^\\]|\\(?:.|x[\da-fA-F]{2}))*?"/],["str",/^"(?:[^\\]|\\(?:.|x[\da-fA-F]{2}|u\{\[\da-fA-F]{1,6}\}))*?"/],["str",/^b?r(#*)\"[\s\S]*?\"\1/],["str",/^b'([^\\]|\\(.|x[\da-fA-F]{2}))'/],["str",/^'([^\\]|\\(.|x[\da-fA-F]{2}|u\{[\da-fA-F]{1,6}\}))'/],["tag",/^'\w+?\b/],["kwd",/^(?:match|if|else|as|break|box|continue|extern|fn|for|in|if|impl|let|loop|pub|return|super|unsafe|where|while|use|mod|trait|struct|enum|type|move|mut|ref|static|const|crate)\b/],
18 | ["kwd",/^(?:alignof|become|do|offsetof|priv|pure|sizeof|typeof|unsized|yield|abstract|virtual|final|override|macro)\b/],["typ",/^(?:[iu](8|16|32|64|size)|char|bool|f32|f64|str|Self)\b/],["typ",/^(?:Copy|Send|Sized|Sync|Drop|Fn|FnMut|FnOnce|Box|ToOwned|Clone|PartialEq|PartialOrd|Eq|Ord|AsRef|AsMut|Into|From|Default|Iterator|Extend|IntoIterator|DoubleEndedIterator|ExactSizeIterator|Option|Some|None|Result|Ok|Err|SliceConcatExt|String|ToString|Vec)\b/],["lit",/^(self|true|false|null)\b/],
19 | ["lit",/^\d[0-9_]*(?:[iu](?:size|8|16|32|64))?/],["lit",/^0x[a-fA-F0-9_]+(?:[iu](?:size|8|16|32|64))?/],["lit",/^0o[0-7_]+(?:[iu](?:size|8|16|32|64))?/],["lit",/^0b[01_]+(?:[iu](?:size|8|16|32|64))?/],["lit",/^\d[0-9_]*\.(?![^\s\d.])/],["lit",/^\d[0-9_]*(?:\.\d[0-9_]*)(?:[eE][+-]?[0-9_]+)?(?:f32|f64)?/],["lit",/^\d[0-9_]*(?:\.\d[0-9_]*)?(?:[eE][+-]?[0-9_]+)(?:f32|f64)?/],["lit",/^\d[0-9_]*(?:\.\d[0-9_]*)?(?:[eE][+-]?[0-9_]+)?(?:f32|f64)/],
20 | ["atn",/^[a-z_]\w*!/i],["pln",/^[a-z_]\w*/i],["atv",/^#!?\[[\s\S]*?\]/],["pun",/^[+\-/*=^&|!<>%[\](){}?:.,;]/],["pln",/./]]),["rust"]);
21 |
--------------------------------------------------------------------------------
/services/sponsor.service.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | const Sponsor = require("../models/sponsor.model");
3 | const logger = require("./logger.service");
4 |
5 | /**
6 | * @function findById
7 | * @param {ObjectId} id
8 | * @return {DocumentQuery} The document query will resolve to a sponsor or null.
9 | * @description Find a sponsor by id
10 | */
11 | function findById(id) {
12 | const TAG = `[Sponsor Service # findById]:`;
13 | const query = {
14 | _id: id
15 | };
16 |
17 | return logger.logQuery(TAG, "sponsor", query, Sponsor.findById(query));
18 | }
19 |
20 | /**
21 | * @function createSponsor
22 | * @param {{_id: ObjectId, accountId: ObjectId, tier: number, company: string, contractURL: string, nominees: ObjectId[]}} sponsorDetails
23 | * @return {Promise} The promise will resolve to a sponsor object if save was successful.
24 | * @description Adds a new sponsor to database.
25 | */
26 | function createSponsor(sponsorDetails) {
27 | const TAG = `[Sponsor Service # createSponsor]:`;
28 |
29 | const sponsor = new Sponsor(sponsorDetails);
30 |
31 | return sponsor.save();
32 | }
33 |
34 | /**
35 | * @function updateOne
36 | * @param {ObjectId} id
37 | * @param {{company?: string, contractURL?: string, nominees?: ObjectId[]}} sponsorDetails
38 | * @return {Promise} The promise will resolve to a sponsor object if update was successful.
39 | * @description Updates a sponsor by id with information in sponsorDetails. Return the updated sponsor
40 | */
41 | function updateOne(id, sponsorDetails) {
42 | const TAG = `[Sponsor Service # updateOne]:`;
43 |
44 | const query = {
45 | _id: id
46 | };
47 |
48 | return Sponsor.findOneAndUpdate(query, sponsorDetails, {
49 | new: true
50 | });
51 | }
52 |
53 | /**
54 | * @function findByAccountId
55 | * @param {ObjectId} accountId
56 | * @return {DocumentQuery} A sponsor document queried by accountId
57 | */
58 | function findByAccountId(accountId) {
59 | const TAG = `[ Sponsor Service # findByAccountId ]:`;
60 |
61 | const query = {
62 | accountId: accountId
63 | };
64 |
65 | return logger.logUpdate(TAG, "sponsor", Sponsor.findOne(query));
66 | }
67 |
68 | module.exports = {
69 | findByAccountId: findByAccountId,
70 | findById: findById,
71 | createSponsor: createSponsor,
72 | updateOne: updateOne
73 | };
74 |
--------------------------------------------------------------------------------
/app.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "HackMcGill HackerAPI",
3 | "description": "API for registration, live-site",
4 | "repository": "https://github.com/hackmcgill/hackerAPI",
5 | "keywords": ["node", "express", "mongo", "react", "hackathon"],
6 | "env": {
7 | "FRONTEND_ADDRESS_DEPLOY": {
8 | "description": "URL for application front end"
9 | },
10 | "DB_ADDRESS_DEPLOY": {
11 | "description": "Connection string for MongoDB"
12 | },
13 | "DB_USER_DEPLOY": {
14 | "description": "DB Username"
15 | },
16 | "DB_PASS_DEPLOY": {
17 | "description": "DB Password"
18 | },
19 | "JWT_INVITE_SECRET": {
20 | "generator": "secret"
21 | },
22 | "JWT_RESET_PWD_SECRET": {
23 | "generator": "secret"
24 | },
25 | "JWT_CONFIRM_ACC_SECRET": {
26 | "generator": "secret"
27 | },
28 | "SENDGRID_API_KEY": {
29 | "description": "Sendgrid API Key"
30 | },
31 | "NO_REPLY_EMAIL": {
32 | "description": "Noreply email address"
33 | },
34 | "NO_REPLY_EMAIL": {
35 | "description": "GCP Storage Bucket Name"
36 | },
37 | "TYPE": {
38 | "description": "GCP Account Type"
39 | },
40 | "PROJECT_ID": {
41 | "description": "GCP Project ID"
42 | },
43 | "PRIVATE_KEY_ID": {
44 | "description": "GCP Private Key ID"
45 | },
46 | "PRIVATE_KEY": {
47 | "description": "GCP Private Key"
48 | },
49 | "CLIENT_EMAIL": {
50 | "description": "GCP Client Email"
51 | },
52 | "AUTH_URI": {
53 | "description": "GCP Auth URI"
54 | },
55 | "TOKEN_URI": {
56 | "description": "GCP TOken URI"
57 | },
58 | "AUTH_PROVIDER_X509_CERT_URL": {
59 | "description": "GCP Provider Cert URL"
60 | },
61 | "CLIENT_X509_CERT_URL": {
62 | "description": "GCP Cert URL"
63 | }
64 | },
65 | "formation": {
66 | "web": {
67 | "quantity": 1,
68 | "size": "free"
69 | }
70 | },
71 | "image": "heroku/nodejs",
72 | "buildpacks": [
73 | {
74 | "url": "https://github.com/heroku/heroku-buildpack-nodejs"
75 | }
76 | ]
77 | }
78 |
--------------------------------------------------------------------------------
/docs/api/vendor/prettify/lang-sql.js:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | Copyright (C) 2008 Google Inc.
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 | */
17 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\r \xA0]+/,null,"\t\n\r \u00a0"],["str",/^(?:"(?:[^\"\\]|\\.)*"|'(?:[^\'\\]|\\.)*')/,null,"\"'"]],[["com",/^(?:--[^\r\n]*|\/\*[\s\S]*?(?:\*\/|$))/],["kwd",/^(?:ADD|ALL|ALTER|AND|ANY|APPLY|AS|ASC|AUTHORIZATION|BACKUP|BEGIN|BETWEEN|BREAK|BROWSE|BULK|BY|CASCADE|CASE|CHECK|CHECKPOINT|CLOSE|CLUSTERED|COALESCE|COLLATE|COLUMN|COMMIT|COMPUTE|CONNECT|CONSTRAINT|CONTAINS|CONTAINSTABLE|CONTINUE|CONVERT|CREATE|CROSS|CURRENT|CURRENT_DATE|CURRENT_TIME|CURRENT_TIMESTAMP|CURRENT_USER|CURSOR|DATABASE|DBCC|DEALLOCATE|DECLARE|DEFAULT|DELETE|DENY|DESC|DISK|DISTINCT|DISTRIBUTED|DOUBLE|DROP|DUMMY|DUMP|ELSE|END|ERRLVL|ESCAPE|EXCEPT|EXEC|EXECUTE|EXISTS|EXIT|FETCH|FILE|FILLFACTOR|FOLLOWING|FOR|FOREIGN|FREETEXT|FREETEXTTABLE|FROM|FULL|FUNCTION|GOTO|GRANT|GROUP|HAVING|HOLDLOCK|IDENTITY|IDENTITYCOL|IDENTITY_INSERT|IF|IN|INDEX|INNER|INSERT|INTERSECT|INTO|IS|JOIN|KEY|KILL|LEFT|LIKE|LINENO|LOAD|MATCH|MATCHED|MERGE|NATURAL|NATIONAL|NOCHECK|NONCLUSTERED|NOCYCLE|NOT|NULL|NULLIF|OF|OFF|OFFSETS|ON|OPEN|OPENDATASOURCE|OPENQUERY|OPENROWSET|OPENXML|OPTION|OR|ORDER|OUTER|OVER|PARTITION|PERCENT|PIVOT|PLAN|PRECEDING|PRECISION|PRIMARY|PRINT|PROC|PROCEDURE|PUBLIC|RAISERROR|READ|READTEXT|RECONFIGURE|REFERENCES|REPLICATION|RESTORE|RESTRICT|RETURN|REVOKE|RIGHT|ROLLBACK|ROWCOUNT|ROWGUIDCOL|ROWS?|RULE|SAVE|SCHEMA|SELECT|SESSION_USER|SET|SETUSER|SHUTDOWN|SOME|START|STATISTICS|SYSTEM_USER|TABLE|TEXTSIZE|THEN|TO|TOP|TRAN|TRANSACTION|TRIGGER|TRUNCATE|TSEQUAL|UNBOUNDED|UNION|UNIQUE|UNPIVOT|UPDATE|UPDATETEXT|USE|USER|USING|VALUES|VARYING|VIEW|WAITFOR|WHEN|WHERE|WHILE|WITH|WITHIN|WRITETEXT|XML)(?=[^\w-]|$)/i,
18 | null],["lit",/^[+-]?(?:0x[\da-f]+|(?:(?:\.\d+|\d+(?:\.\d*)?)(?:e[+\-]?\d+)?))/i],["pln",/^[a-z_][\w-]*/i],["pun",/^[^\w\t\n\r \xA0\"\'][^\w\t\n\r \xA0+\-\"\']*/]]),["sql"]);
19 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "hackerAPI",
3 | "version": "3.1.4",
4 | "private": true,
5 | "scripts": {
6 | "start": "DEBUG=hackboard:* NODE_ENV=development nodemon --ignore gcp_creds.json ./bin/www.js",
7 | "start-windows": "set DEBUG=hackboard:* && set NODE_ENV=test && nodemon --ignore gcp_creds.json ./bin/www.js",
8 | "deploy": "NODE_ENV=deployment node ./bin/www.js",
9 | "debug": "DEBUG=hackboard:* NODE_ENV=development nodemon --ignore gcp_creds.json ./bin/www.js",
10 | "test": "DEBUG=hackboard:* NODE_ENV=development mocha -r dotenv/config --reporter spec tests/**.js --exit",
11 | "test-windows": "DEBUG=hackboard:* SET NODE_ENV=development & mocha -r dotenv/config --reporter spec tests/**.js --exit",
12 | "seed": "NODE_ENV=development node ./seed/index.js",
13 | "docs": "apidoc -i ./routes -o ./docs/api/",
14 | "format": "prettier --write '**/*.js'",
15 | "lint": "eslint --fix '**/*.js'"
16 | },
17 | "dependencies": {
18 | "@google-cloud/storage": "^7.7.0",
19 | "@sendgrid/mail": "^8.1.0",
20 | "bcrypt": "^5.1.1",
21 | "cookie-parser": "^1.4.6",
22 | "cookie-session": "^2.0.0",
23 | "cors": "^2.8.5",
24 | "cryptiles": "^4.1.3",
25 | "debug": "~4.3.4",
26 | "dotenv": "^16.3.1",
27 | "express": "~4.18.2",
28 | "express-validator": "^7.0.1",
29 | "express-winston": "^4.2.0",
30 | "handlebars": "^4.7.8",
31 | "jsonwebtoken": "^9.0.2",
32 | "memory-cache": "^0.2.0",
33 | "mongoose": "^8.0.4",
34 | "multer": "^1.4.2",
35 | "passport": "^0.5.3",
36 | "passport-local": "^1.0.0",
37 | "promise.allsettled": "^1.0.7",
38 | "q": "^1.5.1",
39 | "qrcode": "^1.5.3",
40 | "winston": "^3.11.0"
41 | },
42 | "devDependencies": {
43 | "@types/express": "^4.17.21",
44 | "@types/google-cloud__storage": "^1.7.2",
45 | "@types/mongodb": "^4.0.6",
46 | "@types/mongoose": "^5.11.97",
47 | "@types/multer": "^1.4.11",
48 | "apidoc": "^1.2.0",
49 | "chai": "^4.4.1",
50 | "chai-http": "^4.4.0",
51 | "eslint": "8.56.0",
52 | "eslint-config-prettier": "9.1.0",
53 | "eslint-plugin-prettier": "5.1.3",
54 | "mocha": "^10.2.0",
55 | "nodemon": "^3.0.2",
56 | "prettier": "3.1.1"
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/docs/api/vendor/prettify/lang-vb.js:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | Copyright (C) 2009 Google Inc.
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 | */
17 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\r \xA0\u2028\u2029]+/,null,"\t\n\r \u00a0\u2028\u2029"],["str",/^(?:[\"\u201C\u201D](?:[^\"\u201C\u201D]|[\"\u201C\u201D]{2})(?:[\"\u201C\u201D]c|$)|[\"\u201C\u201D](?:[^\"\u201C\u201D]|[\"\u201C\u201D]{2})*(?:[\"\u201C\u201D]|$))/i,null,'"\u201c\u201d'],["com",/^[\'\u2018\u2019](?:_(?:\r\n?|[^\r]?)|[^\r\n_\u2028\u2029])*/,null,"'\u2018\u2019"]],[["kwd",/^(?:AddHandler|AddressOf|Alias|And|AndAlso|Ansi|As|Assembly|Auto|Boolean|ByRef|Byte|ByVal|Call|Case|Catch|CBool|CByte|CChar|CDate|CDbl|CDec|Char|CInt|Class|CLng|CObj|Const|CShort|CSng|CStr|CType|Date|Decimal|Declare|Default|Delegate|Dim|DirectCast|Do|Double|Each|Else|ElseIf|End|EndIf|Enum|Erase|Error|Event|Exit|Finally|For|Friend|Function|Get|GetType|GoSub|GoTo|Handles|If|Implements|Imports|In|Inherits|Integer|Interface|Is|Let|Lib|Like|Long|Loop|Me|Mod|Module|MustInherit|MustOverride|MyBase|MyClass|Namespace|New|Next|Not|NotInheritable|NotOverridable|Object|On|Option|Optional|Or|OrElse|Overloads|Overridable|Overrides|ParamArray|Preserve|Private|Property|Protected|Public|RaiseEvent|ReadOnly|ReDim|RemoveHandler|Resume|Return|Select|Set|Shadows|Shared|Short|Single|Static|Step|Stop|String|Structure|Sub|SyncLock|Then|Throw|To|Try|TypeOf|Unicode|Until|Variant|Wend|When|While|With|WithEvents|WriteOnly|Xor|EndIf|GoSub|Let|Variant|Wend)\b/i,
18 | null],["com",/^REM\b[^\r\n\u2028\u2029]*/i],["lit",/^(?:True\b|False\b|Nothing\b|\d+(?:E[+\-]?\d+[FRD]?|[FRDSIL])?|(?:&H[0-9A-F]+|&O[0-7]+)[SIL]?|\d*\.\d+(?:E[+\-]?\d+)?[FRD]?|#\s+(?:\d+[\-\/]\d+[\-\/]\d+(?:\s+\d+:\d+(?::\d+)?(\s*(?:AM|PM))?)?|\d+:\d+(?::\d+)?(\s*(?:AM|PM))?)\s+#)/i],["pln",/^(?:(?:[a-z]|_\w)\w*(?:\[[%&@!#]+\])?|\[(?:[a-z]|_\w)\w*\])/i],["pun",/^[^\w\t\n\r \"\'\[\]\xA0\u2018\u2019\u201C\u201D\u2028\u2029]+/],["pun",/^(?:\[|\])/]]),["vb",
19 | "vbs"]);
20 |
--------------------------------------------------------------------------------
/docs/api/vendor/prettify/lang-vbs.js:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | Copyright (C) 2009 Google Inc.
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 | */
17 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\r \xA0\u2028\u2029]+/,null,"\t\n\r \u00a0\u2028\u2029"],["str",/^(?:[\"\u201C\u201D](?:[^\"\u201C\u201D]|[\"\u201C\u201D]{2})(?:[\"\u201C\u201D]c|$)|[\"\u201C\u201D](?:[^\"\u201C\u201D]|[\"\u201C\u201D]{2})*(?:[\"\u201C\u201D]|$))/i,null,'"\u201c\u201d'],["com",/^[\'\u2018\u2019](?:_(?:\r\n?|[^\r]?)|[^\r\n_\u2028\u2029])*/,null,"'\u2018\u2019"]],[["kwd",/^(?:AddHandler|AddressOf|Alias|And|AndAlso|Ansi|As|Assembly|Auto|Boolean|ByRef|Byte|ByVal|Call|Case|Catch|CBool|CByte|CChar|CDate|CDbl|CDec|Char|CInt|Class|CLng|CObj|Const|CShort|CSng|CStr|CType|Date|Decimal|Declare|Default|Delegate|Dim|DirectCast|Do|Double|Each|Else|ElseIf|End|EndIf|Enum|Erase|Error|Event|Exit|Finally|For|Friend|Function|Get|GetType|GoSub|GoTo|Handles|If|Implements|Imports|In|Inherits|Integer|Interface|Is|Let|Lib|Like|Long|Loop|Me|Mod|Module|MustInherit|MustOverride|MyBase|MyClass|Namespace|New|Next|Not|NotInheritable|NotOverridable|Object|On|Option|Optional|Or|OrElse|Overloads|Overridable|Overrides|ParamArray|Preserve|Private|Property|Protected|Public|RaiseEvent|ReadOnly|ReDim|RemoveHandler|Resume|Return|Select|Set|Shadows|Shared|Short|Single|Static|Step|Stop|String|Structure|Sub|SyncLock|Then|Throw|To|Try|TypeOf|Unicode|Until|Variant|Wend|When|While|With|WithEvents|WriteOnly|Xor|EndIf|GoSub|Let|Variant|Wend)\b/i,
18 | null],["com",/^REM\b[^\r\n\u2028\u2029]*/i],["lit",/^(?:True\b|False\b|Nothing\b|\d+(?:E[+\-]?\d+[FRD]?|[FRDSIL])?|(?:&H[0-9A-F]+|&O[0-7]+)[SIL]?|\d*\.\d+(?:E[+\-]?\d+)?[FRD]?|#\s+(?:\d+[\-\/]\d+[\-\/]\d+(?:\s+\d+:\d+(?::\d+)?(\s*(?:AM|PM))?)?|\d+:\d+(?::\d+)?(\s*(?:AM|PM))?)\s+#)/i],["pln",/^(?:(?:[a-z]|_\w)\w*(?:\[[%&@!#]+\])?|\[(?:[a-z]|_\w)\w*\])/i],["pun",/^[^\w\t\n\r \"\'\[\]\xA0\u2018\u2019\u201C\u201D\u2028\u2029]+/],["pun",/^(?:\[|\])/]]),["vb",
19 | "vbs"]);
20 |
--------------------------------------------------------------------------------
/tests/email.service.spec.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | const dotenv = require("dotenv");
3 | const path = require("path");
4 | const EmailService = require("../services/email.service");
5 | const assert = require("chai").assert;
6 |
7 | describe("Email Service", function() {
8 | it("It should send an email", (done) => {
9 | EmailService.send({
10 | to: process.env.NO_REPLY_EMAIL,
11 | from: process.env.NO_REPLY_EMAIL,
12 | subject: "Hey man",
13 | text: "Hi!",
14 | mailSettings: {
15 | sandboxMode: {
16 | enable: true
17 | }
18 | }
19 | })
20 | .then((response) => {
21 | assert.equal(
22 | response[0].statusCode,
23 | 200,
24 | "response should be accepted"
25 | );
26 | done();
27 | })
28 | .catch(done);
29 | });
30 | it("It should send multiple emails", (done) => {
31 | EmailService.sendMultiple({
32 | to: [process.env.NO_REPLY_EMAIL, process.env.NO_REPLY_EMAIL],
33 | from: process.env.NO_REPLY_EMAIL,
34 | subject: "Hey man",
35 | text: "Hi!",
36 | mailSettings: {
37 | sandboxMode: {
38 | enable: true
39 | }
40 | }
41 | })
42 | .then((responses) => {
43 | responses.forEach((resp) => {
44 | if (resp) {
45 | assert.equal(
46 | resp.statusCode,
47 | 200,
48 | "response should be accepted"
49 | );
50 | }
51 | });
52 | done();
53 | })
54 | .catch(done);
55 | });
56 | it("It should compile a handlebars email", (done) => {
57 | const handlebarPath = path.join(__dirname, `../assets/email/test.hbs`);
58 | const rendered = EmailService.renderEmail(handlebarPath, {
59 | TEST: "TESTTEST",
60 | NOT_ESCAPED: "localhost:1337/reset?token=lala"
61 | });
62 | assert.equal(
63 | 'This is used for testing email service. DO NOT REMOVE.TESTTEST.
link ',
64 | rendered
65 | );
66 | done();
67 | });
68 | });
69 |
--------------------------------------------------------------------------------
/services/database.service.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | const mongoose = require("mongoose");
3 | const logger = require("./logger.service");
4 | const Q = require("q");
5 |
6 | const TAG = "[ DATABASE SERVICE ]";
7 | const env = require("./env.service");
8 |
9 | // if DB is defined as an env var, it will go there, elsewise, try local
10 | // you ideally set DB to your database uri that the provider gives you
11 | // it should be easily findable
12 |
13 | // DATABASE SERVICE
14 | function getAddressFromEnvironment() {
15 | return env.isDevelopment()
16 | ? process.env.DB_ADDRESS_DEV
17 | : env.isProduction()
18 | ? process.env.DB_ADDRESS_DEPLOY
19 | : process.env.DB_ADDRESS_TEST;
20 | }
21 |
22 | function getUserFromEnvironment() {
23 | return env.isDevelopment()
24 | ? process.env.DB_USER_DEV
25 | : env.isProduction()
26 | ? process.env.DB_USER_DEPLOY
27 | : process.env.DB_USER_TEST;
28 | }
29 |
30 | function getPassFromEnvironment() {
31 | return process.env.NODE_ENV === "development"
32 | ? process.env.DB_PASS_DEV
33 | : process.env.NODE_ENV === "deployment"
34 | ? process.env.DB_PASS_DEPLOY
35 | : process.env.DB_PASS_TEST;
36 | }
37 |
38 | module.exports = {
39 | connect: function(callback) {
40 | mongoose.Promise = Q.promise;
41 | const user = getUserFromEnvironment();
42 | const pass = getPassFromEnvironment();
43 | const address = getAddressFromEnvironment();
44 | const url =
45 | !!user && !!pass
46 | ? `mongodb://${user}:${pass}@${address}`
47 | : `mongodb://${address}`;
48 | logger.info(`${TAG} Connecting to db on ${url}`);
49 | mongoose
50 | .connect(url)
51 | .then(
52 | function() {
53 | logger.info(`${TAG} Connected to database on ${url}`);
54 | if (callback) {
55 | callback();
56 | }
57 | },
58 | function(error) {
59 | logger.error(
60 | `${TAG} Failed to connect to database at ${url}. Error: ${error}`
61 | );
62 | throw `Failed to connect to database at ${url}`;
63 | }
64 | );
65 | },
66 | address: getAddressFromEnvironment(),
67 | readyState: function() {
68 | return mongoose.connection.readyState;
69 | }
70 | };
71 |
--------------------------------------------------------------------------------
/tests/util/team.test.util.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | const Util = {
3 | Hacker: require("./hacker.test.util")
4 | };
5 | const Constants = {
6 | MongoId: require("../../constants/testMongoId.constant")
7 | };
8 | const Team = require("../../models/team.model");
9 | const mongoose = require("mongoose");
10 | const logger = require("../../services/logger.service");
11 |
12 | const duplicateTeamName1 = {
13 | name: "SilverTeam",
14 | projectName: "AProject"
15 | };
16 |
17 | const newTeam1 = {
18 | _id: new mongoose.Types.ObjectId(),
19 | name: "BronzeTeam1",
20 | projectName: "YetAnotherProject"
21 | };
22 |
23 | const createdNewTeam1 = {
24 | name: "BronzeTeam1",
25 | members: [Util.Hacker.NoTeamHacker0._id],
26 | projectName: "YetAnotherProject"
27 | };
28 |
29 | const Team1 = {
30 | _id: Constants.MongoId.team1Id,
31 | name: "BronzeTeam",
32 | members: [Util.Hacker.TeamHacker0._id],
33 | devpostURL: "justanother.devpost.com",
34 | projectName: "YetAnotherProject"
35 | };
36 |
37 | const Team2 = {
38 | _id: Constants.MongoId.team2Id,
39 | name: "SilverTeam",
40 | members: [Util.Hacker.waitlistedHacker0._id],
41 | devpostURL: "watwatwat.devpost.com",
42 | projectName: "WatWatWat"
43 | };
44 |
45 | const Team3 = {
46 | _id: Constants.MongoId.team3Id,
47 | name: "FullTeam",
48 | members: [
49 | Util.Hacker.TeamHacker1._id,
50 | Util.Hacker.TeamHacker2._id,
51 | Util.Hacker.TeamHacker3._id,
52 | Util.Hacker.TeamHacker4._id
53 | ]
54 | };
55 |
56 | const Teams = [Team1, Team2, Team3];
57 |
58 | function store(attributes) {
59 | const teamDocs = [];
60 | const names = [];
61 | attributes.forEach((attribute) => {
62 | teamDocs.push(new Team(attribute));
63 | names.push(attribute.name);
64 | });
65 |
66 | return Team.collection.insertMany(teamDocs);
67 | }
68 |
69 | async function storeAll() {
70 | await store(Teams);
71 | }
72 |
73 | async function dropAll() {
74 | try {
75 | await Team.collection.drop();
76 | } catch (e) {
77 | if (e.code === 26) {
78 | logger.info("namespace %s not found", Team.collection.name);
79 | } else {
80 | throw e;
81 | }
82 | }
83 | }
84 |
85 | module.exports = {
86 | newTeam1: newTeam1,
87 | createdNewTeam1: createdNewTeam1,
88 | duplicateTeamName1: duplicateTeamName1,
89 | Team1: Team1,
90 | Team2: Team2,
91 | Team3: Team3,
92 | Teams: Teams,
93 | storeAll: storeAll,
94 | dropAll: dropAll
95 | };
96 |
--------------------------------------------------------------------------------