Opinionated starter project to build a robust and scalable backend service in TypeScript, with a code-first approach, exposing a GraphQL endpoint, and using a postgres database as an example
This repository is an opinionated starter project to build a robust and scalable backend service in TypeScript, with a code-first approach, exposing a GraphQL endpoint, and using a postgres database as an example
First you need Node, Yarn and Docker installed on your machine to run this project.
Then run the following commands :
yarn install
→ Install the dependenciesyarn prisma:generate
→ Generate the prisma clientyarn start
-> Start the server and external dependencies
🖥 Open a new terminal prompt
yarn prisma
-> Create initial tablesup
yarn prisma:seed
-> Populate the databaseThe starter project comes with an architecture proposal inspired from the clean architecture.
I recommend to read this article to better understand how it works. Feel free to use it or adapt it to your needs.
.
├── prisma
│ ├── migrations
│ │ ├── 20200904123736-user
│ │ │ ├── README.md
│ │ │ ├── schema.prisma
│ │ │ └── steps.json
│ │ └── migrate.lock
│ ├── schema.prisma
│ └── seed.ts
├── src
│ ├── components
│ │ └── user
│ │ ├── __tests__
│ │ │ └── user.service.spec.ts
│ │ ├── adapters
│ │ │ └── user.repository.ts
│ │ ├── user.entity.ts
│ │ ├── user.service.ts
│ │ └── user.source.ts
│ ├── infrastructure
│ │ ├── database
│ │ │ └── prisma.client.ts
│ │ └── resolvers
│ │ └── user.resolver.ts
│ ├── index.ts
│ └── module.ts
├── docker-compose.deps.yml
├── package.json
└── tsconfig.json
yarn start
yarn start:server
yarn start:deps
yarn lint
yarn test
yarn build
dist
folderyarn prisma:generate
yarn prisma
new
prisma/migrations
yarn prisma
up
yarn prisma:seed
This project use Prisma Migrate to create and update tables. Unfortunately this migration tool is still in an experimental state, if it’s unsuitable for your project, you can replace this tool with db-migrate and use Prisma Introspection