Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V2.2.0 release #125

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .eslintignore

This file was deleted.

26 changes: 0 additions & 26 deletions .eslintrc.js

This file was deleted.

16 changes: 10 additions & 6 deletions .github/workflows/main-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: givethio
POSTGRES_DB: notification-center
options: >-
--health-cmd pg_isready
--health-interval 10s
Expand All @@ -43,15 +43,15 @@ jobs:
- name: Use Node.js
uses: actions/setup-node@v1
with:
node-version: 18.14.0
node-version: 20.14.0
- name: Install dependencies
run: npm ci
run: yarn install
- name: Run linter
run: npm run lint
run: yarn lint
- name: Run migrations
run: npm run db:migrate:run:test
run: yarn db:migrate:run:test
- name: Run tests
run: npm run test
run: yarn test

publish:
needs: test
Expand All @@ -60,6 +60,10 @@ jobs:
steps:
- name: Check out the repo
uses: actions/checkout@v2
- name: Install Yarn
run: npm install -g yarn
- name: Install dependencies
run: yarn install
- name: Build image and push to GitHub Packages
uses: docker/build-push-action@v1
with:
Expand Down
21 changes: 15 additions & 6 deletions .github/workflows/staging-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: givethio
POSTGRES_DB: notification-center
options: >-
--health-cmd pg_isready
--health-interval 10s
Expand All @@ -41,15 +41,17 @@ jobs:
- name: Use Node.js
uses: actions/setup-node@v1
with:
node-version: 18.14.0
node-version: 20.14.0
- name: Install Yarn
run: npm install -g yarn
- name: Install dependencies
run: npm ci
run: yarn install
- name: Run linter
run: npm run lint
run: yarn lint
- name: Run migrations
run: npm run db:migrate:run:test
run: yarn db:migrate:run:test
- name: Run tests
run: npm run test
run: yarn test

publish:
needs: test
Expand All @@ -58,6 +60,13 @@ jobs:
steps:
- name: Check out the repo
uses: actions/checkout@v2

- name: Install Yarn
run: npm install -g yarn

- name: Install dependencies
run: yarn install

- name: Build image and push to GitHub Packages
uses: docker/build-push-action@v1
with:
Expand Down
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#https://hub.docker.com/_/node?tab=tags&page=1
FROM node:18.14.0
FROM node:20.14.0

WORKDIR /usr/src/app

Expand All @@ -10,7 +10,7 @@ COPY src ./src
COPY migrations ./migrations
COPY test ./test

RUN npm ci
RUN npm i -g pm2
RUN npm run build #It will run prebuild script for generating swagger spec by tsoa as well
RUN yarn install --frozen-lockfile
RUN yarn build #It will run prebuild script for generating swagger spec by tsoa as well
RUN cp -rv public ./dist
1 change: 1 addition & 0 deletions config/example.env
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ REDIS_PASSWORD=

SEGMENT_API_KEY=FAKE_API_KEY
ORTTO_API_KEY=FAKE_API_KEY
QACC_ORTTO_API_KEY=FAKE_API_KEY
ORTTO_ACTIVITY_API=https://api-us.ortto.app/v1/activities/create

#JWT_AUTHORIZATION_ADAPTER=siweMicroservice
Expand Down
76 changes: 76 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import _import from 'eslint-plugin-import';
import unusedImports from 'eslint-plugin-unused-imports';
import { fixupPluginRules } from '@eslint/compat';
import tsParser from '@typescript-eslint/parser';
import js from '@eslint/js';
import { FlatCompat } from '@eslint/eslintrc';

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all,
});

export default [
{
ignores: ['node_modules/*', 'dist/*'],
},
...compat.extends(
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:prettier/recommended',
),
{
plugins: {
import: fixupPluginRules(_import),
'unused-imports': unusedImports,
},

languageOptions: {
parser: tsParser,
},

rules: {
'@typescript-eslint/no-explicit-any': 'off',
'unused-imports/no-unused-imports': 'error',
'@typescript-eslint/no-unused-vars': [
'error',
{
argsIgnorePattern: '^_',
},
],

'prettier/prettier': [
'error',
{
arrowParens: 'avoid',
singleQuote: true,
semi: true,
tabWidth: 2,
useTabs: false,
trailingComma: 'all',
'jsdoc-format': false,
endOfLine: 'auto',
},
],

'import/order': [
'error',
{
groups: [
'builtin',
'external',
['internal', 'parent', 'sibling'],
'index',
'object',
'type',
],
},
],
},
},
];
6 changes: 3 additions & 3 deletions migrations/1678175596807-changeNotificationCopies.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { MigrationInterface, QueryRunner } from 'typeorm';
import { MigrationInterface } from 'typeorm';
import { getNotificationTypeByEventName } from '../src/repositories/notificationTypeRepository';
import { NOTIFICATION_TYPE_NAMES } from '../src/types/general';

Expand All @@ -24,7 +24,7 @@ export class changeNotificationCopies1678175596807
await notificationType.save();
}

public async up(queryRunner: QueryRunner): Promise<void> {
public async up(): Promise<void> {
if (
process.env.NODE_ENV === 'test' ||
process.env.NODE_ENV === 'development'
Expand Down Expand Up @@ -339,7 +339,7 @@ export class changeNotificationCopies1678175596807
);
}

public async down(queryRunner: QueryRunner): Promise<void> {
public async down(): Promise<void> {
//
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { MigrationInterface, QueryRunner } from 'typeorm';
import { MigrationInterface } from 'typeorm';
import { getNotificationTypeByEventName } from '../src/repositories/notificationTypeRepository';
import { NOTIFICATION_TYPE_NAMES } from '../src/types/general';

Expand All @@ -21,7 +21,7 @@ export class changeCancelProjectNotificationCopies1681206838965
await notificationType.save();
}

public async up(queryRunner: QueryRunner): Promise<void> {
public async up(): Promise<void> {
if (
process.env.NODE_ENV === 'test' ||
process.env.NODE_ENV === 'development'
Expand Down Expand Up @@ -84,7 +84,7 @@ export class changeCancelProjectNotificationCopies1681206838965
);
}

public async down(queryRunner: QueryRunner): Promise<void> {
public async down(): Promise<void> {
//
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@ import {
NotificationType,
SCHEMA_VALIDATORS_NAMES,
} from '../src/entities/notificationType';
import { MICRO_SERVICES, THIRD_PARTY_EMAIL_SERVICES } from '../src/utils/utils';
import { MICRO_SERVICES } from '../src/utils/utils';
import {
NOTIFICATION_CATEGORY,
NOTIFICATION_TYPE_NAMES,
} from '../src/types/general';
import { NOTIFICATION_CATEGORY_GROUPS } from '../src/entities/notificationSetting';
import { SegmentEvents } from '../src/services/segment/segmentAnalyticsSingleton';

// https://github.com/Giveth/notification-center/issues/6 , https://gist.github.com/MohammadPCh/24434d50bc9ccd9b74905c271ee05482
// icons https://gist.github.com/MohammadPCh/31e2b750dd9aa54edb21dcc6e7332efb
Expand Down
6 changes: 3 additions & 3 deletions migrations/1692698983844-changeNotificationCopies.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { MigrationInterface, QueryRunner } from 'typeorm';
import { MigrationInterface } from 'typeorm';
import { getNotificationTypeByEventName } from '../src/repositories/notificationTypeRepository';
import { NOTIFICATION_TYPE_NAMES } from '../src/types/general';

Expand All @@ -21,7 +21,7 @@ export class changeNotificationCopies1692698983844
await notificationType.save();
}

public async up(queryRunner: QueryRunner): Promise<void> {
public async up(): Promise<void> {
if (
process.env.NODE_ENV === 'test' ||
process.env.NODE_ENV === 'development'
Expand Down Expand Up @@ -85,7 +85,7 @@ export class changeNotificationCopies1692698983844
);
}

public async down(queryRunner: QueryRunner): Promise<void> {
public async down(): Promise<void> {
//
}
}
44 changes: 23 additions & 21 deletions migrations/1712683625687-addSuperFluidNotificationForAllUsers.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
import { MigrationInterface, QueryRunner } from "typeorm"
import { MigrationInterface, QueryRunner } from 'typeorm';

export class addSuperFluidNotificationForAllUsers1712683625687 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<void> {
// Fetch the notificationTypeIds for the "superfluid" categoryGroup
const notificationTypeIds = await queryRunner.query(`
export class addSuperFluidNotificationForAllUsers1712683625687
implements MigrationInterface
{
public async up(queryRunner: QueryRunner): Promise<void> {
// Fetch the notificationTypeIds for the "superfluid" categoryGroup
const notificationTypeIds = await queryRunner.query(`
SELECT "id" FROM "notification_type" WHERE "categoryGroup" = 'superfluid';
`);

// Fetch all unique userAddressIds
const userAddressIds = await queryRunner.query(`
// Fetch all unique userAddressIds
const userAddressIds = await queryRunner.query(`
SELECT DISTINCT "userAddressId" FROM "notification_setting";
`);

// For each userAddressId, insert a new row for each notificationTypeId
for (const { userAddressId } of userAddressIds) {
for (const { id: notificationTypeId } of notificationTypeIds) {
await queryRunner.query(`
// For each userAddressId, insert a new row for each notificationTypeId
for (const { userAddressId } of userAddressIds) {
for (const { id: notificationTypeId } of notificationTypeIds) {
await queryRunner.query(`
INSERT INTO "notification_setting" (
"allowNotifications",
"allowEmailNotification",
Expand All @@ -24,22 +26,22 @@ export class addSuperFluidNotificationForAllUsers1712683625687 implements Migrat
"userAddressId"
) VALUES (true, true, true, ${notificationTypeId}, ${userAddressId});
`);
}
}
}
}
}

public async down(queryRunner: QueryRunner): Promise<void> {
// Fetch the notificationTypeIds for the "superfluid" categoryGroup
const notificationTypeIds = await queryRunner.query(`
public async down(queryRunner: QueryRunner): Promise<void> {
// Fetch the notificationTypeIds for the "superfluid" categoryGroup
const notificationTypeIds = await queryRunner.query(`
SELECT "id" FROM "notification_type" WHERE "categoryGroup" = 'superfluid';
`);

// Convert fetched rows to a list of IDs for the IN clause
const ids = notificationTypeIds.map((nt: { id: any; }) => nt.id).join(', ');
// Convert fetched rows to a list of IDs for the IN clause
const ids = notificationTypeIds.map((nt: { id: any }) => nt.id).join(', ');

// Delete the rows with the fetched notificationTypeIds for all userAddressIds
await queryRunner.query(`
// Delete the rows with the fetched notificationTypeIds for all userAddressIds
await queryRunner.query(`
DELETE FROM "notification_setting" WHERE "notificationTypeId" IN (${ids});
`);
}
}
}
Loading
Loading