Merge Complete
This commit is contained in:
1 parent
482ef7a81a
commit
dabe23d505
6483 files changed
No files matched your search
@@ -0,0 +1,3 @@
|
||||
/.cache
|
||||
.vscode
|
||||
docs/notes
|
||||
@@ -0,0 +1,46 @@
|
||||
# Contributor Covenant Code of Conduct
|
||||
|
||||
## Our Pledge
|
||||
|
||||
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
|
||||
|
||||
## Our Standards
|
||||
|
||||
Examples of behavior that contributes to creating a positive environment include:
|
||||
|
||||
* Using welcoming and inclusive language
|
||||
* Being respectful of differing viewpoints and experiences
|
||||
* Gracefully accepting constructive criticism
|
||||
* Focusing on what is best for the community
|
||||
* Showing empathy towards other community members
|
||||
|
||||
Examples of unacceptable behavior by participants include:
|
||||
|
||||
* The use of sexualized language or imagery and unwelcome sexual attention or advances
|
||||
* Trolling, insulting/derogatory comments, and personal or political attacks
|
||||
* Public or private harassment
|
||||
* Publishing others' private information, such as a physical or electronic address, without explicit permission
|
||||
* Other conduct which could reasonably be considered inappropriate in a professional setting
|
||||
|
||||
## Our Responsibilities
|
||||
|
||||
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
|
||||
|
||||
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
|
||||
|
||||
## Scope
|
||||
|
||||
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
|
||||
|
||||
## Enforcement
|
||||
|
||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team using the online form in the contacts page of the superalgos.org website. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
|
||||
|
||||
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
|
||||
|
||||
## Attribution
|
||||
|
||||
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
|
||||
|
||||
[homepage]: http://contributor-covenant.org
|
||||
[version]: http://contributor-covenant.org/version/1/4/
|
||||
@@ -0,0 +1,55 @@
|
||||
# Contributing
|
||||
|
||||
We are thrilled you are interested in contributing to this repository. Your help may be essential to the project's success and we want you in!
|
||||
|
||||
Superalgos is a collective project, currently at a very early stage. Although this repository is not open source software yet, we do welcome contributions from the community.
|
||||
|
||||
Contributions are deemed _voluntary work_. There might be incentives in place for certain kinds of contributions. Contact us for more information in this regard.
|
||||
|
||||
In any case, contributors agree to provide an express grant of patent rights for their contributions. Submitting Pull Requests to this repository represents an express agreement with the terms of our Balanced Contributor Intellectual Property Agreement. This agreement is a direct implementation of GitHub's [Balanced Employee Intellectual Property Agreement 1.0.1](https://github.com/github/balanced-employee-ip-agreement/blob/master/Balanced_Employee_IP_Agreement.md).
|
||||
|
||||
# Balanced Contributor Intellectual Property Agreement 1.0.1
|
||||
|
||||
This BALANCED CONTRIBUTOR INTELLECTUAL PROPERTY AGREEMENT is between person or team submitting Pull Requests to this repository and Superalgos.org ("Project").
|
||||
|
||||
**What is this?** This is the Project's Intellectual Property Agreement ("Agreement"). If you've worked in the technology space before, there's a good chance that you've run across one or more of these in the past. This document is the official, entire and exclusive agreement on what intellectual property ("IP") is yours, and what belongs to the Project.
|
||||
|
||||
**Why is this?** The Project needs to be clear on what IP it owns and has rights to. Its customers, contributors, and investors depend on the Project having the legal rights to the products and services it is providing so that the Project can continue operating and doing business.
|
||||
|
||||
The Project also believes that it's important to be clear on what it doesn't own. The Project doesn't want you looking over your shoulder every time you work on something personal or worrying that the Project will someday seize your open source non-lethal mousetrap simulation software. In other words, the Project isn't interested in appropriating your personal projects.
|
||||
|
||||
**Read this.** Please read this document and be sure you understand it before you submit any Pull Requests. Due to legal risk and corporate obligations, the Project cannot, by and large, negotiate its terms. If you feel you have a particular circumstance that keeps you from signing, please let the Project's legal department ("Legal") know. And, of course, you're always free and encouraged to get your own legal counsel to explain anything you're not clear on.
|
||||
|
||||
Cool? Then, by submitting your first Pull Request, and as a condition of your contribution, you agree to the following:
|
||||
|
||||
1. **What the Project owns.** The Project owns any IP ("Project IP") that you create, or help create _as its contributor_, but only if it meets one or more of these additional conditions: The IP was (i) related to an existing or prospective Project product or service at the time you developed, invented, or created it, (ii) developed for use by the Project, or (iii) developed or promoted with existing Project IP or with the Project's endorsement. You hereby grant and assign, and will grant and assign, to the Project all rights and interests in all Project IP.
|
||||
|
||||
"Project IP" includes concepts, designs, developments, discoveries, ideas, improvements, inventions, trade secrets, trademarks, and works of authorship.
|
||||
|
||||
<<<<<<< HEAD
|
||||
2. **What the Project doesn't own.** If you create IP that doesn't fit into one of the categories listed above, the Project doesn't own it. In other words, the Project doesn't own concepts, designs, developments, discoveries, ideas, improvements, inventions, trade secrets, trademarks, or works of authorship that you develop, invent, or create that do not meet any of the conditions in Section 1.
|
||||
|
||||
3. **Contribution of your IP to Project projects.** If you include your own IP – such as IP you created prior to working for the Project – into a Project product or service, it's still yours, of course, but you grant the Project a non-exclusive, irrevocable, fully paid-up, royalty-free, perpetual, sublicensable, transferable, worldwide license to use it without restriction in any way or implementation, in modified form, or as is, by itself, or incorporated into another product or service ("License"). If you include your name in any project over which the Project would have rights under this Agreement, such as in a copyright notice or a comment in code or documentation, then the License covers the rights associated with that use of your name as well.
|
||||
=======
|
||||
2. **What the Project doesn't own.** If you create IP that doesn't fit into one of the categories listed above, the Project doesn't own it. In other words, the Project doesn't own concepts, designs, developments, discoveries, ideas, improvements, inventions, trade secrets, trademarks, or works of authorship that you develop, invent, or create that do not meet any of the conditions in Section 1.
|
||||
|
||||
3. **Contribution of your IP to Project projects.** If you include your own IP � such as IP you created prior to working for the Project � into a Project product or service, it's still yours, of course, but you grant the Project a non-exclusive, irrevocable, fully paid-up, royalty-free, perpetual, sub-licensable, transferable, worldwide license to use it without restriction in any way or implementation, in modified form, or as is, by itself, or incorporated into another product or service ("License"). If you include your name in any project over which the Project would have rights under this Agreement, such as in a copyright notice or a comment in code or documentation, then the License covers the rights associated with that use of your name as well.
|
||||
>>>>>>> develop
|
||||
|
||||
4. **Your contributions to non-Project projects.** The Project recognizes that you may be engaged in work that requires you to submit IP to entities other than the Project, such as open source projects used by the Project. Please make sure that Legal is aware of what you're working on so that Legal can help with any licensing issues. If any project asks you to sign a contribution agreement, you should check with Legal before doing so. These agreements may be legally binding on the Project and so should be run through Legal first.
|
||||
|
||||
5. **Voluntary Works** All Project IP that you are involved with or create as part of your work for the Project is voluntary work which does not require compensation. There might be incentives in place for certain kinds of contributions. Feel free to contact the Project to learn more.
|
||||
|
||||
6. **No conflicts.** You agree that you don't have any outstanding agreements or obligations that conflict with those in this Agreement, and that you won't enter into conflicting agreements in the future.
|
||||
|
||||
7. **IP protection.** The Project might someday need to show the work that went into the development of IP that it uses or has used, or to make government filings to establish that it owns the IP or has rights over it. To help in those situations, you agree not to destroy any records you maintain relating to the development of any Project IP or IP under License (together, "All IP"), and, if the Project asks, to provide those records to the Project. You agree to help the Project secure and defend its rights in All IP. For your help the Project will compensate you at a reasonable rate. If the Project is unable to secure your help, you authorize the Project to act on your behalf (as your agent and attorney-in-fact) in securing all rights related to All IP.
|
||||
|
||||
8. **Confidentiality.** As an contributor or contractor of the Project, you will have access to sensitive confidential information that is important to the Project's business. You are responsible for keeping this information confidential, including after you end your work for the Project.
|
||||
|
||||
"Confidential Information" includes non-public technical details about our products or services, financial information, business strategies and forecasts, customer data, or any other information, data or know-how that is valuable to the Project because it is not publicly known.
|
||||
|
||||
<<<<<<< HEAD
|
||||
The Project's Confidential Information is sensitive and we expect that you'll treat it as such. You agree to only use the Project's Confidential Information for the purpose of performing your contribution and for the benefit of the Project. You will do your best to keep Confidential Information secret. If you are not sure if something is Confidential Information, you should assume that it is, until you can confirm otherwise.
|
||||
=======
|
||||
The Project's Confidential Information is sensitive and we expect that you'll treat it as such. You agree to only use the Project's Confidential Information for the purpose of performing your contribution and for the benefit of the Project. You will do your best to keep Confidential Information secret. If you are not sure if something is Confidential Information, you should assume that it is, until you can confirm otherwise.
|
||||
>>>>>>> develop
|
||||
@@ -0,0 +1,66 @@
|
||||
COPYRIGHT NOTICE
|
||||
|
||||
<<<<<<< HEAD
|
||||
© Copyright 2018 Superalgos.org
|
||||
=======
|
||||
© Copyright 2019 Superalgos.org
|
||||
>>>>>>> develop
|
||||
|
||||
|
||||
LICENSE NOTICE
|
||||
|
||||
<<<<<<< HEAD
|
||||
Superalgos is a collaborative project currently at a very early stage. Because certain aspects of
|
||||
the project are still not clearly defined, we have chosen to --temporarily-- grant a restrictive
|
||||
license for the use of this repository, until those aspects are clarified and a proper open source
|
||||
license can be granted.
|
||||
|
||||
Superalgos.org is publishing the code of this software for several reasons. However, it shall not be considered free software yet. Superalgos is a collaborative project in the crypto space and this
|
||||
=======
|
||||
Superalgos is a collaborative project currently at a very early stage. Because certain aspects of
|
||||
the project are still not clearly defined, we have chosen to --temporarily-- grant a restrictive
|
||||
license for the use of this repository, until those aspects are clarified and a proper open source
|
||||
license can be granted.
|
||||
|
||||
Superalgos.org is publishing the code of this software for several reasons. However, it shall not be considered free software yet. Superalgos is a collaborative project in the crypto space and this
|
||||
>>>>>>> develop
|
||||
software is still proprietary software.
|
||||
|
||||
The reasons for opening up the code of this software at this stage are the following:
|
||||
|
||||
<<<<<<< HEAD
|
||||
* We believe that transparency is paramount to achieving our goals, so we want everyone to
|
||||
be able to understand what this software does and how. Opening up the code of this software
|
||||
=======
|
||||
* We believe that transparency is paramount to achieving our goals, so we want everyone to
|
||||
be able to understand what this software does and how. Opening up the code of this software
|
||||
>>>>>>> develop
|
||||
allows anyone to take a close look.
|
||||
|
||||
* We welcome contributions from the community. Contributions are regarded as voluntary work.
|
||||
There may be incentives in place for certain kinds of contributions. Contact us to learn more.
|
||||
Contributors agree to provide an express grant of patent rights for their contributions.
|
||||
|
||||
|
||||
LICENSE WORDING
|
||||
|
||||
Superalgos.org grants a limited license for the following uses:
|
||||
|
||||
1. CODE REVIEW AND AUDITS. You are granted permission to clone this repository to analyze,
|
||||
review or audit the code.
|
||||
|
||||
<<<<<<< HEAD
|
||||
2. COLLABORATING WITH Superalgos.org. You are granted permission to fork this repository
|
||||
with the sole purpose of correcting bugs and developing functionality in agreement with
|
||||
Superalgos.org. By contributing to this repository you explicitely agree to the terms
|
||||
detailed in CONTRIBUTING.MD.
|
||||
|
||||
PLEASE SEE CONTRIBUTING.MD FOR MORE DETAILS ON THE IMPLICATIONS SURROUNDING YOUR CONTRIBUTIONS TO THIS REPOSITORY.
|
||||
=======
|
||||
2. COLLABORATING WITH Superalgos.org. You are granted permission to fork this repository
|
||||
with the sole purpose of correcting bugs and developing functionality in agreement with
|
||||
Superalgos.org. By contributing to this repository you explicitly agree to the terms
|
||||
detailed in CONTRIBUTING.MD.
|
||||
|
||||
PLEASE SEE CONTRIBUTING.MD FOR MORE DETAILS ON THE IMPLICATIONS SURROUNDING YOUR CONTRIBUTIONS TO THIS REPOSITORY.
|
||||
>>>>>>> develop
|
||||
@@ -0,0 +1,23 @@
|
||||
# Superlgos Notifications Module
|
||||
|
||||
## Introduction
|
||||
|
||||
The general purpose of the notifications module is providing notification services to other Superalgos Platform modules.
|
||||
|
||||
## Quick Start
|
||||
|
||||
Requirements:
|
||||
|
||||
- NodeJS 8+
|
||||
- NPM (comes installed with NodeJS)
|
||||
- [Github authorization via SSH](https://help.github.com/articles/connecting-to-github-with-ssh/): *optional* - removes need to authenticate every push or pull from GitHub especially as this is a private repo.
|
||||
|
||||
1. Clone this repository `git clone https://github.com/AdvancedAlgos/NotificationsModule.git`
|
||||
2. `cd NotificationsModule`
|
||||
5. Navigate to desired package (eg, server) in /packages and look at its README.md for further instructions.
|
||||
|
||||
## Getting Started
|
||||
|
||||
_This repo is currently under heavy initial-phase development and is not representative of the more mature product. On that note, feel free to look around and keep an eye out as the development unfolds!_
|
||||
|
||||
1. Where we set sail — [to the docs!](./docs/README.md)
|
||||
@@ -0,0 +1,24 @@
|
||||
# Superalgos Notifications Module Documentation
|
||||
|
||||
## Architecture
|
||||
Currently, this module is only a GraphQL server providing notification services to other platform modules. For example, it wraps the SendGrid API and allows other modules to send transactional emails or provides signup methods to campaign newsletter list.
|
||||
|
||||
There is no database or client for this module currently.
|
||||
|
||||
### GraqphQL schema
|
||||
|
||||
The Notifications Module graphql schema:
|
||||
|
||||
```
|
||||
type Mutation {
|
||||
Corporate_NewsletterSignup(email: String!): String
|
||||
Corporate_NewsletterSignupVerify(token: String!): String
|
||||
Corporate_Contact(email: String!, name: String, message: String!, recaptcha: String!): String
|
||||
Master_NewsletterSignup(email: String!): String
|
||||
Master_NewsletterSignupVerify(token: String!): String
|
||||
Master_Feedback(email: String!, subject: String!, message: String!, recaptcha: String!): String
|
||||
Teams_SendTeamMemberInvite(email: String!, teamName: String!): String
|
||||
Teams_SendTeamCreateConfirmation(email: String!, teamName: String!, botName: String!): String
|
||||
Teams_VerifyTeamMemberInviteToken(token: String!): String
|
||||
}
|
||||
```
|
||||
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"name": "NotificationsModule",
|
||||
"version": "0.0.1",
|
||||
"description": "Superalgos Notifications Module",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/Superalgos/NotificationsModule.git"
|
||||
},
|
||||
"keywords": [
|
||||
"Superalgos"
|
||||
],
|
||||
"author": "Barry Low <bearcanru@gmail.com>",
|
||||
"license": "SEE LICENSE IN LICENSE.MD",
|
||||
"bugs": {
|
||||
"url": "https://github.com/Superalgos/NotificationsModule.git/issues"
|
||||
},
|
||||
"homepage": "https://github.com/Superalgos/NotificationsModule.git#readme"
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"presets": ["@babel/preset-env"],
|
||||
"plugins": [
|
||||
"@babel/plugin-proposal-throw-expressions",
|
||||
["@babel/plugin-proposal-class-properties", { "loose": true }]
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
PORT=4101
|
||||
|
||||
PRESHARED_GATEWAY_KEY=SECRET_STUFF
|
||||
|
||||
NODE_ENV=development
|
||||
GENERATE_SOURCEMAP=false
|
||||
|
||||
# APIs
|
||||
PLATFORM_API_URL=https://platform-api-dev.advancedalgos.net
|
||||
|
||||
# SendGrid Api Keys
|
||||
SG_APIKEY=sg-apikey
|
||||
SG_APIKEY_CAMPAIGN=sg-apikey-contacts
|
||||
|
||||
# SendGrid Template IDs
|
||||
SG_MASTER_SIGNUP_EMAILID=sg-master-signup-template-id
|
||||
SG_MASTER_FEEDBACK_EMAILID=sg-master-feedback-template-id
|
||||
|
||||
SG_CORPORATE_SIGNUP_EMAILID=sg-master-signup-template-id
|
||||
SG_CORPORATE_CONTACT_EMAILID=sg-master-contact-template-id
|
||||
|
||||
SG_TEAMS_MEMBER_INVITE_EMAILID=sg-teams-member-invite-template-id
|
||||
SG_TEAMS_TEAMCREATE_EMAILID=sg-teams-teamcreate-template-id
|
||||
|
||||
#SendGrid Origins
|
||||
SG_PLATFORM_ORIGIN=https://platform-dev.advancedalgos.net
|
||||
# SG_PLATFORM_ORIGIN=https://platform.advancedalgos.net
|
||||
SG_CORPORATE_ORIGIN=http://localhost:3999
|
||||
# SG_CORPORATE_ORIGIN=https://advancedalgos.net
|
||||
|
||||
# Google ReCaptcha
|
||||
RECAPTCHA=google-recaptcha-secret
|
||||
@@ -0,0 +1,13 @@
|
||||
/.env
|
||||
/.env.prod
|
||||
.env.dev
|
||||
/database/.env
|
||||
/database/docker-compose.prisma.prod.yml
|
||||
/docker-compose.prisma.prod.yml
|
||||
/docker-compose.prod.yml
|
||||
.graphqlconfig.prod.yml
|
||||
dist
|
||||
node_modules
|
||||
.idea
|
||||
.vscode
|
||||
*.log
|
||||
@@ -0,0 +1,46 @@
|
||||
# Contributor Covenant Code of Conduct
|
||||
|
||||
## Our Pledge
|
||||
|
||||
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
|
||||
|
||||
## Our Standards
|
||||
|
||||
Examples of behavior that contributes to creating a positive environment include:
|
||||
|
||||
* Using welcoming and inclusive language
|
||||
* Being respectful of differing viewpoints and experiences
|
||||
* Gracefully accepting constructive criticism
|
||||
* Focusing on what is best for the community
|
||||
* Showing empathy towards other community members
|
||||
|
||||
Examples of unacceptable behavior by participants include:
|
||||
|
||||
* The use of sexualized language or imagery and unwelcome sexual attention or advances
|
||||
* Trolling, insulting/derogatory comments, and personal or political attacks
|
||||
* Public or private harassment
|
||||
* Publishing others' private information, such as a physical or electronic address, without explicit permission
|
||||
* Other conduct which could reasonably be considered inappropriate in a professional setting
|
||||
|
||||
## Our Responsibilities
|
||||
|
||||
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
|
||||
|
||||
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
|
||||
|
||||
## Scope
|
||||
|
||||
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
|
||||
|
||||
## Enforcement
|
||||
|
||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at feedback at advancedalgos dot org. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
|
||||
|
||||
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
|
||||
|
||||
## Attribution
|
||||
|
||||
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
|
||||
|
||||
[homepage]: http://contributor-covenant.org
|
||||
[version]: http://contributor-covenant.org/version/1/4/
|
||||
@@ -0,0 +1,45 @@
|
||||
# Contributing
|
||||
|
||||
We are thrilled you are interested in contributing to this repository. Your help may be essential to the project's success and we want you in!
|
||||
|
||||
Advanced Algos LTD is a startup, currently at a very early stage. Although this repository is not open source software yet, we do welcome contributions from the community.
|
||||
|
||||
Contributions are deemed _voluntary work_. There might be incentives in place for certain kinds of contributions. Contact us for more information in this regards.
|
||||
|
||||
In any case, contributors agree to provide an express grant of patent rights for their contributions. Submitting Pull Requests to this repository represents an express agreement with the terms of our Balanced Contributor Intellectual Property Agreement. This agreement is a direct implementation of GitHub's [Balanced Employee Intellectual Property Agreement 1.0.1](https://github.com/github/balanced-employee-ip-agreement/blob/master/Balanced_Employee_IP_Agreement.md).
|
||||
|
||||
# Balanced Contributor Intellectual Property Agreement 1.0.1
|
||||
|
||||
This BALANCED CONTRIBUTOR INTELLECTUAL PROPERTY AGREEMENT is between person or team submitting Pull Requests to this repository and Advanced Algos LTD ("Company").
|
||||
|
||||
**What is this?** This is the Company's Intellectual Property Agreement ("Agreement"). If you've worked in the technology space before, there's a good chance that you've run across one or more of these in the past. This document is the official, entire and exclusive agreement on what intellectual property ("IP") is yours, and what belongs to the Company.
|
||||
|
||||
**Why is this?** The Company needs to be clear on what IP it owns and has rights to. Its customers, contributors, and investors depend on the Company having the legal rights to the products and services it is providing so that the Company can continue operating and doing business.
|
||||
|
||||
The Company also believes that it's important to be clear on what it doesn't own. The Company doesn't want you looking over your shoulder every time you work on something personal or worrying that the Company will someday seize your open source non-lethal mousetrap simulation software. In other words, the Company isn't interested in appropriating your personal projects.
|
||||
|
||||
**Read this.** Please read this document and be sure you understand it before you submit any Pull Requests. Due to legal risk and corporate obligations, the Company cannot, by and large, negotiate its terms. If you feel you have a particular circumstance that keeps you from signing, please let the Company's legal department ("Legal") know. And, of course, you're always free and encouraged to get your own legal counsel to explain anything you're not clear on.
|
||||
|
||||
Cool? Then, by submitting your first Pull Request, and as a condition of your contribution, you agree to the following:
|
||||
|
||||
1. **What the Company owns.** The Company owns any IP ("Company IP") that you create, or help create _as its contributor_, but only if it meets one or more of these additional conditions: The IP was (i) related to an existing or prospective Company product or service at the time you developed, invented, or created it, (ii) developed for use by the Company, or (iii) developed or promoted with existing Company IP or with the Company's endorsement. You hereby grant and assign, and will grant and assign, to the Company all rights and interests in all Company IP.
|
||||
|
||||
"Company IP" includes concepts, designs, developments, discoveries, ideas, improvements, inventions, trade secrets, trademarks, and works of authorship.
|
||||
|
||||
2. **What the Company doesn't own.** If you create IP that doesn't fit into one of the categories listed above, the Company doesn't own it. In other words, the Company doesn't own concepts, designs, developments, discoveries, ideas, improvements, inventions, trade secrets, trademarks, or works of authorship that you develop, invent, or create that do not meet any of the conditions in Section 1.
|
||||
|
||||
3. **Contribution of your IP to Company projects.** If you include your own IP – such as IP you created prior to working for the Company – into a Company product or service, it's still yours, of course, but you grant the Company a non-exclusive, irrevocable, fully paid-up, royalty-free, perpetual, sublicensable, transferable, worldwide license to use it without restriction in any way or implementation, in modified form, or as is, by itself, or incorporated into another product or service ("License"). If you include your name in any project over which the Company would have rights under this Agreement, such as in a copyright notice or a comment in code or documentation, then the License covers the rights associated with that use of your name as well.
|
||||
|
||||
4. **Your contributions to non-Company projects.** The Company recognizes that you may be engaged in work that requires you to submit IP to entities other than the Company, such as open source projects used by the Company. Please make sure that Legal is aware of what you're working on so that Legal can help with any licensing issues. If any project asks you to sign a contribution agreement, you should check with Legal before doing so. These agreements may be legally binding on the Company and so should be run through Legal first.
|
||||
|
||||
5. **Voluntary Works** All Company IP that you are involved with or create as part of your work for the Company is voluntary work which does not require compensation. There might be incentives in place for certain kinds of contributions. Feel free to contact the Company to learn more.
|
||||
|
||||
6. **No conflicts.** You agree that you don't have any outstanding agreements or obligations that conflict with those in this Agreement, and that you won't enter into conflicting agreements in the future.
|
||||
|
||||
7. **IP protection.** The Company might someday need to show the work that went into the development of IP that it uses or has used, or to make government filings to establish that it owns the IP or has rights over it. To help in those situations, you agree not to destroy any records you maintain relating to the development of any Company IP or IP under License (together, "All IP"), and, if the Company asks, to provide those records to the Company. You agree to help the Company secure and defend its rights in All IP. For your help the Company will compensate you at a reasonable rate. If the Company is unable to secure your help, you authorize the Company to act on your behalf (as your agent and attorney-in-fact) in securing all rights related to All IP.
|
||||
|
||||
8. **Confidentiality.** As an contributor or contractor of the Company, you will have access to sensitive confidential information that is important to the Company's business. You are responsible for keeping this information confidential, including after you end your work for the Company.
|
||||
|
||||
"Confidential Information" includes non-public technical details about our products or services, financial information, business strategies and forecasts, customer data, or any other information, data or know-how that is valuable to the Company because it is not publicly known.
|
||||
|
||||
The Company's Confidential Information is sensitive and we expect that you'll treat it as such. You agree to only use the Company's Confidential Information for the purpose of performing your contribution and for the benefit of the Company. You will do your best to keep Confidential Information secret. If you are not sure if something is Confidential Information, you should assume that it is, until you can confirm otherwise.
|
||||
@@ -0,0 +1,23 @@
|
||||
FROM mhart/alpine-node:8
|
||||
|
||||
ENV PORT=4301
|
||||
|
||||
RUN mkdir -p /var/www/app && \
|
||||
mkdir -p /var/www/app/node_modules
|
||||
|
||||
# Use app directory as current workdir
|
||||
WORKDIR /var/www/app
|
||||
ENV PATH /var/www/app/node_modules/.bin:$PATH
|
||||
# Copy package.json to workdir
|
||||
COPY package.json /var/www/app/package.json
|
||||
|
||||
# Install dependencies
|
||||
RUN npm install
|
||||
|
||||
RUN npm audit fix
|
||||
|
||||
# Copy application code
|
||||
COPY . /var/www/app
|
||||
|
||||
# Expose Port
|
||||
EXPOSE $PORT
|
||||
@@ -0,0 +1,39 @@
|
||||
COPYRIGHT NOTICE
|
||||
|
||||
© Copyright 2019 Superalgos.org
|
||||
|
||||
|
||||
LICENSE NOTICE
|
||||
|
||||
Superalgos is a collaborative project currently at a very early stage. Because certain aspects of
|
||||
the project are still not clearly defined, we have chosen to --temporarily-- grant a restrictive
|
||||
license for the use of this repository, until those aspects are clarified and a proper open source
|
||||
license can be granted.
|
||||
|
||||
Superalgos.org is publishing the code of this software for several reasons. However, it shall not be considered free software yet. Superalgos is a collaborative project in the crypto space and this
|
||||
software is still proprietary software.
|
||||
|
||||
The reasons for opening up the code of this software at this stage are the following:
|
||||
|
||||
* We believe that transparency is paramount to achieving our goals, so we want everyone to
|
||||
be able to understand what this software does and how. Opening up the code of this software
|
||||
allows anyone to take a close look.
|
||||
|
||||
* We welcome contributions from the community. Contributions are regarded as voluntary work.
|
||||
There may be incentives in place for certain kinds of contributions. Contact us to learn more.
|
||||
Contributors agree to provide an express grant of patent rights for their contributions.
|
||||
|
||||
|
||||
LICENSE WORDING
|
||||
|
||||
Superalgos.org grants a limited license for the following uses:
|
||||
|
||||
1. CODE REVIEW AND AUDITS. You are granted permission to clone this repository to analyze,
|
||||
review or audit the code.
|
||||
|
||||
2. COLLABORATING WITH Superalgos.org. You are granted permission to fork this repository
|
||||
with the sole purpose of correcting bugs and developing functionality in agreement with
|
||||
Superalgos.org. By contributing to this repository you explicitly agree to the terms
|
||||
detailed in CONTRIBUTING.MD.
|
||||
|
||||
PLEASE SEE CONTRIBUTING.MD FOR MORE DETAILS ON THE IMPLICATIONS SURROUNDING YOUR CONTRIBUTIONS TO THIS REPOSITORY.
|
||||
@@ -0,0 +1,109 @@
|
||||
# Superalgos Notifications GraphQL API Server
|
||||
|
||||
This is the Superalgos Notifications Module server-side GraphQL API server. We use Docker to develop locally and for our production workflow.
|
||||
|
||||
This module currently has no client-side component.
|
||||
|
||||
## Getting Started
|
||||
|
||||
Run
|
||||
```
|
||||
npm install
|
||||
```
|
||||
then
|
||||
```
|
||||
npm run dev
|
||||
```
|
||||
|
||||
### Using Docker
|
||||
|
||||
Get latest Docker and Docker Compose: [https://docs.docker.com/compose/install/](https://docs.docker.com/compose/install/)
|
||||
|
||||
#### Using Docker container for Development
|
||||
|
||||
To run starter kit in development mode with hot code reload execute:
|
||||
|
||||
Run docker container in background:
|
||||
|
||||
```
|
||||
docker-compose up -d
|
||||
```
|
||||
|
||||
If image issues, try running:
|
||||
```
|
||||
docker-compose up --build
|
||||
```
|
||||
then run
|
||||
```
|
||||
docker-compose up -d
|
||||
```
|
||||
|
||||
To view logs
|
||||
```
|
||||
docker-compose logs -f -t
|
||||
```
|
||||
Hit Ctrl + c to exit logs without stopping service
|
||||
|
||||
To stop service
|
||||
```
|
||||
docker-compose down
|
||||
```
|
||||
|
||||
### Main Libraries
|
||||
|
||||
- [*Webpack 4*](https://webpack.js.org/):web application bundler. Allows us to us latest newer JS ECMA features that increase productivity and code clarity. Also allows additional libraries such as modular and programmable CSS via SASS/SCSS/LESS. Provides webserver for local development.
|
||||
- [*Bulma CSS Framework*](https://bulma.io/documentation/): Bulma is a highly-customizable CSS-only framework allowing us to quickly prototype the layout of a webapp without being complicated by opinionated functionality represented in libraries such as Bootstrap or Material UI. Grants us the flexibility to create a custom look at top speed whilst minimizing baggage.
|
||||
- [*HyperApp*](https://github.com/hyperapp/hyperapp): Allows a controlled Flux-styled approach to state-management and data-flow through components like React minus the excess boilerplate and learning curve.
|
||||
- [*Docker*](https://www.docker.com/what-docker)
|
||||
|
||||
### File organization
|
||||
|
||||
```
|
||||
. # Top level directory located at your choice
|
||||
├── src
|
||||
│ ├── actions # Actions are functions that change the app state
|
||||
│ ├── assets # images, logos and other static assets
|
||||
│ ├── state # Schema of state — the single source of truth concerning app state.
|
||||
│ ├── styles # SASS/SCSS styles
|
||||
│ ├── utils # Local storage and other utils
|
||||
│ └── views # Main folder for editing site content
|
||||
│ ├─ nav # Nav components — header, footer, etc.
|
||||
│ ├─ pages # Nav components — header, footer, etc.
|
||||
│ │ ├─ landing # Homepage
|
||||
│ │ │ ├─ sections # Homepage sections. Collated in its own index.js
|
||||
│ │ │ └─ index.js # Main homepage component. Pulls in sections
|
||||
│ │ └─ ... # Other page/component folders
|
||||
│ └─ index.js # Main view container. Main router
|
||||
├── html
|
||||
│ └── index.html # index.html template pulled in by Webpack to attach transpiled bundles
|
||||
├── index.js # JS entry point to website
|
||||
│
|
||||
├── tools # utility scripts, mostly for webpack configuration
|
||||
│
|
||||
├── node_modules # created by running `npm install` in this packages root dir
|
||||
├── dist # created by `npm run develop` - a cache of bundled files served by Webpack for local development
|
||||
└── build # created by `npm run build` - location of deployable production bundle
|
||||
|
||||
```
|
||||
|
||||
## Deployment
|
||||
|
||||
The simplest deployment is compiling/transpiling the site to a distribution bundle and then uploading the files in the bundle to a web-accessible folder or storage.
|
||||
|
||||
For this application we use Webpack to transpile the application which combines and minimizes all code and assets into an optimized bundle without and of the development code and resources.
|
||||
|
||||
To build, run:
|
||||
```
|
||||
npm run build
|
||||
```
|
||||
Looking in this packages directory, there should be a ./build directory with the final built files that can be uploaded.
|
||||
|
||||
### Create Docker image
|
||||
|
||||
```
|
||||
docker build -t aateamapi/prod .
|
||||
```
|
||||
|
||||
### Deployment instructions
|
||||
|
||||
Coming soon...
|
||||
@@ -0,0 +1,19 @@
|
||||
version: '3'
|
||||
services:
|
||||
api:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
env_file: ./.env.dev
|
||||
container_name: aanotificationapi
|
||||
ports:
|
||||
- "4101:4101"
|
||||
volumes:
|
||||
- .:/var/www/app
|
||||
- /var/www/app/node_modules
|
||||
tty: true
|
||||
stdin_open: true
|
||||
volumes:
|
||||
working_dir: /var/www/app
|
||||
restart: always
|
||||
command: node --require @babel/register --require dotenv/config src/index.js
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,44 @@
|
||||
{
|
||||
"name": "aa-notifications-server",
|
||||
"scripts": {
|
||||
"start": "NODE_ENV=production nodemon -e js,graphql -x node -r @babel/register -r dotenv/config src/index.js",
|
||||
"debug": "nodemon --trace-warnings src/index.js --watch ./src --exec \"node --require @babel/register --require dotenv/config\"",
|
||||
"playground": "graphql playground --dotenv dotenv/config",
|
||||
"dev": "npm-run-all --parallel debug playground"
|
||||
},
|
||||
"dependencies": {
|
||||
"@sendgrid/client": "^6.3.0",
|
||||
"@sendgrid/mail": "^6.3.1",
|
||||
"apollo-errors": "^1.9.0",
|
||||
"apollo-server-express": "^2.2.6",
|
||||
"axios": "^0.18.0",
|
||||
"cors": "^2.8.5",
|
||||
"express": "^4.16.4",
|
||||
"fast-xml-parser": "^3.12.10",
|
||||
"graphql-import": "^0.7.1",
|
||||
"graphql-middleware": "^2.0.2",
|
||||
"graphql-subscriptions": "^1.0.0",
|
||||
"graphql-tag": "^2.10.0",
|
||||
"graphql-tools": "^4.0.3",
|
||||
"jsonwebtoken": "^8.4.0",
|
||||
"lodash.get": "^4.4.2",
|
||||
"lodash.merge": "^4.6.1",
|
||||
"request": "^2.88.0",
|
||||
"request-promise-native": "^1.0.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/cli": "^7.2.0",
|
||||
"@babel/core": "^7.2.0",
|
||||
"@babel/node": "^7.2.0",
|
||||
"@babel/plugin-proposal-class-properties": "^7.2.1",
|
||||
"@babel/plugin-proposal-throw-expressions": "^7.2.0",
|
||||
"@babel/polyfill": "^7.0.0",
|
||||
"@babel/preset-env": "^7.2.0",
|
||||
"@babel/register": "^7.0.0",
|
||||
"dotenv": "^6.2.0",
|
||||
"graphql-cli": "^2.17.0",
|
||||
"nodemon": "^1.18.7",
|
||||
"npm-run-all": "^4.1.5",
|
||||
"winston": "^3.1.0"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,131 @@
|
||||
import http from 'http'
|
||||
import { ApolloServer, makeExecutableSchema } from 'apollo-server-express'
|
||||
import { applyMiddleware as applyGraphQLMiddleware } from 'graphql-middleware'
|
||||
import { moduleAuth } from './middleware'
|
||||
import logger from './logger'
|
||||
|
||||
/**
|
||||
*
|
||||
* @description Creates an Apollo Server. Setup based on `vue-cli-plugin-apollo`.
|
||||
* @param {Object} app Express application
|
||||
* @param {Object} options Apollo options
|
||||
* @returns {Object} HTTP Server
|
||||
*/
|
||||
export default function createApolloServer(
|
||||
app,
|
||||
{
|
||||
// Main options
|
||||
graphqlEndpoint = '',
|
||||
typeDefs = {},
|
||||
resolvers = {},
|
||||
schemaDirectives = {},
|
||||
directiveResolvers = {},
|
||||
graphqlMiddlewares = [],
|
||||
dataSources = () => ({}),
|
||||
context = () => ({}),
|
||||
// Subscriptions
|
||||
subscriptionsEndpoint = '',
|
||||
wsMiddlewares = [],
|
||||
// Mocks
|
||||
mocks,
|
||||
// Apollo Engine
|
||||
engineKey = '',
|
||||
// HTTP options
|
||||
cors = true,
|
||||
timeout = 120000,
|
||||
// Extra options for Apollo Server
|
||||
apolloServerOptions = {},
|
||||
}
|
||||
) {
|
||||
const schema = makeExecutableSchema({
|
||||
typeDefs,
|
||||
resolvers,
|
||||
schemaDirectives,
|
||||
directiveResolvers,
|
||||
resolverValidationOptions: {
|
||||
requireResolversForResolveType: false,
|
||||
},
|
||||
})
|
||||
|
||||
// Apollo server options
|
||||
const options = {
|
||||
...apolloServerOptions,
|
||||
schema: applyGraphQLMiddleware(schema, ...graphqlMiddlewares),
|
||||
tracing: true,
|
||||
cacheControl: true,
|
||||
introspection: true,
|
||||
playground: true,
|
||||
engine: engineKey ? { apiKey: engineKey } : false,
|
||||
dataSources,
|
||||
// Resolvers context in POST requests
|
||||
context: async ({ req, connection }) => {
|
||||
let contextData
|
||||
try {
|
||||
if (connection) {
|
||||
contextData = { ...connection.context }
|
||||
} else {
|
||||
contextData = await context({ req, request: req })
|
||||
}
|
||||
} catch (err) {
|
||||
logger.error(err)
|
||||
throw err
|
||||
}
|
||||
|
||||
return contextData
|
||||
},
|
||||
// Resolvers context in WebSocket requests
|
||||
subscriptions: {
|
||||
path: subscriptionsEndpoint,
|
||||
onConnect: async (connection, websocket) => {
|
||||
const { authorization, userid } = connection
|
||||
|
||||
let contextData = {}
|
||||
try {
|
||||
// Simulate `req` object for auth
|
||||
const req = { headers: { authorization, userid } }
|
||||
|
||||
// Call all middlewares in order and modify `req`
|
||||
await new Promise((resolve, reject) =>
|
||||
wsMiddlewares.reduceRight(
|
||||
(acc, m) => err => (err ? reject(err) : m(req, null, acc)),
|
||||
err => (err ? reject(err) : resolve())
|
||||
)()
|
||||
)
|
||||
|
||||
contextData = await context({
|
||||
connection,
|
||||
websocket,
|
||||
request: req,
|
||||
req,
|
||||
})
|
||||
} catch (err) {
|
||||
logger.error(err)
|
||||
}
|
||||
|
||||
return contextData
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
// Apollo Server
|
||||
const server = new ApolloServer(options)
|
||||
|
||||
// Express middleware
|
||||
server.applyMiddleware({
|
||||
moduleAuth,
|
||||
app,
|
||||
cors,
|
||||
path: graphqlEndpoint,
|
||||
// gui: {
|
||||
// endpoint: graphqlEndpoint,
|
||||
// subscriptionEndpoint: graphqlSubscriptionsPath,
|
||||
// },
|
||||
})
|
||||
|
||||
// Create HTTP server and add subscriptions
|
||||
const httpServer = http.createServer(app)
|
||||
httpServer.setTimeout(timeout)
|
||||
server.installSubscriptionHandlers(httpServer)
|
||||
|
||||
return httpServer
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
import { ApolloError } from 'apollo-server-express'
|
||||
import { inspect } from 'util'
|
||||
import logger from '../logger'
|
||||
|
||||
export {
|
||||
ApolloError,
|
||||
AuthenticationError,
|
||||
ForbiddenError,
|
||||
SyntaxError,
|
||||
UserInputError,
|
||||
ValidationError,
|
||||
} from 'apollo-server-express'
|
||||
|
||||
export const formatError = (error) => {
|
||||
// This can be used to send errors to third
|
||||
// party services like Sentry or Stackdriver
|
||||
logger.info('formatError')
|
||||
logger.error(JSON.parse(JSON.stringify(inspect(error))))
|
||||
const originalError = searchOriginalError(error)
|
||||
logger.error('originalError')
|
||||
logger.error(originalError)
|
||||
const { message, code } = originalError
|
||||
return { message, code}
|
||||
}
|
||||
|
||||
const searchOriginalError = (error) => {
|
||||
if (error.originalError) {
|
||||
logger.error('Original Error')
|
||||
logger.error(error.originalError)
|
||||
return error.originalError
|
||||
}
|
||||
if (error.errors) {
|
||||
logger.error('Errors')
|
||||
logger.error(JSON.parse(JSON.stringify(inspect(error.errors))))
|
||||
return error.errors.map(searchOriginalError)[0]
|
||||
}
|
||||
logger.error('searchOriginalErrors')
|
||||
logger.error(JSON.parse(JSON.stringify(inspect(error))))
|
||||
return error;
|
||||
}
|
||||
|
||||
// Define custom Apollo errors here
|
||||
export class ExternalServiceError extends ApolloError {
|
||||
constructor(message) {
|
||||
super(message, 'EXTERNAL_SERVICE_UNAVAILABLE')
|
||||
|
||||
Object.defineProperty(this, 'name', { value: this.constructor.name })
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"errors": [
|
||||
{
|
||||
"code": 401,
|
||||
"message": "Wait, you're not supposed to be here, go through the gate as everyone else"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
import Corporate from './sendgrid/corporate'
|
||||
import Master from './sendgrid/master'
|
||||
import Teams from './sendgrid/teams'
|
||||
|
||||
export const resolvers = {
|
||||
Mutation: {
|
||||
Corporate_NewsletterSignup: (parent, arg, ctx, info) => Corporate.Corporate_NewsletterSignup(parent, arg, ctx, info),
|
||||
Corporate_NewsletterSignupVerify: (parent, arg, ctx, info) => Corporate.Corporate_NewsletterSignupVerify(parent, arg, ctx, info),
|
||||
Corporate_Contact: (parent, arg, ctx, info) => Corporate.Corporate_Contact(parent, arg, ctx, info),
|
||||
Master_NewsletterSignup: (parent, arg, ctx, info) => Master.Master_NewsletterSignup(parent, arg, ctx, info),
|
||||
Master_NewsletterSignupVerify: (parent, arg, ctx, info) => Master.Master_NewsletterSignupVerify(parent, arg, ctx, info),
|
||||
Master_Feedback: (parent, arg, ctx, info) => Master.Master_Feedback(parent, arg, ctx, info),
|
||||
Teams_SendTeamMemberInvite: (parent, arg, ctx, info) => Teams.Teams_SendTeamMemberInvite(parent, arg, ctx, info),
|
||||
Teams_VerifyTeamMemberInviteToken: (parent, arg, ctx, info) => Teams.Teams_VerifyTeamMemberInviteToken(parent, arg, ctx, info),
|
||||
Teams_SendTeamCreateConfirmation: (parent, arg, ctx, info) => Teams.Teams_SendTeamCreateConfirmation(parent, arg, ctx, info)
|
||||
}
|
||||
}
|
||||
+221
@@ -0,0 +1,221 @@
|
||||
import sgMail from '@sendgrid/mail'
|
||||
import axios from 'axios'
|
||||
import jwt from 'jsonwebtoken'
|
||||
import { ApolloError } from 'apollo-server-express'
|
||||
|
||||
import logger from '../../../../logger'
|
||||
|
||||
const API_KEY = process.env.SG_APIKEY
|
||||
const API_KEY_CAMPAIGN = process.env.SG_APIKEY_CAMPAIGN
|
||||
const CORPORATE_EMAIL = process.env.CORPORATE_EMAIL
|
||||
|
||||
const origin = process.env.SG_CORPORATE_ORIGIN
|
||||
|
||||
export default {
|
||||
async Corporate_NewsletterSignup(parent, { email }, ctx, info) {
|
||||
logger.info('Corporate_NewsletterSignup params email:')
|
||||
logger.info(email)
|
||||
const token = jwt.sign({ email: email }, API_KEY, { expiresIn: '1d' })
|
||||
const params = '/email-verification.shtml?token='
|
||||
|
||||
const data = JSON.stringify({
|
||||
"personalizations": [
|
||||
{
|
||||
"to": [
|
||||
{
|
||||
"email": email
|
||||
}
|
||||
],
|
||||
dynamic_template_data: {
|
||||
"aaverifylink": origin + params + token,
|
||||
"subject": 'VERIFY YOUR INTEREST in the Superalgos project'
|
||||
},
|
||||
"subject": 'VERIFY YOUR INTEREST in the Superalgos project'
|
||||
}
|
||||
],
|
||||
"from": {
|
||||
"email": "feedback@superalgos.org",
|
||||
"name": "Superalgos Project Team"
|
||||
},
|
||||
"template_id": process.env.SG_CORPORATE_SIGNUP_EMAILID
|
||||
})
|
||||
|
||||
const sendVerify = axios({
|
||||
method: 'post',
|
||||
url: 'https://api.sendgrid.com/v3/mail/send',
|
||||
data: data,
|
||||
headers:{
|
||||
'content-type': 'application/json',
|
||||
'authorization': 'Bearer ' + API_KEY
|
||||
}
|
||||
})
|
||||
.then(function (response) {
|
||||
logger.info('Sendgrid sendVerify response:')
|
||||
logger.info(response)
|
||||
if (response.status >= 200 && response.status < 300) {
|
||||
return 'SUCCESS'
|
||||
} else {
|
||||
throw response.data.errors[0].message
|
||||
}
|
||||
})
|
||||
.catch(function (error) {
|
||||
logger.error('Sendgrid sendVerify Error:')
|
||||
logger.error(error)
|
||||
throw new ApolloError(`Sendgrid sendVerify Error: ${error.response.data.errors[0].message}`, 404)
|
||||
})
|
||||
return sendVerify
|
||||
},
|
||||
|
||||
async Corporate_NewsletterSignupVerify(parent, { token }, ctx, info){
|
||||
let verifiedToken
|
||||
try {
|
||||
verifiedToken = jwt.verify(token, API_KEY, {maxAge: '1d'})
|
||||
} catch(err) {
|
||||
logger.error('Sendgrid verifiedToken Error:')
|
||||
logger.error(err)
|
||||
if (err.name === 'TokenExpiredError'){
|
||||
throw new ApolloError('Error: Token Expired. Please resubmit email address.', 400)
|
||||
} else {
|
||||
throw new ApolloError(`Error: ${err.message}`, 400)
|
||||
}
|
||||
}
|
||||
logger.info('Sendgrid verifySignup verifiedToken: ')
|
||||
logger.info(verifiedToken)
|
||||
|
||||
const email = verifiedToken.email
|
||||
|
||||
const subscribe = axios({
|
||||
method: 'post',
|
||||
url: 'https://api.sendgrid.com/v3/contactdb/recipients',
|
||||
data: [{"email": email}],
|
||||
headers:{
|
||||
'content-type': 'application/json',
|
||||
'authorization': 'Bearer ' + API_KEY_CAMPAIGN
|
||||
}
|
||||
})
|
||||
.then(response => {
|
||||
logger.info('Sendgrid verifySignup subscribe: ')
|
||||
logger.info(response)
|
||||
const recipients = response.data.persisted_recipients
|
||||
|
||||
if (recipients.length > 0 ){
|
||||
const addToList = axios({
|
||||
method: 'post',
|
||||
url: 'https://api.sendgrid.com/v3/contactdb/lists/4068018/recipients/' + recipients[0],
|
||||
headers:{
|
||||
'content-type': 'application/json',
|
||||
'authorization': 'Bearer ' + API_KEY_CAMPAIGN
|
||||
}
|
||||
})
|
||||
.then(response => {
|
||||
logger.info('Sendgrid verifySignup addToList: ')
|
||||
logger.info(response)
|
||||
if (response.status >= 200 && response.status < 300) {
|
||||
return 'SUCCESS'
|
||||
} else {
|
||||
throw response.data.errors[0].message
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
logger.error('Sendgrid verifySignUp subscribe Error:')
|
||||
logger.error(error)
|
||||
throw `Email SignUp Error: ${error}`
|
||||
})
|
||||
return addToList
|
||||
} else{
|
||||
return response.data.errors[0].message
|
||||
}
|
||||
})
|
||||
.then(response => {
|
||||
return response
|
||||
})
|
||||
.catch(error => {
|
||||
logger.error('Sendgrid verifySubscribe Error:')
|
||||
logger.error(error)
|
||||
throw new ApolloError(`Sendgrid verifySubscribe Error: ${error.response.data.errors[0].message}`, 404)
|
||||
})
|
||||
return subscribe
|
||||
},
|
||||
|
||||
async Corporate_Contact(parent, { email, name, message, recaptcha }, ctx, info) {
|
||||
logger.info(`Corporate_Contact: ${email} | ${name} | ${message} | ${recaptcha}`)
|
||||
const data = JSON.stringify({
|
||||
"personalizations": [
|
||||
{
|
||||
"to": [
|
||||
{
|
||||
"email": CORPORATE_EMAIL
|
||||
}
|
||||
],
|
||||
dynamic_template_data: {
|
||||
"aacontactname": name,
|
||||
"aacontactemail": email,
|
||||
"aacontactbody": message,
|
||||
"subject": `Superalgos Project Site Contact - Message from ${name}`
|
||||
},
|
||||
"subject": `Superalgos Project Site Contact - Message from ${name}`
|
||||
}
|
||||
],
|
||||
"from": {
|
||||
"email": "feedback@superalgos.org",
|
||||
"name": "Superalgos Project Team"
|
||||
},
|
||||
"reply_to": {
|
||||
"email": email,
|
||||
"name": name
|
||||
},
|
||||
"template_id": process.env.SG_CORPORATE_CONTACT_EMAILID
|
||||
})
|
||||
|
||||
const checkCaptcha = axios({
|
||||
method: 'post',
|
||||
url: 'https://www.google.com/recaptcha/api/siteverify',
|
||||
params: {
|
||||
secret: process.env.RECAPTCHA,
|
||||
response: recaptcha
|
||||
}
|
||||
})
|
||||
.then(function (response) {
|
||||
// logger.info(response)
|
||||
if (response.status >= 200 && response.status < 300 && response.data.success) {
|
||||
return axios({
|
||||
method: 'post',
|
||||
url: 'https://api.sendgrid.com/v3/mail/send',
|
||||
data: data,
|
||||
headers:{
|
||||
'content-type': 'application/json',
|
||||
'authorization': 'Bearer ' + API_KEY
|
||||
}
|
||||
})
|
||||
.then(function (response) {
|
||||
// logger.info('Sendgrid Contact response: ')
|
||||
// logger.info(response)
|
||||
if (response.status >= 200 && response.status < 300) {
|
||||
logger.info('Sendgrid Contact email sent')
|
||||
return `Superalgos Project Contact email sent`
|
||||
} else {
|
||||
throw response.data.errors[0].message
|
||||
}
|
||||
})
|
||||
.catch(function (error) {
|
||||
logger.error(`sendgrid Error: ${JSON.stringify(error)}`)
|
||||
throw `Superalgos Project Contact email send error: ${error.response.data.errors[0].message}`
|
||||
})
|
||||
}else{
|
||||
logger.info('Superalgos Project Contact recaptcha error')
|
||||
logger.info(response.data)
|
||||
throw { response: { data: JSON.stringify(response.data) } }
|
||||
}
|
||||
})
|
||||
.then(function(response){
|
||||
return response
|
||||
})
|
||||
.catch(function (error) {
|
||||
logger.error('Sendgrid Superalgos Project Contact RECAPTCHA Error:')
|
||||
logger.error(error)
|
||||
throw new ApolloError(`Sendgrid Superalgos Project Contact RECAPTCHA Error: ${error.response.data}`, 404)
|
||||
})
|
||||
|
||||
return checkCaptcha
|
||||
}
|
||||
}
|
||||
+219
@@ -0,0 +1,219 @@
|
||||
import sgMail from '@sendgrid/mail'
|
||||
import axios from 'axios'
|
||||
import jwt from 'jsonwebtoken'
|
||||
import { ApolloError } from 'apollo-server-express'
|
||||
|
||||
import logger from '../../../../logger'
|
||||
|
||||
const API_KEY = process.env.SG_APIKEY
|
||||
const API_KEY_CAMPAIGN = process.env.SG_APIKEY_CAMPAIGN
|
||||
|
||||
const origin = process.env.SG_PLATFORM_ORIGIN
|
||||
|
||||
export default {
|
||||
async Master_NewsletterSignup(parent, { email }, ctx, info) {
|
||||
logger.info('Master_NewsletterSignup params email:')
|
||||
logger.info(email)
|
||||
const token = jwt.sign({ email: email }, API_KEY, { expiresIn: '1d' })
|
||||
const params = '/email-verification?token='
|
||||
|
||||
const data = JSON.stringify({
|
||||
"personalizations": [
|
||||
{
|
||||
"to": [
|
||||
{
|
||||
"email": email
|
||||
}
|
||||
],
|
||||
dynamic_template_data: {
|
||||
"aaverifylink": origin + params + token,
|
||||
"subject": 'VERIFY YOUR INTEREST in the Superalgos Project'
|
||||
},
|
||||
"subject": 'VERIFY YOUR INTEREST in the Superalgos Project'
|
||||
}
|
||||
],
|
||||
"from": {
|
||||
"email": "feedback@superalgos.org",
|
||||
"name": "Superalgos Project Team"
|
||||
},
|
||||
"reply_to": {
|
||||
"email": "feedback@superalgos.org",
|
||||
"name": "Superalgos Project Team"
|
||||
},
|
||||
"template_id": process.env.SG_MASTER_SIGNUP_EMAILID
|
||||
})
|
||||
|
||||
const sendVerify = axios({
|
||||
method: 'post',
|
||||
url: 'https://api.sendgrid.com/v3/mail/send',
|
||||
data: data,
|
||||
headers:{
|
||||
'content-type': 'application/json',
|
||||
'authorization': 'Bearer ' + API_KEY
|
||||
}
|
||||
})
|
||||
.then(function (response) {
|
||||
logger.info('Sendgrid Master SendVerify response:')
|
||||
logger.info (response)
|
||||
if (response.status >= 200 && response.status < 300) {
|
||||
return 'SUCCESS'
|
||||
} else {
|
||||
throw response.data.errors[0].message
|
||||
}
|
||||
})
|
||||
.catch(function (error) {
|
||||
logger.error('Sendgrid Master SendVerify Error:')
|
||||
logger.error(error)
|
||||
throw new ApolloError(`Sendgrid Master SendVerify Error: ${error.response.data.errors[0].message}`, 404)
|
||||
})
|
||||
return sendVerify
|
||||
},
|
||||
async Master_NewsletterSignupVerify(parent, { token }, ctx, info){
|
||||
let verifiedToken
|
||||
try {
|
||||
verifiedToken = jwt.verify(token, API_KEY, {maxAge: '1d'})
|
||||
} catch(err) {
|
||||
logger.error('Sendgrid Master verifiedToken Error:')
|
||||
logger.error(err)
|
||||
if (err.name === 'TokenExpiredError'){
|
||||
throw new ApolloError('Error: Token Expired. Please resubmit email address.', 400)
|
||||
} else {
|
||||
throw new ApolloError(`Error: ${err.message}`, 400)
|
||||
}
|
||||
}
|
||||
logger.info('Sendgrid Master verifySignup verifiedToken: ')
|
||||
logger.info(verifiedToken)
|
||||
|
||||
const email = verifiedToken.email
|
||||
|
||||
const subscribe = axios({
|
||||
method: 'post',
|
||||
url: 'https://api.sendgrid.com/v3/contactdb/recipients',
|
||||
data: [{"email": email}],
|
||||
headers:{
|
||||
'content-type': 'application/json',
|
||||
'authorization': 'Bearer ' + API_KEY_CAMPAIGN
|
||||
}
|
||||
})
|
||||
.then(response => {
|
||||
logger.info('Sendgrid Master verifySignup subscribe: ')
|
||||
logger.info(response)
|
||||
const recipients = response.data.persisted_recipients
|
||||
|
||||
if (recipients.length > 0 ){
|
||||
const addToList = axios({
|
||||
method: 'post',
|
||||
url: 'https://api.sendgrid.com/v3/contactdb/lists/4068018/recipients/' + recipients[0],
|
||||
headers:{
|
||||
'content-type': 'application/json',
|
||||
'authorization': 'Bearer ' + API_KEY_CAMPAIGN
|
||||
}
|
||||
})
|
||||
.then(response => {
|
||||
logger.info('Sendgrid Master verifySignup addToList: ')
|
||||
logger.info(response)
|
||||
if (response.status >= 200 && response.status < 300) {
|
||||
return 'SUCCESS'
|
||||
} else {
|
||||
throw response.data.errors[0].message
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
logger.error('Sendgrid Master verifySignUp subscribe Error:')
|
||||
logger.error(error)
|
||||
throw `Email SignUp Error: ${error}`
|
||||
})
|
||||
return addToList
|
||||
} else{
|
||||
return response.data.errors[0].message
|
||||
}
|
||||
})
|
||||
.then(response => {
|
||||
return response
|
||||
})
|
||||
.catch(error => {
|
||||
logger.error('Sendgrid Master verifySubscribe Error:')
|
||||
logger.error(error)
|
||||
throw new ApolloError(`Sendgrid Master verifySubscribe Error: ${error.response.data.errors[0].message}`, 404)
|
||||
})
|
||||
return subscribe
|
||||
},
|
||||
async Master_Feedback(parent, { email, subject, message, recaptcha }, ctx, info) {
|
||||
const toEmail = 'feedback@superalgos.org'
|
||||
|
||||
const data = JSON.stringify({
|
||||
"personalizations": [
|
||||
{
|
||||
"to": [
|
||||
{
|
||||
"email": toEmail
|
||||
}
|
||||
],
|
||||
dynamic_template_data: {
|
||||
"aacontactname": name,
|
||||
"aacontactemail": email,
|
||||
"aacontactbody": message
|
||||
},
|
||||
"subject": `Superalgos Platform App Feedback - Message from ${name}`
|
||||
}
|
||||
],
|
||||
"from": {
|
||||
"email": email,
|
||||
"name": name
|
||||
},
|
||||
"reply_to": {
|
||||
"email": email,
|
||||
"name": name
|
||||
},
|
||||
"template_id": process.env.SG_MASTER_FEEDBACK_EMAILID
|
||||
})
|
||||
|
||||
const checkCaptcha = axios({
|
||||
method: 'post',
|
||||
url: 'https://www.google.com/recaptcha/api/siteverify',
|
||||
params: {
|
||||
secret: process.env.RECAPTCHA,
|
||||
response: recaptcha
|
||||
}
|
||||
})
|
||||
.then(function (response) {
|
||||
logger.info(response.data)
|
||||
if (response.status >= 200 && response.status < 300 && response.data.success) {
|
||||
return axios({
|
||||
method: 'post',
|
||||
url: 'https://api.sendgrid.com/v3/mail/send',
|
||||
data: data,
|
||||
headers:{
|
||||
'content-type': 'application/json',
|
||||
'authorization': 'Bearer ' + API_KEY
|
||||
}
|
||||
})
|
||||
.then(function (response) {
|
||||
logger.info('Platform Feedback response: ')
|
||||
logger.info(response)
|
||||
if (response.status >= 200 && response.status < 300) {
|
||||
return `Platform Feedback email sent`
|
||||
} else {
|
||||
throw response.data.errors[0].message
|
||||
}
|
||||
})
|
||||
.catch(function (error) {
|
||||
logger.error(`sendgrid Error: ${JSON.stringify(error)}`)
|
||||
throw `Platform Feedback email send error: ${error.response.data.errors[0].message}`
|
||||
})
|
||||
}else{
|
||||
throw response.data
|
||||
}
|
||||
})
|
||||
.then(function(response){
|
||||
return response
|
||||
})
|
||||
.catch(function (error) {
|
||||
logger.error('Platform Feedback RECAPTCHA Error:')
|
||||
logger.error(error)
|
||||
throw new ApolloError(`Platform Feedback RECAPTCHA Error: ${error.response.data.errors[0].message}`, 404)
|
||||
})
|
||||
|
||||
return checkCaptcha
|
||||
}
|
||||
}
|
||||
+134
@@ -0,0 +1,134 @@
|
||||
import sgMail from '@sendgrid/mail'
|
||||
import axios from 'axios'
|
||||
import jwt from 'jsonwebtoken'
|
||||
import { ApolloError } from 'apollo-server-express'
|
||||
|
||||
import logger from '../../../../logger'
|
||||
|
||||
const API_KEY = process.env.SG_APIKEY
|
||||
const API_KEY_CAMPAIGN = process.env.SG_APIKEY_CAMPAIGN
|
||||
|
||||
const origin = process.env.SG_PLATFORM_ORIGIN
|
||||
|
||||
export default {
|
||||
async Teams_SendTeamMemberInvite(parent, { email, teamName }, ctx, info) {
|
||||
logger.info('Teams_NewsletterSignup params email:')
|
||||
logger.info(email)
|
||||
const token = jwt.sign({ email: email }, API_KEY, { expiresIn: '1d' })
|
||||
const params = '/email-verification?token='
|
||||
|
||||
const data = JSON.stringify({
|
||||
"personalizations": [
|
||||
{
|
||||
"to": [
|
||||
{
|
||||
"email": email
|
||||
}
|
||||
],
|
||||
dynamic_template_data: {
|
||||
"aateaminvitelink": origin + params + token,
|
||||
"aateamname": teamName,
|
||||
"subject": "INVITATION: Join team " + teamName
|
||||
},
|
||||
"subject": "INVITATION: Join team " + teamName
|
||||
}
|
||||
],
|
||||
"from": {
|
||||
"email": "noreply@superalgos.org",
|
||||
"name": "Superalgos Project Teams"
|
||||
},
|
||||
"reply_to": {
|
||||
"email": "feedback@superalgos.org",
|
||||
"name": "Superalgos Project Teams"
|
||||
},
|
||||
"template_id": process.env.SG_TEAMS_MEMBER_INVITE_EMAILID
|
||||
})
|
||||
|
||||
let sendVerify = axios({
|
||||
method: 'post',
|
||||
url: 'https://api.sendgrid.com/v3/mail/send',
|
||||
data: data,
|
||||
headers:{
|
||||
'content-type': 'application/json',
|
||||
'authorization': 'Bearer ' + API_KEY
|
||||
}
|
||||
})
|
||||
.then(function (response) {
|
||||
if (response.status >= 200 && response.status < 300) {
|
||||
return 'Success'
|
||||
} else {
|
||||
throw response.data.errors[0].message
|
||||
}
|
||||
})
|
||||
.catch(function (error) {
|
||||
throw new ApolloError (`Send Team Invite Verification Error: - ${error.status}-${error.response.data.errors[0].message}`, 404)
|
||||
})
|
||||
return sendVerify
|
||||
},
|
||||
|
||||
async Teams_VerifyTeamMemberInviteToken(parent, { email, teamName }, ctx, info) {
|
||||
let verifiedToken
|
||||
try {
|
||||
verifiedToken = await jwt.verify(token, API_KEY, {maxAge: '7d'})
|
||||
} catch(err) {
|
||||
if (err.name === "TokenExpiredError"){
|
||||
throw new ApolloError('Team Invite Token Error: Token Expired. Please request new invitation or apply to the team again', 404)
|
||||
} else {
|
||||
throw new ApolloError (`Team Invite Token Error: - ${err.message}`, 404)
|
||||
}
|
||||
}
|
||||
logger.info(`verifyInviteToken: ${verifiedToken}`)
|
||||
return verifiedToken
|
||||
},
|
||||
|
||||
async Teams_SendTeamCreateConfirmation(parent, { email, teamName, botName }, ctx, info){
|
||||
const data = JSON.stringify({
|
||||
"personalizations": [
|
||||
{
|
||||
"to": [
|
||||
{
|
||||
"email": email
|
||||
}
|
||||
],
|
||||
dynamic_template_data: {
|
||||
"aadeveloplink": "https://platform.superalgos.org/index.html",
|
||||
"aateamname": teamName,
|
||||
"aabotname": botName,
|
||||
"subject": "Team " + teamName + " has been created!"
|
||||
},
|
||||
"subject": "Team " + teamName + " has been created!"
|
||||
}
|
||||
],
|
||||
"from": {
|
||||
"email": "noreply@superalgos.org",
|
||||
"name": "Superalgos Project Teams"
|
||||
},
|
||||
"reply_to": {
|
||||
"email": "feedback@superalgos.org",
|
||||
"name": "Superalgos Project Teams"
|
||||
},
|
||||
"template_id": process.env.SG_TEAMS_TEAMCREATE_EMAILID
|
||||
})
|
||||
|
||||
let sendTeamCreation = axios({
|
||||
method: 'post',
|
||||
url: 'https://api.sendgrid.com/v3/mail/send',
|
||||
data: data,
|
||||
headers:{
|
||||
'content-type': 'application/json',
|
||||
'authorization': 'Bearer ' + API_KEY
|
||||
}
|
||||
})
|
||||
.then(function (response) {
|
||||
if (response.status >= 200 && response.status < 300) {
|
||||
return 'Success'
|
||||
} else {
|
||||
throw response.data.errors[0].message
|
||||
}
|
||||
})
|
||||
.catch(function (error) {
|
||||
throw new ApolloError(`Team Creation Confirmation Error: ${error.response.data.errors[0].message}`)
|
||||
})
|
||||
return sendTeamCreation
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
import logger from '../../../logger'
|
||||
|
||||
export const resolvers = {
|
||||
Query: {
|
||||
_blank: (parent, arg, ctx, info) => { return '' }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
import merge from 'lodash.merge'
|
||||
|
||||
import { resolvers as queryResolvers } from './Query'
|
||||
import { resolvers as mutationResolvers } from './Mutation'
|
||||
|
||||
export const resolvers = merge(queryResolvers, mutationResolvers)
|
||||
@@ -0,0 +1,15 @@
|
||||
type Query {
|
||||
_blank: String
|
||||
}
|
||||
|
||||
type Mutation {
|
||||
Corporate_NewsletterSignup(email: String!): String
|
||||
Corporate_NewsletterSignupVerify(token: String!): String
|
||||
Corporate_Contact(email: String!, name: String, message: String!, recaptcha: String!): String
|
||||
Master_NewsletterSignup(email: String!): String
|
||||
Master_NewsletterSignupVerify(token: String!): String
|
||||
Master_Feedback(email: String!, subject: String!, message: String!, recaptcha: String!): String
|
||||
Teams_SendTeamMemberInvite(email: String!, teamName: String!): String
|
||||
Teams_SendTeamCreateConfirmation(email: String!, teamName: String!, botName: String!): String
|
||||
Teams_VerifyTeamMemberInviteToken(token: String!): String
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
import '@babel/polyfill'
|
||||
require('dotenv').config();
|
||||
import express from 'express'
|
||||
import createApolloServer from './ApolloServer'
|
||||
import { formatError } from './errors'
|
||||
import { makeExecutableSchema } from 'graphql-tools'
|
||||
import { importSchema } from 'graphql-import'
|
||||
|
||||
import { resolvers } from './graphql/resolvers'
|
||||
|
||||
import logger from './logger'
|
||||
|
||||
import wrongPreshared from './errors/notAllowed.json'
|
||||
|
||||
const GRAPHQL_ENDPOINT = '/graphql'
|
||||
const GRAPHQL_SUBSCRIPTIONS = '/graphql'
|
||||
const PORT = process.env.PORT
|
||||
const NODE_ENV = 'development'
|
||||
|
||||
const app = express()
|
||||
|
||||
app.post(GRAPHQL_ENDPOINT, (req, res, next) => {
|
||||
if (req.headers.preshared === process.env.PRESHARED_GATEWAY_KEY) {
|
||||
next();
|
||||
} else {
|
||||
res.send(wrongPreshared);
|
||||
}
|
||||
});
|
||||
|
||||
app.post(GRAPHQL_ENDPOINT)
|
||||
|
||||
const corsOptions = {
|
||||
"origin": "*",
|
||||
"methods": "GET,HEAD,PUT,PATCH,POST,DELETE",
|
||||
"preflightContinue": false,
|
||||
"optionsSuccessStatus": 204
|
||||
}
|
||||
|
||||
const options = {
|
||||
port: PORT,
|
||||
cors: corsOptions,
|
||||
endpoint: '/graphql',
|
||||
subscriptions: '/graphql'
|
||||
}
|
||||
|
||||
let server
|
||||
try {
|
||||
server = createApolloServer(app, {
|
||||
graphqlEndpoint: GRAPHQL_ENDPOINT,
|
||||
subscriptionsEndpoint: GRAPHQL_SUBSCRIPTIONS,
|
||||
apolloServerOptions: { formatError },
|
||||
typeDefs: importSchema('src/graphql/schema.graphql'),
|
||||
resolvers,
|
||||
resolverValidationOptions: { requireResolversForResolveType: false },
|
||||
context: req => ({
|
||||
...req ,
|
||||
token: req.headers ? req.headers : undefined,
|
||||
user: req.user ? req.user : undefined,
|
||||
userId: (req.headers && req.headers.userid) ? req.headers.userid : undefined
|
||||
})
|
||||
})
|
||||
} catch (err) {
|
||||
logger.error('Create Apollo Server Error: ')
|
||||
logger.error(err)
|
||||
}
|
||||
|
||||
server.listen({ port: PORT }, () => {
|
||||
logger.info(
|
||||
`🚀 GraphQL Server is running on http://localhost:${PORT}${GRAPHQL_ENDPOINT} in "${NODE_ENV}" mode\n`
|
||||
)
|
||||
})
|
||||
@@ -0,0 +1,41 @@
|
||||
import { createLogger, format, transports } from 'winston'
|
||||
import { inspect } from 'util'
|
||||
|
||||
const { combine, timestamp, simple } = format
|
||||
|
||||
const options = {
|
||||
file: {
|
||||
level: 'info',
|
||||
filename: '../logs/app.log',
|
||||
handleExceptions: true,
|
||||
json: true,
|
||||
maxsize: 5242880, // 5MB
|
||||
maxFiles: 5,
|
||||
colorize: false,
|
||||
timestamp: true
|
||||
},
|
||||
console: {
|
||||
level: 'info',
|
||||
handleExceptions: true,
|
||||
json: false,
|
||||
colorize: true,
|
||||
}
|
||||
}
|
||||
|
||||
const logger = createLogger({
|
||||
level: 'info',
|
||||
format: format.combine(
|
||||
format.colorize(),
|
||||
format.timestamp({ format: 'YY/MM/DD HH:mm' }),
|
||||
format.printf(
|
||||
info => `${info.timestamp} - ${info.level}: ${JSON.parse(JSON.stringify(inspect(info.message)))}`
|
||||
)
|
||||
),
|
||||
transports: [
|
||||
new transports.File(options.file),
|
||||
new transports.Console(options.console)
|
||||
],
|
||||
exitOnError: false // do not exit on handled exceptions
|
||||
})
|
||||
|
||||
export default logger
|
||||
@@ -0,0 +1,3 @@
|
||||
import moduleAuth from './moduleAuth'
|
||||
|
||||
export { moduleAuth }
|
||||
@@ -0,0 +1,13 @@
|
||||
import logger from '../logger'
|
||||
|
||||
export const moduleAuth = async (req, res, next, db) => {
|
||||
if (req.headers.preshared === process.env.PRESHARED_GATEWAY_KEY) {
|
||||
logger.info('Module authenticated')
|
||||
next();
|
||||
} else {
|
||||
logger.error('Module authentication error')
|
||||
res.send(wrongPreshared);
|
||||
}
|
||||
}
|
||||
|
||||
export default moduleAuth
|
||||
@@ -0,0 +1,3 @@
|
||||
import { PubSub } from 'graphql-subscriptions'
|
||||
|
||||
export default new PubSub()
|
||||
Reference in new issue
Block a user