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

Base models, authentication and routes. #1

Merged
merged 33 commits into from
Aug 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
97d7f59
add base entities and migrations and authentication helpers
cquinterom096 Aug 15, 2022
e48925c
fix indexes
cquinterom096 Aug 15, 2022
182eb73
remove wrong index in setting
cquinterom096 Aug 15, 2022
3bfae87
add user to auth validator
cquinterom096 Aug 15, 2022
f6f75c1
remuve restriction on templateId
cquinterom096 Aug 15, 2022
ba19593
remove settings from user
cquinterom096 Aug 17, 2022
2a66345
add schema validators, seeds and settings
cquinterom096 Aug 18, 2022
52a7aff
add notification setting base controller
cquinterom096 Aug 22, 2022
77f8e21
revert test env
cquinterom096 Aug 22, 2022
8112d8b
fix migrations, add html template
cquinterom096 Aug 23, 2022
5e03f90
add notification settings controller
cquinterom096 Aug 23, 2022
8d65d7d
add segment
cquinterom096 Aug 24, 2022
64707c5
add notifications controller GET/PUT Logic
cquinterom096 Aug 24, 2022
799d32b
add schema validator to send notification
cquinterom096 Aug 24, 2022
0919c5d
Add deploy stage in ci/cd
mohammadranjbarz Aug 24, 2022
532156d
Change listened port in docker-compose-staging
mohammadranjbarz Aug 24, 2022
94e477a
Refactor some functions
mohammadranjbarz Aug 24, 2022
1c7dcdf
Fix linter errors
mohammadranjbarz Aug 24, 2022
209de62
Fix linter errors
mohammadranjbarz Aug 24, 2022
41c0d47
Merge branch 'feature_base_helpers_and_database' into feature_base_he…
CarlosQ96 Aug 24, 2022
f5c7318
Merge pull request #2 from Giveth/feature_base_helpers_and_database_r…
CarlosQ96 Aug 24, 2022
3ef789b
unify template and type
cquinterom096 Aug 25, 2022
915fd36
add notification controller base logic, update notificationtype seeds
cquinterom096 Aug 27, 2022
56dd9f8
update seed template as its empty
cquinterom096 Aug 27, 2022
03dbf42
Now send notification works
mohammadranjbarz Aug 27, 2022
9ba2c36
Add migration file to create test third party
mohammadranjbarz Aug 27, 2022
bd0d0f2
Get notification works
mohammadranjbarz Aug 27, 2022
0fa9dd7
/notifications/countUnread works now
mohammadranjbarz Aug 27, 2022
9bbe1d4
Merge staging to feature_base_helpers_and_database
mohammadranjbarz Aug 27, 2022
aeeb93f
notifications/read/{id} works
mohammadranjbarz Aug 27, 2022
55e5fab
/notifications/readAll works
mohammadranjbarz Aug 27, 2022
655bea4
Fix running tests
mohammadranjbarz Aug 27, 2022
e55c438
Update .env.example
mohammadranjbarz Aug 27, 2022
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
13 changes: 13 additions & 0 deletions .github/workflows/CI-CD.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,17 @@ jobs:
# Add commit hash to docker image tag @see{@link https://github.com/docker/build-push-action/tree/releases/v1#tag_with_sha}
tag_with_sha: true

deploy:
if: github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/main'|| github.ref == 'refs/heads/staging'
needs: publish
runs-on: ubuntu-latest
steps:
- name: Staging deploy
if: github.ref == 'refs/heads/staging'
uses: garygrossgarten/[email protected]
with:
command: cd notification-center && git checkout staging && git pull && docker-compose -f docker-compose-staging.yml pull && docker-compose -f docker-compose-staging.yml down && docker-compose -f docker-compose-staging.yml up -d && docker image prune -a --force;
host: ${{ secrets.STAGING_HOST }}
username: ${{ secrets.STAGING_USERNAME }}
privateKey: ${{ secrets.STAGING_PRIVATE_KEY}}

8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,14 @@ npm run db:migrate:run:local
npm run db:migrate:revert:local
```

#### Create Third party in DB
As we can't put inserting third parties in migration, I put a query sample here, we can use it in prod

```
INSERT INTO public.third_party(
"microService", secret, "isActive")
VALUES ('givethio', 'givethio_secret', true);
```

## References

Expand Down
11 changes: 6 additions & 5 deletions config/example.env
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ TYPEORM_DATABASE_PORT=5443

# Filled with docker-compose-local-postgres-redis.yml data
REDIS_HOST=127.0.0.1
REDIS_PORT=6489
REDIS_PORT=6490
REDIS_PASSWORD=

GIVETHIO_USERNAME=givethio
GIVETHIO_PASSWORD=givethio_secret
TRACE_USERNAME=trace
TRACE_PASSWORD=trace_secret
SEGMENT_API_KEY=FAKE_API_KEY

#JWT_AUTHORIZATION_ADAPTER=siweMicroservice
JWT_AUTHORIZATION_ADAPTER=mock
AUTH_MICROSERVICE_AUTHORIZATION_URL=
10 changes: 5 additions & 5 deletions config/test.env
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ PORT=3041
TYPEORM_DATABASE_NAME=notification-center
TYPEORM_DATABASE_USER=postgres
TYPEORM_DATABASE_PASSWORD=postgres
TYPEORM_DATABASE_HOST=127.0.0.1
TYPEORM_DATABASE_HOST=localhost
TYPEORM_DATABASE_PORT=5446


REDIS_HOST=127.0.0.1
REDIS_PORT=6490
REDIS_PASSWORD=

GIVETHIO_USERNAME=givethio
GIVETHIO_PASSWORD=givethio_secret
TRACE_USERNAME=trace
TRACE_PASSWORD=trace_secret

SEGMENT_API_KEY=FAKE_API_KEY

JWT_AUTHORIZATION_ADAPTER=mock
2 changes: 1 addition & 1 deletion docker-compose-staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ services:
source: ./logs
target: /usr/src/app/dist/logs
ports:
- "3040:3040"
- "3032:3040"



Expand Down
25 changes: 0 additions & 25 deletions migrations/1658258392704-createNotificationTemplateTable.ts

This file was deleted.

34 changes: 0 additions & 34 deletions migrations/1658258392706-createNotificationTable.ts

This file was deleted.

37 changes: 37 additions & 0 deletions migrations/1660539566228-createUserAddress.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { MigrationInterface, QueryRunner, Table } from 'typeorm';

export class createUserAddress1660539566228 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.createTable(
new Table({
name: 'user_address',
columns: [
{
name: 'id',
type: 'int',
isPrimary: true,
isGenerated: true, // Auto-increment
generationStrategy: 'increment',
},
{
name: 'createdAt',
type: 'timestamp without time zone',
isNullable: false,
default: 'now()',
},
{
name: 'updatedAt',
type: 'timestamp without time zone',
isNullable: false,
default: 'now()',
},
],
}),
true,
);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.dropTable('user_address');
}
}
53 changes: 53 additions & 0 deletions migrations/1660539945623-createThirdParty.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import { MigrationInterface, QueryRunner, Table } from 'typeorm';

export class createThirdParty1660539945623 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.createTable(
new Table({
name: 'third_party',
columns: [
{
name: 'id',
type: 'int',
isPrimary: true,
isGenerated: true, // Auto-increment
generationStrategy: 'increment',
},
{
name: 'microService',
type: 'text',
isNullable: false,
},
{
name: 'secret',
type: 'text',
isNullable: false,
},
{
name: 'isActive',
type: 'boolean',
isNullable: false,
default: true,
},
{
name: 'createdAt',
type: 'timestamp without time zone',
isNullable: false,
default: 'now()',
},
{
name: 'updatedAt',
type: 'timestamp without time zone',
isNullable: false,
default: 'now()',
},
],
}),
true,
);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.dropTable('third_party');
}
}
122 changes: 122 additions & 0 deletions migrations/1660540253547-createNotificationType.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
import { MigrationInterface, QueryRunner, Table, TableIndex } from 'typeorm';

export class createNotificationType1660540253547 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.createTable(
new Table({
name: 'notification_type',
columns: [
{
name: 'id',
type: 'int',
isPrimary: true,
isGenerated: true, // Auto-increment
generationStrategy: 'increment',
},
{
name: 'microService',
type: 'text',
isNullable: false,
},
{
name: 'name',
type: 'text',
isNullable: false,
},
{
name: 'description',
type: 'text',
isNullable: false,
},
{
name: 'schemaValidator',
type: 'text',
isNullable: true,
},
{
name: 'category',
type: 'text',
isNullable: false,
},
{
name: 'emailNotifierService',
type: 'text',
isNullable: true,
},
{
name: 'emailNotificationId',
type: 'text', // events are strings
isNullable: true,
},
{
name: 'pushNotifierService',
type: 'text',
isNullable: true,
},
{
name: 'requiresTemplate',
type: 'boolean',
isNullable: false,
default: true,
},
{
name: 'htmlTemplate',
type: 'jsonb',
isNullable: true,
},
{
name: 'title',
type: 'text',
isNullable: true,
},
{
name: 'content',
type: 'text',
isNullable: true,
},
{
name: 'createdAt',
type: 'timestamp without time zone',
isNullable: false,
default: 'now()',
},
{
name: 'updatedAt',
type: 'timestamp without time zone',
isNullable: false,
default: 'now()',
},
],
}),
true,
);

await queryRunner.createIndex(
'notification_type',
new TableIndex({
name: 'IDX_NOTY_TYPE_NAME',
columnNames: ['name'],
}),
);

await queryRunner.createIndex(
'notification_type',
new TableIndex({
name: 'IDX_NOTY_TYPE_RES',
columnNames: ['category'],
}),
);

await queryRunner.createIndex(
'notification_type',
new TableIndex({
name: 'IDX_NOTY_TYPE_SERVICE',
columnNames: ['microService'],
}),
);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.dropTable('notification_type');
}
}
Loading