Skip to content

Commit 166a1d4

Browse files
committed
Fix container
1 parent 96a189b commit 166a1d4

File tree

5 files changed

+31
-9
lines changed

5 files changed

+31
-9
lines changed

dist/app/CorsPlugin.d.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
export declare class CorsPlugin {
2-
constructor(options: any);
2+
private instance;
3+
private name;
4+
constructor(container: any, options: any);
5+
getInstance(): any;
6+
getName(): String;
37
}

dist/app/CorsPlugin.js

Lines changed: 10 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/app/CorsPlugin.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@
1111
"author": "",
1212
"license": "ISC",
1313
"dependencies": {
14-
"bap-node-microframework": "git+https://github.com/bureaux-a-partager/node-microframework.git"
14+
"bap-node-microframework": "git+https://github.com/bap-node-microframework/node-microframework.git"
1515
}
1616
}

src/app/CorsPlugin.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,24 @@ import * as cors from 'cors';
22
import { Container } from 'bap-node-microframework/core';
33

44
export class CorsPlugin {
5-
constructor(options) {
6-
var corsOptions = {
5+
private instance: any;
6+
private name: String = 'cors';
7+
8+
constructor(container, options) {
9+
this.instance = {
710
credentials: options.credentials || true,
811
origin: options.origin || function(origin, callback) {
912
callback(null, true);
1013
}
1114
};
12-
Container.get('app').use(cors(corsOptions));
15+
Container.getApplicationInstance().get('app').use(cors(this.instance));
16+
}
17+
18+
getInstance() {
19+
return this.instance;
20+
}
21+
22+
getName() {
23+
return this.name;
1324
}
1425
}

0 commit comments

Comments
 (0)