Coder Social home page Coder Social logo

typescript-example's Issues

Update README

3. edit `ormconfig.json` and change your database configuration (you can also change a database type, but don't forget to install specific database drivers)

Is there a ormconfig.ts in updated versions? I came here looking for awnsers, but I see conflicting information here.

tsc fails

Just checked out the repo and follows the instructions in README. NPM start fails - i noticed there's no build folder. Running tsc manually results in:

➜  typescript-example git:(master) ✗ tsc
node_modules/rxjs/observable/PairsObservable.d.ts(1,1): error TS2688: Cannot find type definition file for 'chai'.
node_modules/rxjs/observable/dom/AjaxObservable.d.ts(1,1): error TS2688: Cannot find type definition file for 'chai'.
src/entity/Post.ts(17,9): error TS2345: Argument of type '{ cascadeInert: boolean; }' is not assignable to parameter of type 'string | ((object: {}) => any)'.
  Object literal may only specify known properties, and 'cascadeInert' does not exist in type 'string | ((object: {}) => any)'.

ormconfig.json Is Incorrect uses *.js instead of *.ts

The current ormconfig.json file has *.js instead of *.ts.

{
  "name": "default",
  "type": "mysql",
  "host": "localhost",
  "port": 3306,
  "username": "test",
  "password": "test",
  "database": "test",
  "synchronize": true,
  "logging": false,
  "entities": [
    "src/entity/*.js"
  ],
  "subscribers": [
    "src/subscriber/*.js"
  ],
  "migrations": [
    "src/migration/*.js"
  ],
  "cli": {
    "entitiesDir": "src/entity",
    "migrationsDir": "src/migration",
    "subscribersDir": "src/subscriber"
  }
}

This is what is on the website:
http://typeorm.io/#/

{
   "type": "mysql",
   "host": "localhost",
   "port": 3306,
   "username": "test",
   "password": "test",
   "database": "test",
   "synchronize": true,
   "logging": false,
   "entities": [
      "src/entity/**/*.ts"
   ],
   "migrations": [
      "src/migration/**/*.ts"
   ],
   "subscribers": [
      "src/subscriber/**/*.ts"
   ]
}

create connection return Pending even with Await on MacOS with PG

MacOS Catalina 10.15.4

How to reproduce, simply install using quick guide

npm install typeorm --save
npm install reflect-metadata --save
npm install @types/node --save
npm install pg --save
npm install typeorm -g
typeorm init --name MyProject --database postgres
cd MyProject
npm install
npm start

It will simply return

➜  MyProject npm start

> [email protected] start /Users/sergecolle/work/eve/MyProject
> ts-node src/index.ts

When troubleshooting I found that neither the code in then and catch got executed. After modifying the code, to something like

const connection:Connection = await createConnection()

the connection will be in state Pending and then the program simply skip then and catch and terminate.

I have ask a friend to try it on his mac and he get the same issue.

there the package.json generated by the typeorm install

   "name": "MyProject",
   "version": "0.0.1",
   "description": "Awesome project developed with TypeORM.",
   "devDependencies": {
      "ts-node": "3.3.0",
      "@types/node": "^8.0.29",
      "typescript": "3.3.3333"
   },
   "dependencies": {
      "typeorm": "0.2.25",
      "reflect-metadata": "^0.1.10",
      "pg": "^7.3.0",
      "express": "^4.15.4",
      "body-parser": "^1.18.1"
   },
   "scripts": {
      "start": "ts-node src/index.ts"
   }

and the ormconfig.json

{
   "type": "postgres",
   "host": "localhost",
   "port": 5432,
   "username": "test",
   "password": "test",
   "database": "test",
   "synchronize": true,
   "logging": false,
   "entities": [
      "src/entity/**/*.ts"
   ],
   "migrations": [
      "src/migration/**/*.ts"
   ],
   "subscribers": [
      "src/subscriber/**/*.ts"
   ],
   "cli": {
      "entitiesDir": "src/entity",
      "migrationsDir": "src/migration",
      "subscribersDir": "src/subscriber"
   }
}

and made sure a postgres db with those credential existed using the psql command.

The tsconfig.json generated

{
   "compilerOptions": {
      "lib": [
         "es5",
         "es6"
      ],
      "target": "es5",
      "module": "commonjs",
      "moduleResolution": "node",
      "outDir": "./build",
      "emitDecoratorMetadata": true,
      "experimentalDecorators": true,
      "sourceMap": true
   }
}

The lib and target seem a little old to support async/await. I tried updating it to es2017, es2018, and esnext but no luck

After following given Steps....app is not starting

am getting this error: plz help if u can
Error: { Error: connect ECONNREFUSED 127.0.0.1:3306
at Object.exports._errnoException (util.js:1018:11)
at exports._exceptionWithHostPort (util.js:1041:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1090:14)
--------------------
at Protocol._enqueue (/home/dixit/typeorm/typescript-example/node_modules/mysql/lib/protocol/Protocol.js:145:48)
at Protocol.handshake (/home/dixit/typeorm/typescript-example/node_modules/mysql/lib/protocol/Protocol.js:52:23)
at PoolConnection.connect (/home/dixit/typeorm/typescript-example/node_modules/mysql/lib/Connection.js:130:18)
at Pool.getConnection (/home/dixit/typeorm/typescript-example/node_modules/mysql/lib/Pool.js:48:16)
at /home/dixit/typeorm/typescript-example/node_modules/typeorm/driver/mysql/MysqlDriver.js:509:18
at MysqlDriver.createPool (/home/dixit/typeorm/typescript-example/node_modules/typeorm/driver/mysql/MysqlDriver.js:506:16)
at MysqlDriver. (/home/dixit/typeorm/typescript-example/node_modules/typeorm/driver/mysql/MysqlDriver.js:183:51)
at step (/home/dixit/typeorm/typescript-example/node_modules/typeorm/driver/mysql/MysqlDriver.js:32:23)
at Object.next (/home/dixit/typeorm/typescript-example/node_modules/typeorm/driver/mysql/MysqlDriver.js:13:53)
at /home/dixit/typeorm/typescript-example/node_modules/typeorm/driver/mysql/MysqlDriver.js:7:71
code: 'ECONNREFUSED',
errno: 'ECONNREFUSED',
syscall: 'connect',
address: '127.0.0.1',
port: 3306,
fatal: true }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.