-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #164 from alkem-io/develop
Release: Notifications-lib package
- Loading branch information
Showing
190 changed files
with
36,874 additions
and
31,765 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,112 +1,10 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
lerna-debug.log* | ||
|
||
# jetbrains IDEs | ||
.idea | ||
# vscode | ||
#.vscode | ||
|
||
# Diagnostic reports (https://nodejs.org/api/report.html) | ||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
*.pid.lock | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
*.lcov | ||
|
||
# nyc test coverage | ||
.nyc_output | ||
|
||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# Bower dependency directory (https://bower.io/) | ||
bower_components | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
||
# Compiled binary addons (https://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directories | ||
node_modules/ | ||
jspm_packages/ | ||
|
||
# TypeScript v1 declaration files | ||
typings/ | ||
|
||
# TypeScript cache | ||
*.tsbuildinfo | ||
|
||
# Optional npm cache directory | ||
.npm | ||
/docs/diagrams/.$* | ||
/service/coverage/* | ||
/service/coverage-ci/* | ||
|
||
# Optional eslint cache | ||
.eslintcache | ||
|
||
# Microbundle cache | ||
.rpt2_cache/ | ||
.rts2_cache_cjs/ | ||
.rts2_cache_es/ | ||
.rts2_cache_umd/ | ||
|
||
# Optional REPL history | ||
.node_repl_history | ||
|
||
# Output of 'npm pack' | ||
*.tgz | ||
|
||
# Yarn Integrity file | ||
.yarn-integrity | ||
|
||
# dotenv environment variables file | ||
*.log | ||
.env | ||
.env.test | ||
|
||
# parcel-bundler cache (https://parceljs.org/) | ||
.cache | ||
|
||
# Next.js build output | ||
.next | ||
.~* | ||
|
||
# Nuxt.js build / generate output | ||
.nuxt | ||
dist | ||
|
||
# Gatsby files | ||
.cache/ | ||
# Comment in the public line in if your project uses Gatsby and *not* Next.js | ||
# https://nextjs.org/blog/next-9-1#public-directory-support | ||
# public | ||
|
||
# vuepress build output | ||
.vuepress/dist | ||
|
||
# Serverless directories | ||
.serverless/ | ||
|
||
# FuseBox cache | ||
.fusebox/ | ||
|
||
# DynamoDB Local files | ||
.dynamodb/ | ||
|
||
# TernJS port file | ||
.tern-port | ||
|
||
# coverage | ||
coverage-ci/ | ||
.vscode | ||
.idea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ install: | |
services: | ||
- mysql | ||
before_install: | ||
- cd service | ||
- npm i -g [email protected] | ||
script: | ||
- npm run test:ci:coverage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ ARG ENV_ARG=production | |
# Install app dependencies | ||
# A wildcard is used to ensure both package.json AND package-lock.json are copied | ||
# where available (npm@5+) | ||
COPY package*.json ./ | ||
COPY ./service/package*.json ./ | ||
|
||
RUN npm i -g [email protected] | ||
RUN npm install | ||
|
@@ -23,10 +23,10 @@ RUN chmod +x /wait | |
# RUN npm ci --only=production | ||
|
||
# Bundle app source & config files for TypeORM & TypeScript | ||
COPY ./src ./src | ||
COPY ./tsconfig.json . | ||
COPY ./tsconfig.build.json . | ||
COPY ./notifications.yml . | ||
COPY ./service/src ./src | ||
COPY ./service/tsconfig.json . | ||
COPY ./service/tsconfig.build.json . | ||
COPY ./service/notifications.yml . | ||
|
||
RUN npm run build | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,109 +1,12 @@ | ||
# notifications | ||
|
||
# Notifications | ||
Alkemio out-of-band notifications service. | ||
|
||
[![Build Status](https://app.travis-ci.com/alkem-io/notifications.svg?branch=develop)](https://app.travis-ci.com/alkem-io/notifications.svg?branch=develop) | ||
[![Coverage Status](https://coveralls.io/repos/github/alkem-io/notifications/badge.svg?branch=develop)](https://coveralls.io/github/alkem-io/notifications?branch=develop) | ||
[![BCH compliance](https://bettercodehub.com/edge/badge/alkem-io/notifications?branch=develop)](https://bettercodehub.com/) | ||
[![Deploy to DockerHub](https://github.com/alkem-io/notifications/actions/workflows/build-release-docker-hub.yml/badge.svg)](https://github.com/alkem-io/notifications/actions/workflows/build-release-docker-hub.yml) | ||
|
||
## To test | ||
|
||
1. Start quickstart-services from the server repo with defaults. | ||
2. Start mailslurper: | ||
|
||
``` | ||
npm run start:services | ||
``` | ||
|
||
3. Go to http://localhost:15672/#/queues/%2F/alkemio-notifications. | ||
4. Under publish message, go to `properties` and add a new property with name `content_type` and value `application/json`. | ||
5. Select payload: | ||
|
||
```json | ||
{ | ||
"data": "YOUR_DATA" | ||
} | ||
``` | ||
|
||
6. Click publish. | ||
7. Navigate to http://localhost:5051/mailcount. You will see mailCount > 0 (mailslurper will reset the count on each restart). | ||
8. Navigate to http://localhost:5051/mail. Search for YOUR_DATA. You will find it in the mail message. | ||
|
||
## Templates | ||
|
||
To add a template: | ||
|
||
1. Create a file under src/templates. | ||
2. Copy welcome.js | ||
3. Change the template name | ||
4. Define your channels. You can use [this](https://github.com/notifme/notifme-template/tree/master/example) as an example. | ||
5. In the file you want to use the template, import nunjucks and notifme-template. | ||
6. Render your template | ||
|
||
```typescript | ||
const notification = await render('template_name', payload, 'en-US'); | ||
``` | ||
|
||
7. Send notification | ||
|
||
```typescript | ||
await notifmeSdk.send(notification.channels).then(console.log); | ||
``` | ||
|
||
To test the welcome (sample) template, you can use the following payload in RabbitMQ Management UI | ||
|
||
```json | ||
{ | ||
"pattern": "communityApplicationCreated", | ||
"data": { | ||
"applicantionCreatorID": "f0a47bad-eca5-4942-84ac-4dc9f085b7b8", | ||
"applicantID": "f0a47bad-eca5-4942-84ac-4dc9f085b7b8", | ||
"community": { | ||
"name": "02 Zero Hunger", | ||
"type": "challenge" | ||
}, | ||
"hub": { | ||
"id": "32818605-ef2f-4395-bb49-1dc2835c23de", | ||
"challenge": { | ||
"id": "7b86f954-d8c3-4fac-a652-b922c80e5c20", | ||
"opportunity": { | ||
"id": "636be60f-b64a-4742-8b50-69e608601935" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
``` | ||
|
||
Note: replace applicantionCreatorID, applicantID, and hub + challenge + opportunity IDs with IDs you have in your database. You can run the following gql queries to find them: | ||
|
||
```gql | ||
query { | ||
hubs { | ||
id | ||
displayName | ||
challenges { | ||
id | ||
displayName | ||
nameID | ||
community { | ||
id | ||
displayName | ||
} | ||
opportunities { | ||
displayName | ||
id | ||
} | ||
} | ||
} | ||
} | ||
``` | ||
## | ||
This repository contains two core elements: | ||
* Notifications Service: the docker container that is used to provide the run time service | ||
* Nofications Library: used to provide a shared set of payloads and event types that is then used by both the Notifications Service and clients of the service. | ||
|
||
```gql | ||
query { | ||
me { | ||
id | ||
} | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
|
||
# Display specific | ||
/node_modules | ||
/dist | ||
|
||
*.log | ||
.env | ||
.~* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
src | ||
tsconfig.json | ||
tsconfig.prod.json |
File renamed without changes.
Oops, something went wrong.