diff --git a/.gitignore b/.gitignore index 3acdb8d..bcb33b6 100644 --- a/.gitignore +++ b/.gitignore @@ -40,6 +40,7 @@ yarn-error.log /quick-start /example_dist /example +sample/**/node_modules # tests /benchmarks/memory @@ -51,6 +52,5 @@ build/config\.gypi .npmrc pnpm-lock.yaml yarn.lock -packages-lock.json -bun.lockb - +package-lock.json +bun.lockb \ No newline at end of file diff --git a/README.md b/README.md index a226a83..ee8ed17 100644 --- a/README.md +++ b/README.md @@ -30,23 +30,23 @@ npm i @nnmt/platform-hyper-express ## Usage -Use **HyperExpressAdapter** for NestJS HTTP adapter. Must require **`@nestjs/platform-express`** in dependencies. +Use **HyperExpressAdapter** for NestJS HTTP Adapter. Must require **`@nestjs/platform-express`** in dependencies. ```js +// sample/nest-sample-1/src/main.ts import { NestFactory } from '@nestjs/core'; import { HyperExpressAdapter } from '@nnmt/platform-hyper-express'; import { AppModule } from './app.module'; async function bootstrap() { - const app = await NestFactory.create( - AppModule, - new HyperExpressAdapter() - ); + const app = await NestFactory.create(AppModule, new HyperExpressAdapter()); await app.listen(3000); } bootstrap(); ``` + Or use **`@nnmt/platform-hyper-express`** classes only to optimize hyper-express usage (Experimental). ```js +// sample/nest-sample-2/src/main.ts import { NestFactory } from '@nestjs/core'; import { HyperExpressAdapter, @@ -57,7 +57,7 @@ import { AppModule } from './app.module'; async function bootstrap() { const app = await NestFactory.create( AppModule, - new HyperExpressAdapter() + new HyperExpressAdapter(), ); await app.listen(3000); } @@ -65,9 +65,17 @@ bootstrap(); ``` + +## Sample +- Sample project are located in **`/sample`** directory. +- Sample project help developers to install/integrate **`platform-hyper-express`** into their NestJS projects. +- Sample project is not included in NPM package's source. + + + ## Encountering Problems? - **`@nnmt/platform-hyper-express`** is mostly compatible with **`@nestjs/platform-express`** but not **100%** therefore you may encounter some middlewares not working out of the box. In this scenario, you must either write your own polyfill or omit the middleware to continue. -- Currently uWebsockets.js supports only Node.js LTS versions on (glibc) Linux, macOS and Windows, on [**`Tier 1`**](https://github.com/nodejs/node/blob/master/BUILDING.md#platform-list) platforms. +- Currently uWebsockets.js supports only Node.js LTS versions 16, 18 and 20 on (glibc) Linux, macOS and Windows, on [**`Tier 1`**](https://github.com/nodejs/node/blob/master/BUILDING.md#platform-list) platforms. - The uWebsockets.js version header is disabled by default. You may opt-out of this behavior by setting an environment variable called **`KEEP_UWS_HEADER`** to a truthy value such as **`1`** or **`true`**. diff --git a/package.json b/package.json index 2fcb294..b4c2024 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@nnmt/platform-hyper-express", - "version": "0.2.3", + "version": "0.3.0", "description": "Hyper-express Adapter for NestJS (@nnmt/platform-hyper-express)", "author": "Nguyen Nhat Minh Tu", "license": "MIT", @@ -18,8 +18,8 @@ "access": "public" }, "dependencies": { - "@nestjs/common": "^10.3.7", - "@nestjs/core": "^10.3.7", + "@nestjs/common": "^10.0.0", + "@nestjs/core": "^10.0.0", "body-parser": "^1.20.2", "cors": "^2.8.5", "hyper-express": "^6.15.1", @@ -27,18 +27,24 @@ "tslib": "^2.6.2" }, "devDependencies": { - "@nestjs/testing": "^10.3.7", + "@nestjs/testing": "^10.0.0", "@types/body-parser": "^1.19.5", "@types/cors": "^2.8.17", + "@types/jest": "^29.5.12", + "jest": "^29.7.0", "mime": "^4.0.1", - "ts-node": "^10.9.2" + "ts-jest": "^29.1.2", + "ts-node": "^10.9.2", + "typescript": "^5.4.3" }, "bugs": { "url": "https://github.com/cpfriend1721994/platform-hyper-express/issues" }, "main": "index.ts", + "types": "index.d.ts", "scripts": { - "test": "npm run test" + "test": "jest", + "build": "tsc --build tsconfig.build.json" }, "keywords": [ "nestjs", diff --git a/tsconfig.build.json b/tsconfig.build.json index 285e254..ff069ca 100644 --- a/tsconfig.build.json +++ b/tsconfig.build.json @@ -1,9 +1,10 @@ { "compilerOptions": { + "composite": true, "outDir": ".", "rootDir": ".", "paths": {} }, - "exclude": ["node_modules", "dist", "test/**/*", "*.spec.ts"], + "exclude": ["node_modules", "dist", "test/**/*", "*.spec.ts", "sample", "tests"], "references": [] } diff --git a/tsconfig.json b/tsconfig.json index 0fb65b9..fa7c910 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,4 +1,5 @@ { + "files": ["index.ts"], "compilerOptions": { "module": "commonjs", "noImplicitAny": false, @@ -12,11 +13,13 @@ "sourceMap": true, "allowJs": false, "outDir": "dist", + "declaration": true, + "composite": true, "baseUrl": ".", "paths": {}, }, - "include": ["packages/**/*", "integration/**/*"], - "exclude": ["node_modules", "**/*.spec.ts"], + "include": ["src", "packages/**/*", "integration/**/*"], + "exclude": ["node_modules", "**/*.spec.ts", "sample", "tests"], "references": [ { "path": "./tsconfig.build.json"