Skip to content

sinner/chat-graphql

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

How was built this project

Prerequisites

Node.js 20.11.3 or higher

Create project

npx typeorm init --name MyProject --database postgres

tsconfig.json

{
  "compilerOptions": {
    "target": "es6",
    "module": "commonjs",
    "outDir": "./dist",
    "rootDir": "./src",
    "strict": true,
    "esModuleInterop": true,
    "skipLibCheck": true,
    "forceConsistentCasingInFileNames": true,
    "resolveJsonModule": true, /* Enable importing .json files. */
    "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
    "strict": true, /* Enable all strict type-checking options. */
    "skipLibCheck": true, /* Skip type checking all .d.ts files. */
  }
}

Install Some Dependencies

npm i dotenv express cors graphql-yoga graphql
npm i -D nodemon @types/express @types/cors

Steps to run this project:

  1. Run npm i command
  2. Setup database settings inside data-source.ts file
  3. Run npm start command

Working with TypeORM

Create an Entity class in src/entity folder, after that you can generate a migration file and run it executing the following commands:

# npm typeorm migration:generate -- -d <path/to/datasource> path/to/migrations/<migration-name>
npm run typeorm migration:generate -- -d ./src/data-source.ts ./src/migration/initial --outputJs
npm run typeorm migration:run

TypeORM will only run migrations from .js files, so you need to generate the migration file with the --outputJs flag (-o).

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published