Skip to content

drewcook/nestjs-graphql-web3-template

Repository files navigation

Web3 NestJS + GraphQL Template

Description

Nest framework TypeScript starter repository. This also includes the added bells and whistles:

  • TypeORM for working with a Postgres database
  • GraphQL support
  • Simple validation with class-validator + class-transformer
  • An account entity with an Ethereum address field
  • A createAccount mutation & accounts query
  • Viem with custom scalars for Ethereum addresses and hashes
  • A prettier logger with nestjs-pino
  • A generic pagination and sorting service that can be applied to any entity
  • Base entities setup using UUID strings as IDs
  • A decimal transformer to store decimals as strings in the DB
  • An optional but non-null decorator
  • TSConfig/ESLint/Prettier wrangling
  • Husky pre-commit hooks and conventional commit messages

Installation

pnpm install

Running the app

# development mode
$ pnpm run dev

# start without watcher
$ pnpm run start

# production mode
$ pnpm run start:prod

# lint with ESLint
$ pnpm lint

# format with Prettier
$ pnpm format

Then you can open up the GraphQL Playground and play with the Account types:

mutation CreateNewAccount {
  createAccount(
    createAccountInput: {
      address: "0xEthereumAddress"
    }
  ) {
    id
    address
    createdAt
    updatedAt
  }
}

query GetAllAccounts {
  accounts(sort: { key: "address", asc: true }) {
    items {
      id
      address
      createdAt
      updatedAt
    }
    meta {
      currentPage
      itemCount
      itemType
      itemsPerPage
      totalItems
      totalPages
    }
  }
}

Running Tests

# unit tests
$ pnpm run test

# e2e tests
$ pnpm run test:e2e

# test coverage
$ pnpm run test:cov

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published