Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add version for modules #2112

Closed
morgan92333 opened this issue Apr 29, 2019 · 2 comments
Closed

Add version for modules #2112

morgan92333 opened this issue Apr 29, 2019 · 2 comments

Comments

@morgan92333
Copy link

morgan92333 commented Apr 29, 2019

[ ] Regression 
[ ] Bug report
[x] Feature request
[x] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

I would like to add version for my modules, but i don't know how can I do this. I tried to create a common module.ts but the same name of services killed each us. I tried different module.ts for the versions, it was better but the services with same names didn't work.

This is my last structure:
test-module

  • 1.0
    • controllers
      - test.controller.ts
    • services
      - test.service.ts
    • test.module.ts
  • 1.1
    • controllers
      - test.controller.ts
    • services
      - test.service.ts
    • test.module.ts

This is my test service(s):

import * as _ from 'lodash';
import { Injectable } from '@nestjs/common';

@Injectable()
export class TestService {
  public test() {
    return '1.0'; // and 1.1 in 1.1 directory
  }
}

This is my module.ts:

import { Module, Logger } from '@nestjs/common';

import { TestModule as DorotTwo } from 'test-module/1.1/test.module';
import { TestModule as DorotOne } from 'test-module/1.0/test.module'

@Module({
  controllers: [ProtobufController],
  providers: [],

  imports: [
    DorotTwo,
    DorotOne,
  ],
})
export class ProjectModule {
  constructor() {
    Logger.log('App initialized');
  }
}

This is a simple test Controller. A tried import TestService from 1.0 or 1.1 but the test function's response is always 1.0.

@Controller()
export class ProtobufController {
  constructor(private readonly testService: TestService) {
    console.log(this.testService.test()); // Always 1.0
  }
.....

If I import the 1.0 and 1.1 services, the TestService in DorotOne overwrite the DorotTwo's Test
service. Is exists an example where I can read how can I create this versioned module?

@kamilmysliwiec
Copy link
Member

See #789

@lock
Copy link

lock bot commented Sep 23, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Sep 23, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants