Skip to content

Commit

Permalink
add missed files
Browse files Browse the repository at this point in the history
  • Loading branch information
yishengjiangcollab committed Sep 1, 2020
1 parent 1fb7a20 commit 2176861
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
6 changes: 5 additions & 1 deletion packages/xarc-app-dev/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,11 @@
"subapp-util": "../subapp-util"
},
"devDependencies": {
"@xarc/app": "../xarc-app"
"@xarc/app": "../xarc-app",
"electrode-archetype-opt-postcss": "../electrode-archetype-opt-postcss",
"@xarc/app-dev": "./",
"electrode-archetype-opt-sass": "../electrode-archetype-opt-sass",
"electrode-archetype-opt-stylus": "../electrode-archetype-opt-stylus"
}
},
"nyc": {
Expand Down
12 changes: 9 additions & 3 deletions packages/xarc-app-dev/src/lib/dev-admin/dev-http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@ export interface IDevHttpServerOptions {
export type HttpRequestEvent = "connect" | "response" | "timeout" | "close" | "finish";
export type HttpServerEvent = "open" | "close" | "listening" | "error";

export interface IDevHttpServer {
export interface DevHttpServer {
webpackDevHttpPlugin: RequestListener;
start: () => void;
stop?: () => void;
addRequestListener: (event: HttpRequestEvent, handler: any) => void;
addServerEventListener: (event: HttpServerEvent, hander: any) => void;
}

export const setup = function({ port, host }): IDevHttpServer {
export const setup = function({ port, host }): DevHttpServer {
const middleware = new Middleware({
baseUrl: () => {
return Url.format({
Expand Down Expand Up @@ -75,6 +76,11 @@ export const setup = function({ port, host }): IDevHttpServer {
addServerEventListener: (event: HttpServerEvent, cb) => {
server.addListener(event.toString(), cb);
},
addRequestListener: (event: HttpRequestEvent, cb: any) => (this.requestEventHooks[event] = cb)
stop: () => {
server.close(function() {
console.log("Server closed!");
});
},
addRequestListener: (event: HttpRequestEvent, cb: any) => (requestEventHooks[event] = cb)
};
};
4 changes: 2 additions & 2 deletions packages/xarc-app-dev/src/lib/dev-admin/dev-server.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable @typescript-eslint/no-var-requires */
export {};
import { IDevHttpServer, setup } from "./dev-http";
import { DevHttpServer, setup } from "./dev-http";

/* eslint-disable global-require, no-console */

Expand All @@ -23,7 +23,7 @@ if (process.env.WEBPACK_DEV === undefined) {
}

if (http) {
const devHttpServer: IDevHttpServer = setup({
const devHttpServer: DevHttpServer = setup({
host: archetype.webpack.devHostname,
port: archetype.webpack.devPort
});
Expand Down

0 comments on commit 2176861

Please sign in to comment.