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

First version of backend #19

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

First version of backend #19

wants to merge 3 commits into from

Conversation

fboucquez
Copy link
Contributor

Includes first versions of:

  • nextjs backend
  • configuration
  • bullmq
  • postgres
  • sequalize-typescript
  • logger
  • docker-compose with third-party services
  • file and art entities
  • graphql
  • rest/openapi

rxjs 7.4.0 upgrade/ SDK upgrade
few storage improvements

Fernando added 2 commits December 13, 2021 13:55
@lgtm-com
Copy link

lgtm-com bot commented Dec 21, 2021

This pull request introduces 2 alerts when merging bc1d2d2 into 4d5d126 - view on LGTM.com

new alerts:

  • 2 for Missing await

Comment on lines +86 to +87
- http://localhost:3000 - Garush Backend.
- http://localhost:3001 - Garush Frontend.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aren't these ports used by Symbol nodes? Can't we have a Garush server and a Symbol node on the same machine?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are ports used for the local services while on development. On production, those services would have their own hostname and they will run on port 443 (HTTPS). Garush doesn't run any symbol node, it connects to them like any other app.

README.md Outdated Show resolved Hide resolved
README.md Outdated
Comment on lines 57 to 65
The first time your run the services, you need to create the minio/s3 access key.

Go to the Minio Console's user tab

http://localhost:9001/users (`minioadmin:minioadmin`)

And create a user with access and key `minioadmin1:minioadmin1`. These keys are the backend's default.

Give this user all the permissions. TODO: Automatize the minio/s3 token for local development

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The first time your run the services, you need to create the minio/s3 access key.
Go to the Minio Console's user tab
http://localhost:9001/users (`minioadmin:minioadmin`)
And create a user with access and key `minioadmin1:minioadmin1`. These keys are the backend's default.
Give this user all the permissions. TODO: Automatize the minio/s3 token for local development
The first time you run the services, you need to create the minio/s3 access key:
- Go to the Minio Console's user tab: http://localhost:9001/users (`minioadmin:minioadmin`)
- Create a user with access and key `minioadmin1:minioadmin1`. These keys are the backend's default.
- Give this user all the permissions. TODO: Automatize the minio/s3 token for local development

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

README.md Outdated
- http://localhost:3000/art
- http://localhost:3000/file

The bullmq job would be populating the database and s3 bucket from the symbol and garush networks.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The bullmq job would be populating the database and s3 bucket from the symbol and garush networks.
The `bullmq` job will be populating the database and s3 bucket from the Symbol and Garush networks.

Copy link
Contributor

@yilmazbahadir yilmazbahadir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good work mate! Added a couple of small comments.

packages/backend/src/modules/art/art.service.ts Outdated Show resolved Hide resolved
@Processor('garush')
export class ArtJobService {
constructor(@InjectQueue('garush') private queue: Queue, @Inject(ArtService) private readonly artService: ArtService) {
queue.add('refresh_art', {}, { repeat: { every: 60000 } });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be better to extract this to the configuration

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Basic extraction is done. We may want to extend the configuration so we can find grain the jobs, like every vs cron configuration, or add some custom job-specific param.

});

if (isObservable(artSubscriber)) {
// I have hacked this with "rxjs": "file:../storage/node_modules/rxjs",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this compatibility issue still stands if it's the same rxjs version? It used to be a peer dependency in nestjs previously but not now I guess.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

storage -> rxjs 7.4.0 in their own node_modules
backend -> rxjs 7.4.0 in their own node_modules.

Both rxjs folders are different. When the backed tries to use an Observable created on storage, the rxjs on the backend raises an error thinking it's not observable. Basically this check fails

https://github.com/ReactiveX/rxjs/blob/master/src/internal/observable/innerFrom.ts#L16
raising
https://github.com/ReactiveX/rxjs/blob/master/src/internal/util/throwUnobservableError.ts#L8

This is not a version issue as everything is 7.4.0, but the instances are different. I think we should find a way that shared third part modules should be installed in a shared folder, I believe learn could fix that. Having said that, this seems to be a common problem, there should be npm solution for it.

@@ -0,0 +1,11 @@
export enum Network {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You must have picked the name Network so that it doesn't clash with SDK/NetworkType, I guess. But it is not too clear that it's an enum by looking at the references. Should we find a different name like NFTNetworkType or a better one?

Copy link
Contributor Author

@fboucquez fboucquez Dec 22, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Network is the identifier of a given network in the env, not its type. The garush solution uses 2 networks, the garush network (pre-sell) and the symbol network (after sold and resells). In my mind:

Dev env:
Garush = garush.dev -> testnet network type
Symbol = joeynet -> testnet network type

Prod env
Garush = a new garush network? -> testnet/mainnet? network type
Symbol = mainnet -> mainnet network type

You can notice that both dev networks use the same network type (with T prefixed addresses), Network is not the same as network type.

We would have 2 running garush, a test env, and a prod env.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea I can see Network and the SDK/NetworkType are not the same, what I meant was the name Network implies (to me) an object rather than an enum/identifier that's why I asked.

Copy link
Contributor Author

@fboucquez fboucquez Dec 23, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any recommendation? should we go with NFTNetworkType?

@lgtm-com
Copy link

lgtm-com bot commented Dec 22, 2021

This pull request introduces 1 alert when merging 06684a7 into 4d5d126 - view on LGTM.com

new alerts:

  • 1 for Missing await

Fix art refresh job. Some improvements
Fixed unique index
Improved logging
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants