Skip to content

Commit

Permalink
feat: init http server
Browse files Browse the repository at this point in the history
  • Loading branch information
hua-bang committed Aug 28, 2024
1 parent 160f814 commit 3fa136a
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 3 deletions.
1 change: 1 addition & 0 deletions packages/express/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"author": "",
"license": "ISC",
"devDependencies": {
"@types/node": "^22.5.1",
"typescript": "^5.5.4"
}
}
17 changes: 17 additions & 0 deletions packages/express/src/application.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import http from 'http';

class Application {
private httpServer: http.Server | null = null;

listen(port: number) {
this.httpServer = http.createServer((req, res) => {
res.writeHead(200, { 'Content-Type': 'application/json' });
res.end(JSON.stringify({
data: 'Hello World!',
})
)});
this.httpServer.listen(port);
}
}

export default Application;
8 changes: 8 additions & 0 deletions packages/express/src/express.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import Application from "./application";

export function createApplication() {
const app = new Application();
return app;
}

export default createApplication;
8 changes: 5 additions & 3 deletions packages/express/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
export const add = (a: number, b: number) => {
return a + b;
}
import express from "./express";

export {
express,
}

export default express;
Empty file.
4 changes: 4 additions & 0 deletions packages/express/test/demo.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { express } from '../src/index';

const app = express();
app.listen(2309);
15 changes: 15 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 3fa136a

Please sign in to comment.