Code Monkey home page Code Monkey logo

Comments (9)

avatsaev avatar avatsaev commented on May 14, 2024 2

Same here, version 3.2.0

from crud.

ymoreiratiti avatar ymoreiratiti commented on May 14, 2024 1

@dolphub yeah, you should name your service as service
here is the example: https://github.com/nestjsx/crud/blob/master/integration/typeorm/src/companies/companies.controller.ts#L23

Worked for me.

P.S: The url of example has changed.
https://github.com/nestjsx/crud/blob/master/integration/crud-typeorm/companies/companies.controller.ts#L32

from crud.

michaelyali avatar michaelyali commented on May 14, 2024

@dolphub yeah, you should name your service as service
here is the example: https://github.com/nestjsx/crud/blob/master/integration/typeorm/src/companies/companies.controller.ts#L23

from crud.

dolphub avatar dolphub commented on May 14, 2024

@zMotivat0r Thanks for the fix, I am able to create / fetch (simple testing).
I still am not sure why the order of imports fails it,
I actually pulled down the example you're referring to in the docs, but am unable to actually get it to run out of the box. Says CrudOptions is has invalid types. Both options and params don't exist on the type definition of CrudOptions following through the Crud definition.

I pulled down the repo down actually to see if the swagger docs contained the model information and how it was configured.

Is there a tag or branch somewhere where I can see a working example?

from crud.

michaelyali avatar michaelyali commented on May 14, 2024

@dolphub sorry, I've updated dependencies in the integration. Please pull and try again

from crud.

fwoelffel avatar fwoelffel commented on May 14, 2024

Hi @zMotivat0r,
I can confirm this issue (and my service is named service like it is shown in the documentation).

Works

import { Controller, Inject } from '@nestjs/common';
import { LabelEntity } from '../entities/label.entity';
import { LabelsService } from '../services/labels.service';
import { Crud } from '@nestjsx/crud';

@Crud(LabelEntity)
@Controller('labels')
export class LabelsController {
  @Inject(LabelsService)
  private service: LabelsService;
}

Doesn't work

import { Controller, Inject } from '@nestjs/common';
import { Crud } from '@nestjsx/crud';
import { LabelEntity } from '../entities/label.entity';
import { LabelsService } from '../services/labels.service';

@Crud(LabelEntity)
@Controller('labels')
export class LabelsController {
  @Inject(LabelsService)
  private service: LabelsService;
}

Here is the raised error (triggered during tests):

    TypeError: typeorm_1.Entity is not a function

      1 | import { PrimaryGeneratedColumn, Entity, Column } from 'typeorm';
      2 | 
    > 3 | @Entity()
        |  ^
      4 | export class LabelEntity {
      5 |   @PrimaryGeneratedColumn()
      6 |   id: number;

      at Object.<anonymous> (annotations/entities/label.entity.ts:3:2)
      at Object.<anonymous> (annotations/controllers/labels.controller.ts:3:1)
      at Object.<anonymous> (annotations/controllers/labels.controller.spec.ts:2:1)

from crud.

jakobrosenberg avatar jakobrosenberg commented on May 14, 2024

Same on 3.1.0

from crud.

Bnaya avatar Bnaya commented on May 14, 2024

I have a feeling its related to tslib and maybe jest stuff
Code from typeorm index.js:

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
// ...
tslib_1.__exportStar(require("./decorator/entity/Entity"), exports);
tslib_1.__exportStar(require("./decorator/entity/ChildEntity"), exports);
tslib_1.__exportStar(require("./decorator/entity/TableInheritance"), exports);
// ....

Code from crud index:

"use strict";
function __export(m) {
    for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
}
Object.defineProperty(exports, "__esModule", { value: true });
__export(require("./decorators"));
__export(require("./dto"));
__export(require("./constants"));
__export(require("./enums"));
__export(require("./module"));
//# sourceMappingURL=index.js.map

from crud.

michaelyali avatar michaelyali commented on May 14, 2024

@jakobrosenberg @avatsaev @fwoelffel are you guys still having this issue with version 4?

from crud.

Related Issues (20)

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.