-
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.
* feat: add @nestjs/swagger and implement basic docs * refactor: convert open api dtos to classes to allow for decorators * refactor: change the versions responses to use dtos and add descriptions * feat: add new /api/v1 prefix to all routes
- Loading branch information
1 parent
9ba3430
commit 3f90eac
Showing
42 changed files
with
400 additions
and
128 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,4 +1,5 @@ | ||
enum APIPathEnum { | ||
API = 'api', | ||
Chains = 'chains', | ||
Fees = 'fees', | ||
Versions = 'versions', | ||
|
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,21 +1,26 @@ | ||
import { Controller, Get } from '@nestjs/common'; | ||
import { ApiOkResponse } from '@nestjs/swagger'; | ||
|
||
// configs | ||
import { chains } from '@app/configs'; | ||
|
||
// dtos | ||
import { GetChainsResponseBodyDTO } from './dtos'; | ||
|
||
// enums | ||
import { APIPathEnum } from '@app/enums'; | ||
|
||
// types | ||
import type { IChainResponseBody } from '@app/types'; | ||
|
||
// utils | ||
import mapChainConfigToChainResponseBody from '@app/utils/mapChainConfigToChainResponseBody'; | ||
|
||
@Controller(APIPathEnum.Chains) | ||
export default class ChainsController { | ||
@Get() | ||
public async get(): Promise<IChainResponseBody[]> { | ||
@ApiOkResponse({ | ||
description: 'Gets the list of the available chains.', | ||
type: [GetChainsResponseBodyDTO], | ||
}) | ||
public async get(): Promise<GetChainsResponseBodyDTO[]> { | ||
return chains.map(mapChainConfigToChainResponseBody); | ||
} | ||
} |
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,48 @@ | ||
import { ApiProperty } from '@nestjs/swagger'; | ||
|
||
interface IProps { | ||
canonicalName: string; | ||
chainId: string; | ||
namespace: string; | ||
reference: string; | ||
testnet: boolean; | ||
} | ||
|
||
export default class GetChainsResponseBodyDTO { | ||
@ApiProperty({ | ||
description: 'The canonical name for the chain.', | ||
}) | ||
public readonly canonicalName: string; | ||
@ApiProperty({ | ||
description: | ||
'The ID of the chain. This is the concatenation of the chain namespace and reference as specified in CAIP-2.', | ||
}) | ||
public readonly chainId: string; | ||
@ApiProperty({ | ||
description: 'The namespace covers the class of blockchain.', | ||
}) | ||
public readonly namespace: string; | ||
@ApiProperty({ | ||
description: | ||
'The reference identifies the blockchain within a given namespace.', | ||
}) | ||
public readonly reference: string; | ||
@ApiProperty({ | ||
description: 'Whether the chain is testnet or not.', | ||
}) | ||
public readonly testnet: boolean; | ||
|
||
constructor({ | ||
canonicalName, | ||
chainId, | ||
namespace, | ||
reference, | ||
testnet, | ||
}: IProps) { | ||
this.canonicalName = canonicalName; | ||
this.chainId = chainId; | ||
this.namespace = namespace; | ||
this.reference = reference; | ||
this.testnet = testnet; | ||
} | ||
} |
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 @@ | ||
export { default as GetChainsResponseBodyDTO } from './GetChainsResponseBodyDTO'; |
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 @@ | ||
export * from './dtos'; |
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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// types | ||
import type { IFeeDocument } from '@app/types'; | ||
|
||
interface IProps { | ||
data: IFeeDocument[]; | ||
limit: number; | ||
page: number; | ||
total: number; | ||
} | ||
|
||
export default class FindByPageResultDTO { | ||
public readonly data: IFeeDocument[]; | ||
public readonly limit: number; | ||
public readonly page: number; | ||
public readonly total: number; | ||
|
||
constructor({ data, limit, page, total }: IProps) { | ||
this.data = data; | ||
this.limit = limit; | ||
this.page = page; | ||
this.total = total; | ||
} | ||
} |
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,2 +1,3 @@ | ||
export { default as CreateDTO } from './CreateDTO'; | ||
export { default as FindByPageDTO } from './FindByPageDTO'; | ||
export { default as CreateOptionsDTO } from './CreateOptionsDTO'; | ||
export { default as FindByPageOptionsDTO } from './FindByPageOptionsDTO'; | ||
export { default as FindByPageResultDTO } from './FindByPageResultDTO'; |
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 was deleted.
Oops, something went wrong.
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,2 +1 @@ | ||
export { default as IFindByPageAggregateResult } from './IFindByPageAggregateResult'; | ||
export { default as IFindByPageResult } from './IFindByPageResult'; |
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
Oops, something went wrong.