Skip to content

Commit ac3a62a

Browse files
committed
feat: first commit
0 parents  commit ac3a62a

File tree

690 files changed

+3609567
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

690 files changed

+3609567
-0
lines changed

.eslintrc.js

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
extends: ['next'],
3+
}

.gitignore

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# compiled output
2+
/dist
3+
/node_modules
4+
5+
# Configs
6+
.env
7+
8+
# Logs
9+
logs
10+
*.log
11+
npm-debug.log*
12+
yarn-debug.log*
13+
yarn-error.log*
14+
lerna-debug.log*
15+
16+
# OS
17+
.DS_Store
18+
19+
# Tests
20+
/coverage
21+
/.nyc_output
22+
23+
# IDEs and editors
24+
/.idea
25+
.project
26+
.classpath
27+
.c9/
28+
*.launch
29+
.settings/
30+
*.sublime-workspace
31+
32+
# IDE - VSCode
33+
.vscode/*
34+
!.vscode/settings.json
35+
!.vscode/tasks.json
36+
!.vscode/launch.json
37+
!.vscode/extensions.json

.graphqlrc.yml

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
schema: './generated/schema.graphql'

.prettierrc

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"trailingComma": "all",
3+
"endOfLine": "lf",
4+
"printWidth": 120,
5+
"tabWidth": 2,
6+
"singleQuote": true,
7+
"semi": false,
8+
"overrides": [
9+
{
10+
"files": "*.sol",
11+
"options": {
12+
"tabWidth": 4
13+
}
14+
}
15+
]
16+
}

.vscode/settings.json

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
// Lints with Standard JS
3+
"standard.enable": true,
4+
// Format files with Standard whenever you save the file
5+
"standard.autoFixOnSave": true,
6+
// Files to validate with Standard JS
7+
"standard.validate": [
8+
"javascript",
9+
"javascriptreact",
10+
"typescript",
11+
"typescriptreact"
12+
],
13+
"editor.tabSize": 2,
14+
"typescript.format.insertSpaceBeforeFunctionParenthesis": true,
15+
"typescript.format.placeOpenBraceOnNewLineForControlBlocks": false,
16+
"typescript.format.placeOpenBraceOnNewLineForFunctions": false,
17+
"editor.detectIndentation": false,
18+
"eslint.packageManager": "yarn",
19+
"eslint.codeAction.showDocumentation": {
20+
"enable": true
21+
},
22+
"eslint.format.enable": true,
23+
"editor.formatOnSave": true,
24+
"editor.codeActionsOnSave": {
25+
"source.fixAll": true
26+
}
27+
}

README.md

+75
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
<p align="center">
2+
<a href="http://nestjs.com/" target="blank"><img src="https://nestjs.com/img/logo_text.svg" width="320" alt="Nest Logo" /></a>
3+
</p>
4+
5+
[travis-image]: https://api.travis-ci.org/nestjs/nest.svg?branch=master
6+
[travis-url]: https://travis-ci.org/nestjs/nest
7+
[linux-image]: https://img.shields.io/travis/nestjs/nest/master.svg?label=linux
8+
[linux-url]: https://travis-ci.org/nestjs/nest
9+
10+
<p align="center">A progressive <a href="http://nodejs.org" target="blank">Node.js</a> framework for building efficient and scalable server-side applications, heavily inspired by <a href="https://angular.io" target="blank">Angular</a>.</p>
11+
<p align="center">
12+
<a href="https://www.npmjs.com/~nestjscore"><img src="https://img.shields.io/npm/v/@nestjs/core.svg" alt="NPM Version" /></a>
13+
<a href="https://www.npmjs.com/~nestjscore"><img src="https://img.shields.io/npm/l/@nestjs/core.svg" alt="Package License" /></a>
14+
<a href="https://www.npmjs.com/~nestjscore"><img src="https://img.shields.io/npm/dm/@nestjs/core.svg" alt="NPM Downloads" /></a>
15+
<a href="https://travis-ci.org/nestjs/nest"><img src="https://api.travis-ci.org/nestjs/nest.svg?branch=master" alt="Travis" /></a>
16+
<a href="https://travis-ci.org/nestjs/nest"><img src="https://img.shields.io/travis/nestjs/nest/master.svg?label=linux" alt="Linux" /></a>
17+
<a href="https://coveralls.io/github/nestjs/nest?branch=master"><img src="https://coveralls.io/repos/github/nestjs/nest/badge.svg?branch=master#5" alt="Coverage" /></a>
18+
<a href="https://gitter.im/nestjs/nestjs?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=body_badge"><img src="https://badges.gitter.im/nestjs/nestjs.svg" alt="Gitter" /></a>
19+
<a href="https://opencollective.com/nest#backer"><img src="https://opencollective.com/nest/backers/badge.svg" alt="Backers on Open Collective" /></a>
20+
<a href="https://opencollective.com/nest#sponsor"><img src="https://opencollective.com/nest/sponsors/badge.svg" alt="Sponsors on Open Collective" /></a>
21+
<a href="https://paypal.me/kamilmysliwiec"><img src="https://img.shields.io/badge/Donate-PayPal-dc3d53.svg"/></a>
22+
<a href="https://twitter.com/nestframework"><img src="https://img.shields.io/twitter/follow/nestframework.svg?style=social&label=Follow"></a>
23+
</p>
24+
<!--[![Backers on Open Collective](https://opencollective.com/nest/backers/badge.svg)](https://opencollective.com/nest#backer)
25+
[![Sponsors on Open Collective](https://opencollective.com/nest/sponsors/badge.svg)](https://opencollective.com/nest#sponsor)-->
26+
27+
## Description
28+
29+
[Nest](https://github.com/nestjs/nest) framework TypeScript starter repository.
30+
31+
## Installation
32+
33+
```bash
34+
$ npm install
35+
```
36+
37+
## Running the app
38+
39+
```bash
40+
# development
41+
$ npm run start
42+
43+
# watch mode
44+
$ npm run start:dev
45+
46+
# production mode
47+
$ npm run start:prod
48+
```
49+
50+
## Test
51+
52+
```bash
53+
# unit tests
54+
$ npm run test
55+
56+
# e2e tests
57+
$ npm run test:e2e
58+
59+
# test coverage
60+
$ npm run test:cov
61+
```
62+
63+
## Support
64+
65+
Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please [read more here](https://docs.nestjs.com/support).
66+
67+
## Stay in touch
68+
69+
- Author - [Kamil Myśliwiec](https://kamilmysliwiec.com)
70+
- Website - [https://nestjs.com](https://nestjs.com/)
71+
- Twitter - [@nestframework](https://twitter.com/nestframework)
72+
73+
## License
74+
75+
Nest is [MIT licensed](LICENSE).

apps/api/Dockerfile

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
FROM node:14
2+
3+
# context path: ./backend
4+
COPY . /app/chainjet/backend
5+
WORKDIR /app/chainjet/backend
6+
7+
RUN yarn
8+
RUN yarn build
9+
10+
CMD [ "yarn", "start:prod:api" ]
11+
12+
EXPOSE 8000
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { NestjsQueryTypegooseModule } from '@app/common/NestjsQueryTypegooseModule'
2+
import { NestjsQueryGraphQLModule } from '@nestjs-query/query-graphql'
3+
import { forwardRef, Module } from '@nestjs/common'
4+
import { ConfigModule } from '@nestjs/config'
5+
import { RunnerModule } from '../../../runner/src/runner.module'
6+
import { IntegrationAccountsModule } from '../integration-accounts/integration-accounts.module'
7+
import { IntegrationsModule } from '../integrations/integrations.module'
8+
import { UsersModule } from '../users/users.module'
9+
import { AccountCredential } from './entities/account-credential'
10+
import { AccountCredentialAuthorizer, AccountCredentialResolver } from './resolvers/account-credentials.resolver'
11+
import { AccountCredentialService } from './services/account-credentials.service'
12+
13+
@Module({
14+
imports: [
15+
ConfigModule.forRoot(),
16+
NestjsQueryGraphQLModule.forFeature({
17+
imports: [NestjsQueryTypegooseModule.forFeature([AccountCredential])],
18+
resolvers: []
19+
}),
20+
UsersModule, // required for GraphqlGuard
21+
IntegrationsModule,
22+
IntegrationAccountsModule,
23+
forwardRef(() => RunnerModule)
24+
],
25+
providers: [AccountCredentialResolver, AccountCredentialService, AccountCredentialAuthorizer],
26+
exports: [AccountCredentialService]
27+
})
28+
export class AccountCredentialsModule {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { AccountCredential } from './account-credential'
2+
3+
describe('AccountCredential', () => {
4+
it('should be defined', () => {
5+
expect(new AccountCredential()).toBeDefined()
6+
})
7+
})
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
import { BaseEntity } from '@app/common/base/base-entity'
2+
import { EntityRef } from '@app/common/decorators/entity-ref.decorator'
3+
import { OwnedEntity } from '@app/common/decorators/owned-entity.decorator'
4+
import { jsonProp } from '@app/common/decorators/props/json-prop.decorator'
5+
import { Reference } from '@app/common/typings/mongodb'
6+
import { FilterableField } from '@nestjs-query/query-graphql'
7+
import { Field, ID, InputType, ObjectType } from '@nestjs/graphql'
8+
import { prop, Ref } from '@typegoose/typegoose'
9+
import { GraphQLJSONObject } from 'graphql-type-json'
10+
import { JSONSchema7 } from 'json-schema'
11+
import { IntegrationAccount } from '../../integration-accounts/entities/integration-account'
12+
import { User } from '../../users/entities/user'
13+
14+
@ObjectType()
15+
@OwnedEntity()
16+
@EntityRef('owner', () => User)
17+
@EntityRef('integrationAccount', () => IntegrationAccount)
18+
export class AccountCredential extends BaseEntity {
19+
@FilterableField(() => ID)
20+
@prop({ ref: User, required: true, index: true })
21+
readonly owner!: Reference<User>
22+
23+
@FilterableField(() => ID)
24+
@prop({ ref: IntegrationAccount, required: true, index: true })
25+
readonly integrationAccount!: Reference<IntegrationAccount>
26+
27+
@Field()
28+
@prop({ required: true })
29+
name: string
30+
31+
// Placeholder for credential pairs input
32+
credentials: Record<string, string>
33+
34+
@prop()
35+
encryptedCredentials: string
36+
37+
@Field(() => GraphQLJSONObject, { nullable: true })
38+
@jsonProp()
39+
fields: Record<string, string>
40+
41+
/**
42+
* Stores references for operations with dynamic schemas.
43+
*/
44+
@Field(() => GraphQLJSONObject, { nullable: true })
45+
@jsonProp()
46+
schemaRefs?: Record<string, JSONSchema7>
47+
}
48+
49+
@InputType()
50+
export class CreateAccountCredentialInput {
51+
@Field(() => ID)
52+
integrationAccount: Ref<IntegrationAccount>
53+
54+
@Field()
55+
name: string
56+
57+
@Field(() => GraphQLJSONObject, { nullable: true })
58+
credentials: Record<string, string>
59+
60+
@Field(() => GraphQLJSONObject, { nullable: true })
61+
fields: Record<string, string>
62+
}
63+
64+
@InputType()
65+
export class UpdateAccountCredentialInput {
66+
@Field({ nullable: true })
67+
name: string
68+
69+
@Field(() => GraphQLJSONObject, { nullable: true })
70+
credentials: Record<string, string>
71+
72+
@Field(() => GraphQLJSONObject, { nullable: true })
73+
fields: Record<string, string>
74+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { Test, TestingModule } from '@nestjs/testing'
2+
import { TypegooseModule } from 'nestjs-typegoose'
3+
import { closeMongoConnection } from '../../../../../libs/common/test/database/test-database.module'
4+
import { MockModule } from '../../../../../libs/common/test/mock.module'
5+
import { MockService } from '../../../../../libs/common/test/mock.service'
6+
import { AccountCredential } from '../entities/account-credential'
7+
import { AccountCredentialService } from '../services/account-credentials.service'
8+
import { AccountCredentialAuthorizer, AccountCredentialResolver } from './account-credentials.resolver'
9+
10+
describe('AccountCredentialResolver', () => {
11+
let resolver: AccountCredentialResolver
12+
let mock: MockService
13+
14+
beforeEach(async () => {
15+
const module: TestingModule = await Test.createTestingModule({
16+
imports: [
17+
TypegooseModule.forFeature([AccountCredential]),
18+
MockModule
19+
],
20+
providers: [AccountCredentialResolver, AccountCredentialService, AccountCredentialAuthorizer]
21+
}).compile()
22+
23+
resolver = module.get<AccountCredentialResolver>(AccountCredentialResolver)
24+
mock = module.get<MockService>(MockService)
25+
})
26+
27+
afterEach(async () => await mock.dropDatabase())
28+
afterAll(async () => await closeMongoConnection())
29+
30+
it('should be defined', () => {
31+
expect(resolver).toBeDefined()
32+
})
33+
})
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { BaseResolver } from '@app/common/base/base.resolver'
2+
import { OwnedAuthorizer } from '@app/common/base/owned.authorizer'
3+
import { Authorizer, InjectAuthorizer } from '@nestjs-query/query-graphql'
4+
import { Injectable, UseGuards } from '@nestjs/common'
5+
import { Resolver } from '@nestjs/graphql'
6+
import { GraphqlGuard } from '../../auth/guards/graphql.guard'
7+
import {
8+
AccountCredential,
9+
CreateAccountCredentialInput,
10+
UpdateAccountCredentialInput
11+
} from '../entities/account-credential'
12+
import { AccountCredentialService } from '../services/account-credentials.service'
13+
14+
@Injectable()
15+
export class AccountCredentialAuthorizer extends OwnedAuthorizer<AccountCredential> {}
16+
17+
@Resolver(() => AccountCredential)
18+
@UseGuards(GraphqlGuard)
19+
export class AccountCredentialResolver extends BaseResolver(AccountCredential, {
20+
CreateDTOClass: CreateAccountCredentialInput,
21+
UpdateDTOClass: UpdateAccountCredentialInput,
22+
guards: [GraphqlGuard]
23+
}) {
24+
constructor (
25+
protected accountCredentialService: AccountCredentialService,
26+
@InjectAuthorizer(AccountCredential) readonly authorizer: Authorizer<AccountCredential>
27+
) {
28+
super(accountCredentialService)
29+
}
30+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { Test, TestingModule } from '@nestjs/testing'
2+
import { TypegooseModule } from 'nestjs-typegoose'
3+
import { closeMongoConnection } from '../../../../../libs/common/test/database/test-database.module'
4+
import { MockModule } from '../../../../../libs/common/test/mock.module'
5+
import { MockService } from '../../../../../libs/common/test/mock.service'
6+
import { AccountCredential } from '../entities/account-credential'
7+
import { AccountCredentialService } from './account-credentials.service'
8+
9+
describe('AccountCredentialService', () => {
10+
let service: AccountCredentialService
11+
let mock: MockService
12+
13+
beforeEach(async () => {
14+
const module: TestingModule = await Test.createTestingModule({
15+
imports: [
16+
TypegooseModule.forFeature([AccountCredential]),
17+
MockModule
18+
],
19+
providers: [AccountCredentialService]
20+
}).compile()
21+
22+
service = module.get<AccountCredentialService>(AccountCredentialService)
23+
mock = module.get<MockService>(MockService)
24+
})
25+
26+
afterEach(async () => await mock.dropDatabase())
27+
afterAll(async () => await closeMongoConnection())
28+
29+
it('should be defined', () => {
30+
expect(service).toBeDefined()
31+
})
32+
})

0 commit comments

Comments
 (0)