@avleon/core 0.0.14 → 0.0.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/icore.d.ts CHANGED
@@ -201,6 +201,7 @@ export declare class TestBuilder {
201
201
  private dataSourceOptions?;
202
202
  private constructor();
203
203
  static createBuilder(): TestBuilder;
204
+ addDatasource(options: DataSourceOptions): void;
204
205
  getController<T>(controller: Constructor<T>): T;
205
206
  getService<T>(service: Constructor<T>): T;
206
207
  getTestApplication(options: TestAppOptions): TestApplication;
package/dist/icore.js CHANGED
@@ -122,24 +122,41 @@ class AvleonApplication {
122
122
  return env.get("NODE_ENV") == "development";
123
123
  }
124
124
  async initSwagger(options) {
125
- const { routePrefix, logo, theme } = options, restOptions = __rest(options, ["routePrefix", "logo", "theme"]);
125
+ const { routePrefix, logo, ui, theme, configuration } = options, restOptions = __rest(options, ["routePrefix", "logo", "ui", "theme", "configuration"]);
126
126
  this.app.register(swagger_1.default, {
127
127
  openapi: Object.assign({ openapi: "3.0.0" }, restOptions),
128
128
  });
129
129
  const rPrefix = routePrefix ? routePrefix : "/docs";
130
- await this.app.register(require("@fastify/swagger-ui"), {
131
- logo: logo ? logo : null,
132
- theme: theme ? theme : {},
133
- routePrefix: rPrefix,
134
- configuration: {
135
- metaData: {
136
- title: "Avleon Api",
137
- ogTitle: "Avleon",
130
+ if (options.ui && options.ui == "scalar") {
131
+ await this.app.register(require("@scalar/fastify-api-reference"), {
132
+ routePrefix: rPrefix,
133
+ configuration: configuration
134
+ ? configuration
135
+ : {
136
+ metaData: {
137
+ title: "Avleon Api",
138
+ ogTitle: "Avleon",
139
+ },
140
+ theme: options.theme ? options.theme : "kepler",
141
+ favicon: "/static/favicon.png",
142
+ },
143
+ });
144
+ }
145
+ else {
146
+ await this.app.register(require("@fastify/swagger-ui"), {
147
+ logo: logo ? logo : null,
148
+ theme: theme ? theme : {},
149
+ routePrefix: rPrefix,
150
+ configuration: {
151
+ metaData: {
152
+ title: "Avleon Api",
153
+ ogTitle: "Avleon",
154
+ },
155
+ theme: "kepler",
156
+ favicon: "/static/favicon.png",
138
157
  },
139
- theme: "kepler",
140
- favicon: "/static/favicon.png",
141
- },
142
- });
158
+ });
159
+ }
143
160
  }
144
161
  useCors(corsOptions = {}) {
145
162
  this.app.register(cors_1.default, corsOptions);
@@ -638,6 +655,9 @@ class TestBuilder {
638
655
  }
639
656
  return TestBuilder.instance;
640
657
  }
658
+ addDatasource(options) {
659
+ this.dataSourceOptions = options;
660
+ }
641
661
  getController(controller) {
642
662
  return typedi_1.default.get(controller);
643
663
  }
package/dist/openapi.d.ts CHANGED
@@ -36,7 +36,9 @@ interface ServerVariableObject {
36
36
  export type OpenApiUiOptions = {
37
37
  logo?: any;
38
38
  theme?: any;
39
+ ui?: "default" | "scalar";
39
40
  openapi?: string;
41
+ configuration?: any;
40
42
  routePrefix?: string;
41
43
  info?: InfoObject;
42
44
  servers?: ServerObject[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@avleon/core",
3
- "version": "0.0.14",
3
+ "version": "0.0.17",
4
4
  "main": "./dist/index.js",
5
5
  "scripts": {
6
6
  "build": "rimraf dist && tsc",
@@ -13,6 +13,7 @@
13
13
  "license": "ISC",
14
14
  "devDependencies": {
15
15
  "@types/jest": "^29.5.14",
16
+ "@types/node": "^20.17.25",
16
17
  "class-transformer": "^0.5.1",
17
18
  "class-validator": "^0.14.1",
18
19
  "jest": "^29.7.0",
@@ -43,6 +44,9 @@
43
44
  "class-validator": "^0.14.1",
44
45
  "typeorm": "^0.3.20"
45
46
  },
47
+ "optionalDependencies": {
48
+ "@scalar/fastify-api-reference": "^1.25.119"
49
+ },
46
50
  "directories": {
47
51
  "test": "tests"
48
52
  },
@@ -51,4 +55,4 @@
51
55
  "type": "git",
52
56
  "url": "git+https://github.com/avleonjs/avleon-core"
53
57
  }
54
- }
58
+ }