Overview
This Fullstack Typescript project aims to combine four popular tools (back-end NestJS / Directus, front-end React or Svelte) to create a typesafe environment with essential configurations necessary for common project requirements. It includes features such as local development environment setup, GraphQL SDK for generating database models and operations in TypeScript, and migration capabilities for export/import of data models.
Features
- Local development environment setup
- GraphQL SDK for generating database models and operations in TypeScript
- Migration capabilities for exporting and importing data models
Installation
- Fork this repository to start a new project based on the Dna architecture.
- Rename the file “example.env” to “.env” (contains the required initial environment variables).
- Run the command “npm start” under the root folder. This will install the Docker images needed for development and start the Nest/Directus environments with docker-compose.
- Optional: To run the example route of the integration between Nest/Directus, start the application with “npm run start:migration-import” (this will import the necessary schema migration of the cats feature).
For GraphQL SDK:
- Install the dependencies under the “graphql” folder with “npm install”.
- With the development docker environment running, run “npm start” to execute the codegen script.
- Optional: Pass the features as command arguments to generate specific codegens (e.g. “npm start cat bird”).
- The script will generate the necessary files based on the queries/mutations within each feature and copy/move them to their respective directories in the NestJS and React/Svelte environments.
For Migration:
- Start the Dna development environment.
- Under the “migration” folder, run the command “npm start”. This will generate the schema inside the Docker instance, which will be moved to the Directus migrations directory (directus/migrations/…) used as a volume on docker-compose for import during development initialization.
- For import into development/production environment:
- Development: Start the Dna application with the command “npm run start:migration-import” (this will import the schema directus/migrations/schema.yaml before starting the Directus image).
- Production: In the cloud environment, copy the generated schema to your cloud Directus folder and run “npx directus schema apply ./path/to/schema.yaml”.
Summary
This Fullstack Typescript project provides a comprehensive solution for setting up a typesafe environment with NestJS, Directus, React or Svelte. It includes features for local development environment setup, GraphQL SDK for generating TypeScript models and operations, and migration capabilities for exporting and importing data models. By following the installation guide, users can easily get started with the project and leverage its powerful features.