Setting up a TypeORM Project - Part 0

preview_player
Показать описание
Start the project by setting up TypeORM, TSLint, and GraphQL Yoga.

Links from video:

----
Video Suggestions:

----
Follow Me Online Here:

----
#benawad

----
#benawad
Рекомендации по теме
Комментарии
Автор

Either we have: "username": "postgres", for some reason it's taking admin username and gives error: "createdb: error: could not connect to database template1: FATAL: password authentication failed for user <machineAdminUser>". In that case when creating DB you want ro run: "createdb -U postgres

bojanmitic
Автор

For beginners each tutorial feels like a lot to digest, and that's true since we are learning a lot of cool things along the way, but the fact of the matter is this is the point of this series. Understanding configuration and setting up to make coding productive at the start and not worry about later when you're doing the "real" work. I want more videos per day to be more productive!!! Just kidding ;-) Great work, Ben. Keep it up!

sumantkanala
Автор

I like how you didn't realize you typed grapqhl instead of graphql in your ormconfig ;) Oh, and it's still in the git repo

Cobinja
Автор

Hey Ben, i'd like to understand why you prefer TypeORM vs. something like Prisma. Also, what is your plan for authentication?

psn
Автор

I'm getting this error when I try to connect
=>QueryFailedError: colonne cnst.consrc doesn't exist ?
does any one have an udea pleas

yahyawiab
Автор

Npm check is good, but it seems you use Yarn which ships with yarn upgrade-interactive, which allows you to choose certain updates, also tells you which ones will cause breaking changes.

devilmanscott
Автор

Awesome video Ben! If someone is using MySQL like me and has this error:

Client does not support authentication protocol requested by server; consider upgrading MySQL client'

This is the solution:

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'YourRootPassword';

andresmontoya
Автор

Also are you using the latest postgreSQL, i.e v10? Thanks.

sumantkanala
Автор

jumping straight into typescript-eslint without knowing how eslint works was kinda dumb ;/

mateuszciupa
Автор

how do you set up postgres on windows to have the postgres user not require a password?

racr
Автор

I have a project already using express-graphql in serverless. The missing part I have is the ORM, is really time consuming write every single method from scratch. In following this serie to evaluate if switching to graphql-yoga, ts and typeorm is a good choice.

Thanks for sharing.

arumals
Автор

running into an issue where when running yarn start im getting this error

/bin/sh: ts-node: command not found

i had to install both ts-node and typescript globally in order to get things working. just thought i'd point it out for anyone else

EDIT: This was due to a conflict caused by 1) having multiple node installations (brew and nvm), and possibly a $PATH issue as well but I can't be certain about that. All I know is that removing the brew version of node and wiping the binaries left from the global installation allowed me to get ts-node, nodemon, etc working as dev dependencies again.

zachblake
Автор

Hello Ben, I've find out that the flags "strict" and are causing errors on starting the server.

The error:

throw new TSError(formatDiagnostics(diagnosticList, cwd, ts, lineOffset))
^
TSError: ⨯ Unable to compile TypeScript
src/entity/User.ts (7, 5): Property 'id' has no initializer and is not definitely assigned in the constructor. (2564)
src/entity/User.ts (10, 5): Property 'firstName' has no initializer and is not definitely assigned in the constructor. (2564)
src/entity/User.ts (13, 5): Property 'lastName' has no initializer and is not definitely assigned in the constructor. (2564)
src/entity/User.ts (16, 5): Property 'age' has no initializer and is not definitely assigned in the constructor. (2564)
at getOutput
at Object.compile
at Module.m._compile
at Module._extensions..js (module.js:663:10)
at function) [as .ts]
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
error An unexpected error occurred: "Command failed.
Exit code: 1
Command: sh
Arguments: -c ts-node src/index.ts
Directory:
Output:
".

My package.json:

"devDependencies": {
"ts-node": "6.0.5",
"tslint": "^5.10.0",
"tslint-config-prettier": "^1.13.0",
"typescript": "2.8.3"
},
"dependencies": {
"pg": "^7.4.3",
"reflect-metadata": "^0.1.12",
"typeorm": "0.2.6"
},

My tsconfig.json (with flags comented):

{
"compilerOptions": {
"target": "es6",
"module": "commonjs",
"lib": [
"dom",
"es2017",
"esnext.asynciterable"
],
"sourceMap": true,
"outDir": "./dist",
"moduleResolution": "node",
"removeComments": true,
// "strict": true,
"noImplicitAny": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
// true,
"noImplicitThis": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"esModuleInterop": true,
false,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
},
"exclude": [
"node_modules"
],
"include": [
"./src/**/*.tsx",
"./src/**/*.ts"
]
}

marcelomagalhaes
Автор

Ben I have one question, if I want to the tslint.json works, I need to install the eslint, tslint and prettier extensions? Or with only the prettier extension it'll work?

andresmontoya
Автор

wait, where is the createdb command coming from?

sumantkanala
Автор

In the ormconfig, you set the password to empty string. How do you create a postgres user with an empty password?

ericlarson
Автор

when a parameter is named "_" it's type is any even if you have the rule in the tsconfig

stuardgerardocarrillogonza
Автор

I'll use sqlite in production. Wish me luuck.LOL!!!

oroneki
Автор

Hi Ben, i read on many blogs/articles that Objection.js (with Knex) is better option than TypeORM. Can you provide more info on the reason to choose TypeORM over Objection.js

sushilbansalk
Автор

Ben - I don't think I have ever seen you use the debugger in vscode. Any reason for that? Is it easy to setup and use - or have you found other tools you prefer?

willcalltickets