gothinkster / realworld

"The mother of all demo apps" — Exemplary fullstack Medium.com clone powered by React, Angular, Node, Django, and many more
https://realworld-docs.netlify.app/
MIT License
80.57k stars 7.34k forks source link

NestJS + TypeORM #182

Closed lujakob closed 6 years ago

lujakob commented 6 years ago

Creating a new example backend api app with nestjs and typeorm on https://github.com/lujakob/nestjs-realworld-example-app

stephnr commented 6 years ago

Nice job!!! Nest is a really awesome framework!

lujakob commented 6 years ago

@Cameron-C-Chapman I have step 3 "Implement all of Conduit's functionality per the spec & API" finished, including one test file tag.controller.spec.ts - What's the next steps? Does anyone review my code for improvements?

lujakob commented 6 years ago

@EricSimons , @Cameron-C-Chapman The codebase is ready for the review. Thank you in advance!

anishkny commented 6 years ago

hi @lujakob I tried to run this locally and got following error:

$ npm start

Error: Cannot find module '../config'
    at Function.Module._resolveFilename (module.js:547:15)
    at Function.Module._load (module.js:474:25)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/private/tmp/nestjs-realworld-example-app/src/user/user.decorator.ts:2:1)
    at Module._compile (module.js:652:30)
    at Module.m._compile (/private/tmp/nestjs-realworld-example-app/node_modules/ts-node/src/index.ts:422:23)
    at Module._extensions..js (module.js:663:10)
    at Object.require.extensions.(anonymous function) [as .ts] (/private/tmp/nestjs-realworld-example-app/node_modules/ts-node/src/index.ts:425:12)
    at Module.load (module.js:565:32)

I renamed src/config.ts.example to src/config.ts and retried, but got different error:


[Nest] 31049   - 2018-8-21 14:01:07   [NestFactory] Starting Nest application...
[Nest] 31049   - 2018-8-21 14:01:07   [ExceptionHandler] Nest cannot export component / module that is not a part of the currently proccessed module (TypeOrmCoreModule). Please verify whether each exported unit is available in this particular context.
Error: Nest cannot export component / module that is not a part of the currently proccessed module (TypeOrmCoreModule). Please verify whether each exported unit is available in this particular context.
    at Module.validateExportedProvider (/private/tmp/nestjs-realworld-example-app/node_modules/@nestjs/core/injector/module.js:224:19)
    at Module.addCustomExportedComponent (/private/tmp/nestjs-realworld-example-app/node_modules/@nestjs/core/injector/module.js:211:32)
    at Module.addExportedComponent (/private/tmp/nestjs-realworld-example-app/node_modules/@nestjs/core/injector/module.js:195:25)
    at NestContainer.addExportedComponent (/private/tmp/nestjs-realworld-example-app/node_modules/@nestjs/core/injector/container.js:113:16)
    at DependenciesScanner.storeExportedComponent (/private/tmp/nestjs-realworld-example-app/node_modules/@nestjs/core/scanner.js:135:24)
    at exports.map.exportedComponent (/private/tmp/nestjs-realworld-example-app/node_modules/@nestjs/core/scanner.js:86:47)
    at Array.map (<anonymous>)
    at DependenciesScanner.reflectExports (/private/tmp/nestjs-realworld-example-app/node_modules/@nestjs/core/scanner.js:86:17)
    at modules.forEach (/private/tmp/nestjs-realworld-example-app/node_modules/@nestjs/core/scanner.js:39:18)
    at Map.forEach (<anonymous>)
lujakob commented 6 years ago

@anishkny You have to create config.ts from config.ts.example and also create the TypeORM options file. Copy ormconfig.json.example to ormconfig.json and set your data base access options.

Cameron-C-Chapman commented 6 years ago

@lujakob would it make sense to add those instructions to the readme?

I think the expectation should be that people who aren't familiar with nestjs, typeorm, or even typescript might want to use this project as their first venture into it. Anything that might seem obvious to people familiar with those technologies but not to someone totally new should be called out if possible.

lujakob commented 6 years ago

@Cameron-C-Chapman I updated the Readme to include the info about copying the config.ts. Do you have further suggestions for improvement on the docs?

Cameron-C-Chapman commented 6 years ago

@lujakob that worked for me and it's looking great. Awesome job (nestjs is on my short list of things to dig more into so I'm excited about this one 😄)

The only thing I would maybe add is a note about needing to create a database called nestjsrealworld in the mysql instance referenced in the config before starting, along with maybe a sample call so the port is easily visible. Different frameworks have different default ports so that's something people will need to track down and I think they would need to know to get to main.ts to find that (nestjs docs of course would work to 😉). Maybe just a line that says now try http://localhost:3000/api/articles to verify it works, or something along those lines.

I'll get this added to the readme, awesome work!

lujakob commented 6 years ago

@Cameron-C-Chapman The readme is updated. I really like NestJS, go for it ;-)