-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(): improve docs, improve jest setup
- Loading branch information
Showing
32 changed files
with
194 additions
and
140 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,75 @@ | ||
# Hyper Project | ||
|
||
![Github Actions](https://github.com/chyzwar/hyper/workflows/Build/badge.svg) | ||
|
||
Experimental web framework for node.js | ||
|
||
## Project status | ||
|
||
I work on this as hobby project. This is not production ready. If you are looking for web framework I recommend fastify.js or hapi.js | ||
|
||
## Why | ||
|
||
```js | ||
import {Server, BodyParser, Router} from "@hyper/http-server"; | ||
- no external dependacies | ||
- native ESM support | ||
- support for async/await | ||
- support for http2 | ||
- clean code and testable | ||
- great performance | ||
- first class typescript support | ||
|
||
```ts | ||
import { | ||
Server, | ||
BodyParser, | ||
Router, | ||
RequestLogger | ||
} from "@hyper/http-server"; | ||
|
||
const server = new Server({port: 3000}); | ||
|
||
const bodyParser = new BodyParser(); | ||
const requestLogger = new RequestLogger(); | ||
const router = new Router(); | ||
server.addLayer(bodyParser); | ||
|
||
router.post("/", (req, res) => { | ||
router.get("/", (req, res) => { | ||
res.json({ | ||
message: "Hello World", | ||
body: req.body, | ||
}); | ||
}); | ||
|
||
server.addLayer(bodyParser); | ||
router.post("/echo", (req, res) => { | ||
res.json({ | ||
body: req.body, | ||
}); | ||
}); | ||
server.addLayer(requestLogger); | ||
server.addRouter(router); | ||
|
||
server | ||
.listen(3000) | ||
.then(() => { | ||
console.log("Server is listening"); | ||
.listen() | ||
.then((address) => { | ||
logger.info(`Server started on ${address.address}:${address.port}`); | ||
}) | ||
.catch((error) => { | ||
console.log("Failed to start", error); | ||
}); | ||
``` | ||
|
||
## What is implemented | ||
|
||
- middleware system simmilar to express | ||
- simple router | ||
- body parser | ||
- isomorthic json logger | ||
- isomorthinc http client | ||
- request logging middleware | ||
- mock request and response | ||
|
||
## What is missing | ||
|
||
- compresssion | ||
- cookie parser | ||
- documentation | ||
- request schema validation | ||
- etag/freshness and caching support |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
### @hyper/event-emitter | ||
|
||
Simple event emitter. |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import type {Config} from "jest"; | ||
|
||
const config: Config = { | ||
displayName: "@hyper/generic-types", | ||
testEnvironment: "jsdom", | ||
rootDir: "src", | ||
testMatch: ["**/__tests__/**/*.ts?(x)", "**/?(*.)+(spec|test).ts?(x)"], | ||
extensionsToTreatAsEsm: [".ts"], | ||
moduleNameMapper: { | ||
"^(\\.{1,2}/.*)\\.js$": "$1", | ||
}, | ||
transform: { | ||
"^.+\\.(t|j)sx?$": "@swc/jest", | ||
}, | ||
}; | ||
|
||
export default config; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
# TCP Socket | ||
### @hyper/http-client |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
### @hyper/http-server | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
### @hyper/http |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"$schema": "http://json.schemastore.org/swcrc", | ||
"isModule": true, | ||
"jsc": { | ||
"target": "es2022", | ||
"parser": { | ||
"syntax": "typescript", | ||
"dynamicImport": false | ||
} | ||
}, | ||
"module": { | ||
"type": "es6", | ||
"resolveFully": true | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import type {Config} from "@jest/types"; | ||
|
||
/** | ||
* Use jest with ts-jest to transform | ||
* | ||
* @see https://facebook.github.io/jest/docs/en/configuration.html | ||
*/ | ||
const config: Config.InitialOptions = { | ||
displayName: "@hyper/logger", | ||
testEnvironment: "jsdom", | ||
rootDir: "src", | ||
setupFiles: ["../jest.setup.js"], | ||
testMatch: ["**/__tests__/**/*.ts?(x)", "**/?(*.)+(spec|test).ts?(x)"], | ||
extensionsToTreatAsEsm: [".ts"], | ||
moduleNameMapper: { | ||
"^(\\.{1,2}/.*)\\.js$": "$1", | ||
}, | ||
transform: { | ||
"^.+\\.(t|j)sx?$": "@swc/jest", | ||
}, | ||
}; | ||
|
||
export default config; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
# Type Generics | ||
### @hyper/utility-types |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import type {Config} from "@jest/types"; | ||
|
||
/** | ||
* Use jest with ts-jest to transform | ||
* | ||
* @see https://facebook.github.io/jest/docs/en/configuration.html | ||
*/ | ||
const config: Config.InitialOptions = { | ||
displayName: "@hyper/utility-types", | ||
testEnvironment: "jsdom", | ||
rootDir: "src", | ||
testMatch: ["**/__tests__/**/*.ts?(x)", "**/?(*.)+(spec|test).ts?(x)"], | ||
extensionsToTreatAsEsm: [".ts"], | ||
moduleNameMapper: { | ||
"^(\\.{1,2}/.*)\\.js$": "$1", | ||
}, | ||
transform: { | ||
"^.+\\.(t|j)sx?$": "@swc/jest", | ||
}, | ||
}; | ||
|
||
export default config; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.