Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

simple node http server for webpack dev #1729

Merged
merged 12 commits into from
Sep 1, 2020

Conversation

yishengjiang99
Copy link
Contributor

rebased to

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


Yisheng Jiang seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@@ -0,0 +1,80 @@
/* eslint-disable @typescript-eslint/no-var-requires */
export {};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no longer needed

@@ -11,6 +12,7 @@ const electrodeServer = optionalRequire("electrode-server");
const Hapi = optionalRequire("@hapi/hapi");
const Koa = optionalRequire("koa");
const express = optionalRequire("express");
const http = optionalRequire("http");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

http is a built-in module, no need to optionalRequire it.
also, use import.

@@ -20,7 +22,21 @@ if (process.env.WEBPACK_DEV === undefined) {
process.env.WEBPACK_DEV = "true";
}

if (fastifyServer) {
if (http) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this would always be true.

@jchip
Copy link
Member

jchip commented Sep 1, 2020

CI failed, run xrun check locally to make sure it pass

import { createServer, IncomingMessage, RequestListener, ServerResponse } from "http";
import * as Url from "url";
import { resolve } from "path";
const Middleware = require("./middleware");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think middleware is typed, so you can import it normally

.end(`<!DOCTYPE html>${html}`);
},
replyError: err => {
res.writeHead(500, err);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is res.end() needed?

server.addListener(event.toString(), cb);
},
stop: () => {
server.close(function() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is asynchronous, it's a good idea to make this return a promise?

@jchip jchip changed the title CEECORE-1839 vanilla node http admin server simple node http server for webpack dev Sep 1, 2020
@jchip jchip merged commit f61f801 into electrode-io:master Sep 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants