serverless-offline with ioc container like inversify.js

Created on 15 Jul 2018  路  4Comments  路  Source: dherault/serverless-offline

A route cannot call as twice: "Error: Cannot apply @injectable decorator multiple times."

Most helpful comment

@mattmeye Hey Matt,

I'm having a similar issue using inversify with serverless offline. Have you found any solutions or workarounds while this issue persists?

Edit: To avoid this error I modified my npm script using serverless offline to be:

sls offline start --useSeparateProcesses

Also, I added the following import at the top of each handler file:

import "reflect-metadata";

All 4 comments

@dherault is there a possibility to run a 'clean'-function on every request?

like this: (source inversify.js):

If you run the application multiple times within a shared runtime process (e.g. unit testing) you might need to clean up the existing metadata before each test.

import { cleanUpMetadata } from "inversify-express-utils";

describe("Some Component", () => {

beforeEach(() => {
    cleanUpMetadata();
});

it("Some test case", () => {
    // ...
});

});

@mattmeye Hey Matt,

I'm having a similar issue using inversify with serverless offline. Have you found any solutions or workarounds while this issue persists?

Edit: To avoid this error I modified my npm script using serverless offline to be:

sls offline start --useSeparateProcesses

Also, I added the following import at the top of each handler file:

import "reflect-metadata";

Hey @EthanTPainter

this is absolutely the same what I did.

Having the same problem. Have you found any solutions?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

balintpeak picture balintpeak  路  4Comments

JimLynchCodes picture JimLynchCodes  路  4Comments

FranzSkuffka picture FranzSkuffka  路  3Comments

jormaechea picture jormaechea  路  4Comments

ghost picture ghost  路  4Comments