framework-do-dede 2.0.7 → 2.0.9

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/dede.d.ts CHANGED
@@ -14,8 +14,8 @@ export type Options = {
14
14
  };
15
15
  export declare class Dede {
16
16
  private static httpServer;
17
- static init({ framework, registries, defaultServerError }: Options): Promise<Dede>;
18
- static close(): Promise<void>;
17
+ static start({ framework, registries, defaultServerError }: Options): Promise<Dede>;
18
+ static stop(): Promise<void>;
19
19
  private static clearControllers;
20
20
  private static loadRegistries;
21
21
  }
package/dist/dede.js CHANGED
@@ -4,7 +4,7 @@ import { ElysiaHttpServer } from "./http/ElysiaHttpServer";
4
4
  import { ExpressHttpServer } from "./http/ExpressHttpServer";
5
5
  export class Dede {
6
6
  static httpServer;
7
- static async init({ framework, registries, defaultServerError }) {
7
+ static async start({ framework, registries, defaultServerError }) {
8
8
  await this.loadRegistries(registries);
9
9
  if (framework.use === 'elysia') {
10
10
  Dede.httpServer = new ElysiaHttpServer(framework.middlewares || []);
@@ -14,13 +14,14 @@ export class Dede {
14
14
  }
15
15
  if (defaultServerError)
16
16
  Dede.httpServer.setDefaultMessageError(defaultServerError);
17
- if (Registry.has('controllers')) {
18
- new ControllerHandler(Dede.httpServer, framework.port || 80);
19
- this.clearControllers();
17
+ if (!Registry.has('controllers')) {
18
+ throw new Error("No controllers registered");
20
19
  }
20
+ new ControllerHandler(Dede.httpServer, framework.port || 80);
21
+ this.clearControllers();
21
22
  return Dede;
22
23
  }
23
- static async close() {
24
+ static async stop() {
24
25
  await Dede.httpServer.close();
25
26
  }
26
27
  static clearControllers() {
@@ -4,6 +4,7 @@ import HttpServer from "./HttpServer";
4
4
  export class ElysiaHttpServer extends HttpServer {
5
5
  async close() {
6
6
  await this.framework.stop();
7
+ console.log('server closed');
7
8
  }
8
9
  constructor(uses) {
9
10
  super(new Elysia(), 'elysia');
@@ -5,6 +5,7 @@ const app = express();
5
5
  export class ExpressHttpServer extends HttpServer {
6
6
  async close() {
7
7
  await this.framework.close();
8
+ console.log('server closed');
8
9
  }
9
10
  constructor(uses) {
10
11
  super(app, 'express');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "framework-do-dede",
3
- "version": "2.0.7",
3
+ "version": "2.0.9",
4
4
  "type": "module",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",