GithubHelp home page GithubHelp logo

nanoexpress / nanoexpress Goto Github PK

View Code? Open in Web Editor NEW
508.0 10.0 40.0 14.78 MB

Professional backend framework for Node.js

Home Page: https://nanoexpress.js.org

License: Apache License 2.0

JavaScript 100.00%
fast middleware cplusplus ws memory-efficient uwebsockets express-like esm esmodules

nanoexpress's Introduction

nanoexpress

Professional backend framework for Node.js

Node.js CI Code Climate GitHub issues

Special thanks / Sponsors

Sponsor Since
BrowserStack 2016
JetBrains 2019
Paw 2020
MacStadium 2020
GitPod 2022

as well as Sergey NN and Yaroslav Dobzhanskij for being Gold+ sponsors for short period of time

TO-DO / Roadmap

  • /get_schema — Ajv Request Validator
  • ESLint plugin for nanoexpress (for better performance)
  • TypeScript integration
  • JSDoc comments
  • Better documentations
  • nanoexpress EcoSystem (middlewares, defines, plugins)
  • Live reload page
  • staticServe watchMode
  • Get query (400x faster)
  • GraphQL subscription
  • Hooks support
  • AWS-S3 Middleware
  • Dropbox Integration
  • WebRTC integration
  • Torrent-server implementation
  • socketi Integration (Pusher API)
  • MQTT Syntax (test with clients)
  • Server-side events (test)
  • EventSource
  • Built-in fast logger (with ELK integration)
  • nanoORM written in AssemblyScript (for PostgreSQL, MySQL and SQLite)
  • Live backend builder

Table of Contents

How to Contribute

Whether you're helping us fix bugs, improve the docs, or spread the word, we'd love to have you as part of the nanoexpress community!

Check out our Contributing Guide for ideas on contributing and setup steps for getting our repositories up and running on your local machine.

Support

Thank you, all previous sponsors, backers and supporters

Sponsors

See here

License

Apache-2.0

nanoexpress's People

Contributors

akhmadiy avatar cryptodeal avatar dalisoft avatar dependabot-preview[bot] avatar dependabot[bot] avatar greenkeeper[bot] avatar lagden avatar mrauhu avatar najsar avatar xobotyi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nanoexpress's Issues

Please try PRO version

See here for reading new rules

Dear old users, i will let you know your new status, i will remove status from Patreon as soon as i get time

  • @mrauhu and @yarsky-tgz will get Commercial user status
  • @victor-a-rigacci will get Supporters status
  • Lemico (please comment here and i'll add your username here) will keep own Donaters status currently

Issue with loadtest

Bug Report

Is you/your team sponsoring this project

  • Yes
  • No

Minimal reproducible repo

https://github.com/mrddter/evaluation-nanoexpress

Current Behavior

Hi I'm evaluating some web frameworks for a next project but if I run loadtest (for performance purpose) too many errors are fired. I create this repo for understand if is a issue on my side (that not appear with other web frameworks like 0http, koa, rayo, etc) or not.

Steps to reproduce execute 'yarn start' (o 'yarn cluster') and in another terminal execute 'yarn load'.
Can you give a look? Thanks in advance 🙏

Expected behavior/code

Don't fire so many errors 🤸‍♂️

Environment

  • Node/npm version: 14.5.0 / 6.14.5
  • OS: Windows 10

Needs a better structure

Feature Request

Is you/your team sponsoring this project

  • Yes
  • No

Is your feature request related to a problem? Please describe

Right now you have to reference source files directly when importing anything that isn't in the main nanoexpress import, and (more annoyingly) the import path depends on whether you're using commonjs or esm (when using typescript and targeting esnext or when using native esm).
This is how it looks right now:

// I'm okay with this...
import nanoexpress from 'nanoexpress';
// ...but not with this.
import Route from 'nanoexpress/cjs/Route.js';
// This is how the import would look like if I were targeting native esm:
// import Route from 'nanoexpress/src/Route.js';

Additionally, you can't do things like:

import nanoexpress, { Route } from 'nanoexpress';
const route = new Route(...);

Or

import nanoexpress from 'nanoexpress';
const route = new nanoexpress.Route(...);

Describe the solution you'd like

I'd like for src/nanoexpress.js to export everything (for example the Route class), while still default-exporting the nanoexpress function.
Another thing that's maybe worth considering is also having stuff like Route be properties on the default-exported nanoexpress function (similarly to how it works in express), so they can be used like nanoexpress.Route, but that's definitely optional and I'm not even sure it's a good idea.

Describe alternatives you've considered

Just using nanoexpress as-is, that's what I'm currently trying to do.

Teachability, Documentation, Adoption, Migration Strategy

It shouldn't be very different to how it's used nowadays so changing the docs would probably be trivial.
If anything, it'll be easier to use since the import path will be be the same regardless of the module system you use/target.

I might be able to work on this but I'll have to learn a bit about exports first since I've never worked on a node library before.

bug route

Bug Report

i tried route exmaple but doesn't work

var nanoexpress = require("nanoexpress"); 
var PORT = process.env.PORT || 8000 || 3000;
var app = nanoexpress();
const Route = require('nanoexpress/cjs/Route');
const route = new Route();
app.use(route);  route.get('/', async () => 'hello world');
app.listen(PORT);

Minimal reproducible repo

Link here

Current Behavior

A clear and concise description of the behavior.

Expected behavior/code

A clear and concise description of what you expected to happen (or code).

Environment

  • Node/npm version: v19.6.1
  • OS: Linux
  • Addinational Info: _type here_

Possible Solution

Additional context/Screenshots

Add any other context about the problem here. If applicable, add screenshots to help explain.

Note

  • Project is provided as-is without any support nor warranty
  • If this issue not related to this project and exists on core of this project, please close issue or not open

Features log

Name Status Development Cost Time
@nanoexpress/core 90% 250$ 1 Week
@nanoexpress/middlewares 80% 250$ 1 Week
@nanoexpress/handler 0% 250$ 1 Week
@nanoexpress/ast-parser 60% 1000$ 4 Week
@nanoexpress/ast-compile 0% 250$ 1 Week
@nanoexpress/db-storage 0% 750$ 3 Week
@nanoexpress/file-storage 0% 750$ 3 Week
@nanoexpress/graphql 65% 750$ 3 Week
@nanoexpress/nginx 0% 250$ 1 Week
@nanoexpress/litespeed 0% 250$ 1 Week
@nanoexpress/admin 0% 1000$ 4 Week
@nanoexpress/ui 0% 1500$ 6 Week
@nanoexpress/cli 0% 500$ 2 Week
@nanoexpress/cli-compiler 0% 3000$ 12 Week

1 - Time based on 2-hour within 5-day and 8-hour within 2-day in Week
2 - All of these features within these time can be made and usable as Beta (not alpha)
3 - Maintenance cost is not less than development cost as need time to improving, fixing bugs and adding new features
4 - These times and development cost are minimum and can be increased

Update:
This table (features, cost) is not actual anymore.
These features will not be implemented, do not expect these features into nanoexpress

`res.status` No effect in setErrorHandler function

Bug Report

Is you/your team sponsoring this project

  • Yes
  • No

If your team sponsoring this project, please attach here your team lead or who purchased license GitHub login

Minimal reproducible repo

import nanoexpress from 'nanoexpress-pro';

const app = nanoexpress();

app.setErrorHandler((err, req, res) => {
  res.status(500)   // here not working ,the response status code will be 200
  res.end('error handled: ' + err.message);
});
app.get('/bar', async (req, res) => {
  throw new Error('Something was wrong in GET /bar');
  // eslint-disable-next-line no-unreachable
  res.send({ status: 'success' });
});

app.listen(4000);

Current Behavior

A clear and concise description of the behavior.

Expected behavior/code

A clear and concise description of what you expected to happen (or code).

Environment

  • Node/npm version: node 12.18.2
  • OS: ubuntu
  • Addinational Info: type here

Possible Solution

Additional context/Screenshots

Add any other context about the problem here. If applicable, add screenshots to help explain.

Note

  • Project is provided as-is without any support nor warranty
  • If this issue not related to this project and exists on core of this project, please close issue or not open

Imported modules do not work on ws handlers

Bug Report

Is you/your team sponsoring this project

  • Yes
  • No

Minimal reproducible repo

https://github.com/kran6a/nanoexpress-bug-2

Current Behavior

Creating a websocket handler that needs to use imported dependencies causes the server to crash when a ws message is received by the server with a ReferenceError: is not defined.

I suspect the error is caused by an eval() or a Function constructor using the relative path of the imported module.

Expected behavior/code

Using imported modules and constants on route handlers should work the same way it works on HTTP routes.

Environment

  • Node/npm version: Node 14.5.0/npm 6.14.5
  • OS: Debian

Getting Buffer in request.body

Hi,

I'm getting a Buffer in the request.body, when I tried to add body-parser with app.use(bodyParser.json());, I get the error stream.on is not a function and a message the key 'message' was not present.

Right now the only way is to JSON.parse(buffer.toString()) which are probably slowing down a bit given the parse.

I also tried @nanoexpress/middleware-body-parser and it's giving wrong typescript types and applying it to use, maybe it wasn't been updated.

Updated:
Well, though very minimal given a simple body, JSON PARSE: 0.085ms

Empty body crashes application

If you send a POST request with an empty request body, it causes the application to crash with an error

req.body = buffer.toString('utf8').replace(SPACE_TRIM_REGEX, ''); TypeError: Cannot read property 'toString' of undefined

My way to fix this
req.body = buffer ? buffer.toString('utf8').replace(SPACE_TRIM_REGEX, '') : null;

v5.2.3 includes "semantic-release" in dependencies

Hi there,

v5.2.3 includes semantic-release v19.0.2 in its dependencies, could you move it to devDependencies? Also, it fetches many files that aren't needed in an npm release, if you could clean them up with package.json "files": ["$includedFolder/*"] I'd appreciate.

I'm also bit confused with the @next tag that is release 9 months ago, it doesn seem to receive updates while v5 receives updates. Could you explain the difference between next tag and the current tag for nanoexpress?

V2 Introducing / V1 Support

There new breaking change (see more on releases), but V1 still will be supported within 2-week (Until 14 July 2020)

Support for V1 happens because some of our sponsors still uses V1 on production and update to V2 is risky as cost is development time, extra money cost and stability

You can see old code at here

The automated release is failing 🚨

🚨 The automated release from the master branch failed. 🚨

I recommend you give this issue a high priority, so other packages depending on you can benefit from your bug fixes and new features again.

You can find below the list of errors reported by semantic-release. Each one of them has to be resolved in order to automatically publish your package. I’m sure you can fix this 💪.

Errors are usually caused by a misconfiguration or an authentication problem. With each error reported below you will find explanation and guidance to help you to resolve it.

Once all the errors are resolved, semantic-release will release your package the next time you push a commit to the master branch. You can also manually restart the failed CI job that runs semantic-release.

If you are not sure how to resolve this, here are some links that can help you:

If those don’t help, or if this issue is reporting something you think isn’t right, you can always ask the humans behind semantic-release.


The release 6.0.0 on branch master cannot be published as it is out of range.

Based on the releases published on other branches, only versions within the range >=5.3.1 <6.0.0 can be published from branch master.

The following commits are responsible for the invalid release:

  • chore(github): CI config update (76c72be)
  • chore(github): use latest LTS CI nodejs ver (7c10409)
  • fix(core): uWS compatibility check now same (1502c64)
  • fix(Route): improve code readability (fa4b8e5)
  • chore: upgrade dependencies and dev-deps (269f2de)
  • chore(rollup): fix rollup config (b453707)
  • fix(Route): this reference fix (63f11b6)
  • fix(App): fix linting error (2d1c039)
  • Merge pull request #479 from Najsar/add_numSubscribers (dce78a5)
  • feat(numSubscribers): add numSubscribers to app (26b504b)
  • Update App.js (3e4e9aa)
  • Merge pull request #475 from nanoexpress/dependabot/npm_and_yarn/typescript-4.9.4 (d6ac2fa)
  • Merge pull request #474 from nanoexpress/dependabot/npm_and_yarn/prettier-2.8.1 (479d6a6)
  • chore(deps-dev): bump typescript from 4.9.3 to 4.9.4 (b531c88)
  • chore(deps-dev): bump prettier from 2.8.0 to 2.8.1 (7d3dba1)
  • Merge pull request #473 from nanoexpress/dependabot/npm_and_yarn/coveralls-next-4.2.0 (b092c21)
  • chore(deps-dev): bump coveralls-next from 4.1.2 to 4.2.0 (a197109)
  • Merge pull request #470 from nanoexpress/dependabot/npm_and_yarn/lint-staged-13.1.0 (f49cf69)
  • Merge pull request #471 from nanoexpress/dependabot/npm_and_yarn/eslint-8.29.0 (cd48367)
  • chore(deps-dev): bump eslint from 8.28.0 to 8.29.0 (4c23a2d)
  • chore(deps-dev): bump lint-staged from 13.0.4 to 13.1.0 (5a8298a)
  • Merge pull request #466 from nanoexpress/dependabot/npm_and_yarn/prettier-2.8.0 (f053ca7)
  • chore(deps-dev): bump prettier from 2.7.1 to 2.8.0 (27b9bc4)
  • Merge pull request #468 from nanoexpress/dependabot/npm_and_yarn/lint-staged-13.0.4 (4c8ff03)
  • chore(deps-dev): bump lint-staged from 13.0.3 to 13.0.4 (ea1c85b)
  • Merge pull request #464 from nanoexpress/dependabot/npm_and_yarn/commitlint/cli-17.3.0 (efe1ca1)
  • chore(deps-dev): bump @commitlint/cli from 17.2.0 to 17.3.0 (c7fb4d8)
  • Merge pull request #463 from nanoexpress/dependabot/npm_and_yarn/eslint-8.28.0 (38c058c)
  • chore(deps-dev): bump eslint from 8.27.0 to 8.28.0 (2acc645)
  • Merge pull request #461 from nanoexpress/dependabot/npm_and_yarn/typescript-4.9.3 (c29c28c)
  • chore(deps-dev): bump typescript from 4.8.2 to 4.9.3 (f10357e)
  • Merge pull request #459 from nanoexpress/dependabot/npm_and_yarn/ajv-8.11.2 (0cfd02f)
  • build(deps): bump ajv from 8.11.0 to 8.11.2 (cde3d94)
  • Merge pull request #457 from nanoexpress/dependabot/npm_and_yarn/husky-8.0.2 (31e7b1e)
  • chore(deps-dev): bump husky from 8.0.1 to 8.0.2 (c3a5de0)
  • Merge pull request #456 from nanoexpress/dependabot/npm_and_yarn/jest-29.3.1 (f720fda)
  • chore(deps-dev): bump jest from 29.3.0 to 29.3.1 (d11c014)
  • Merge pull request #453 from nanoexpress/dependabot/npm_and_yarn/eslint-8.27.0 (290fb08)
  • chore(deps-dev): bump eslint from 8.26.0 to 8.27.0 (19ca8c6)
  • Merge pull request #452 from nanoexpress/dependabot/npm_and_yarn/jest-29.3.0 (9f8769c)
  • chore(deps-dev): bump jest from 29.2.2 to 29.3.0 (edd9262)
  • Merge pull request #450 from nanoexpress/dependabot/npm_and_yarn/commitlint/cli-17.2.0 (8ca1564)
  • chore(deps-dev): bump @commitlint/cli from 17.1.2 to 17.2.0 (fb3e18c)
  • Merge pull request #448 from nanoexpress/dependabot/npm_and_yarn/jest-29.2.2 (9e41d7f)
  • chore(deps-dev): bump jest from 29.2.1 to 29.2.2 (e240b1a)
  • Merge pull request #447 from nanoexpress/dependabot/npm_and_yarn/eslint-8.26.0 (4762d0b)
  • chore(deps-dev): bump eslint from 8.25.0 to 8.26.0 (1e9804f)
  • Merge pull request #445 from nanoexpress/dependabot/npm_and_yarn/jest-29.2.1 (26103e6)
  • chore(deps-dev): bump jest from 29.2.0 to 29.2.1 (f708973)
  • Merge pull request #443 from nanoexpress/dependabot/npm_and_yarn/jest-29.2.0 (fb6b338)
  • chore(deps-dev): bump jest from 29.1.2 to 29.2.0 (3efa2d1)
  • docs(readme): update sponsors section (9f41470)
  • Merge pull request #440 from nanoexpress/dependabot/npm_and_yarn/eslint-8.25.0 (4a9843e)
  • chore(deps-dev): bump eslint from 8.24.0 to 8.25.0 (9decacf)
  • Merge pull request #439 from nanoexpress/dependabot/npm_and_yarn/jest-29.1.2 (8f78320)
  • chore(deps-dev): bump jest from 29.1.1 to 29.1.2 (a61fb85)
  • Merge pull request #438 from nanoexpress/dependabot/npm_and_yarn/jest-29.1.1 (431a7d4)
  • chore(deps-dev): bump jest from 29.0.3 to 29.1.1 (34e4f0e)
  • Merge pull request #437 from nanoexpress/dependabot/npm_and_yarn/eslint-8.24.0 (3410d0a)
  • chore(deps-dev): bump eslint from 8.23.1 to 8.24.0 (683b3c8)
  • Merge pull request #436 from nanoexpress/dependabot/npm_and_yarn/rollup-2.79.1 (d46c6ae)
  • chore(deps-dev): bump rollup from 2.79.0 to 2.79.1 (55bee21)
  • Merge pull request #435 from nanoexpress/dependabot/npm_and_yarn/eslint-8.23.1 (3f54d54)
  • chore(deps-dev): bump eslint from 8.23.0 to 8.23.1 (3507897)
  • Merge pull request #434 from nanoexpress/dependabot/npm_and_yarn/jest-29.0.3 (3e944b4)
  • chore(deps-dev): bump jest from 29.0.2 to 29.0.3 (e8458ac)
  • Merge pull request #433 from nanoexpress/dependabot/npm_and_yarn/jest-29.0.2 (e8d797e)
  • chore(deps-dev): bump jest from 29.0.1 to 29.0.2 (a2ab2b9)

Those commits should be moved to a valid branch with git merge or git cherry-pick and removed from branch master with git revert or git reset.

A valid branch could be next.

See the workflow configuration documentation for more details.


Good luck with your project ✨

Your semantic-release bot 📦🚀

The automated release is failing 🚨

🚨 The automated release from the master branch failed. 🚨

I recommend you give this issue a high priority, so other packages depending on you can benefit from your bug fixes and new features again.

You can find below the list of errors reported by semantic-release. Each one of them has to be resolved in order to automatically publish your package. I’m sure you can fix this 💪.

Errors are usually caused by a misconfiguration or an authentication problem. With each error reported below you will find explanation and guidance to help you to resolve it.

Once all the errors are resolved, semantic-release will release your package the next time you push a commit to the master branch. You can also manually restart the failed CI job that runs semantic-release.

If you are not sure how to resolve this, here are some links that can help you:

If those don’t help, or if this issue is reporting something you think isn’t right, you can always ask the humans behind semantic-release.


The release 6.0.0 on branch master cannot be published as it is out of range.

Based on the releases published on other branches, only versions within the range >=5.3.1 <6.0.0 can be published from branch master.

The following commits are responsible for the invalid release:

  • chore(github): CI config update (76c72be)
  • chore(github): use latest LTS CI nodejs ver (7c10409)
  • fix(core): uWS compatibility check now same (1502c64)
  • fix(Route): improve code readability (fa4b8e5)
  • chore: upgrade dependencies and dev-deps (269f2de)
  • chore(rollup): fix rollup config (b453707)
  • fix(Route): this reference fix (63f11b6)
  • fix(App): fix linting error (2d1c039)
  • Merge pull request #479 from Najsar/add_numSubscribers (dce78a5)
  • feat(numSubscribers): add numSubscribers to app (26b504b)
  • Update App.js (3e4e9aa)
  • Merge pull request #475 from nanoexpress/dependabot/npm_and_yarn/typescript-4.9.4 (d6ac2fa)
  • Merge pull request #474 from nanoexpress/dependabot/npm_and_yarn/prettier-2.8.1 (479d6a6)
  • chore(deps-dev): bump typescript from 4.9.3 to 4.9.4 (b531c88)
  • chore(deps-dev): bump prettier from 2.8.0 to 2.8.1 (7d3dba1)
  • Merge pull request #473 from nanoexpress/dependabot/npm_and_yarn/coveralls-next-4.2.0 (b092c21)
  • chore(deps-dev): bump coveralls-next from 4.1.2 to 4.2.0 (a197109)
  • Merge pull request #470 from nanoexpress/dependabot/npm_and_yarn/lint-staged-13.1.0 (f49cf69)
  • Merge pull request #471 from nanoexpress/dependabot/npm_and_yarn/eslint-8.29.0 (cd48367)
  • chore(deps-dev): bump eslint from 8.28.0 to 8.29.0 (4c23a2d)
  • chore(deps-dev): bump lint-staged from 13.0.4 to 13.1.0 (5a8298a)
  • Merge pull request #466 from nanoexpress/dependabot/npm_and_yarn/prettier-2.8.0 (f053ca7)
  • chore(deps-dev): bump prettier from 2.7.1 to 2.8.0 (27b9bc4)
  • Merge pull request #468 from nanoexpress/dependabot/npm_and_yarn/lint-staged-13.0.4 (4c8ff03)
  • chore(deps-dev): bump lint-staged from 13.0.3 to 13.0.4 (ea1c85b)
  • Merge pull request #464 from nanoexpress/dependabot/npm_and_yarn/commitlint/cli-17.3.0 (efe1ca1)
  • chore(deps-dev): bump @commitlint/cli from 17.2.0 to 17.3.0 (c7fb4d8)
  • Merge pull request #463 from nanoexpress/dependabot/npm_and_yarn/eslint-8.28.0 (38c058c)
  • chore(deps-dev): bump eslint from 8.27.0 to 8.28.0 (2acc645)
  • Merge pull request #461 from nanoexpress/dependabot/npm_and_yarn/typescript-4.9.3 (c29c28c)
  • chore(deps-dev): bump typescript from 4.8.2 to 4.9.3 (f10357e)
  • Merge pull request #459 from nanoexpress/dependabot/npm_and_yarn/ajv-8.11.2 (0cfd02f)
  • build(deps): bump ajv from 8.11.0 to 8.11.2 (cde3d94)
  • Merge pull request #457 from nanoexpress/dependabot/npm_and_yarn/husky-8.0.2 (31e7b1e)
  • chore(deps-dev): bump husky from 8.0.1 to 8.0.2 (c3a5de0)
  • Merge pull request #456 from nanoexpress/dependabot/npm_and_yarn/jest-29.3.1 (f720fda)
  • chore(deps-dev): bump jest from 29.3.0 to 29.3.1 (d11c014)
  • Merge pull request #453 from nanoexpress/dependabot/npm_and_yarn/eslint-8.27.0 (290fb08)
  • chore(deps-dev): bump eslint from 8.26.0 to 8.27.0 (19ca8c6)
  • Merge pull request #452 from nanoexpress/dependabot/npm_and_yarn/jest-29.3.0 (9f8769c)
  • chore(deps-dev): bump jest from 29.2.2 to 29.3.0 (edd9262)
  • Merge pull request #450 from nanoexpress/dependabot/npm_and_yarn/commitlint/cli-17.2.0 (8ca1564)
  • chore(deps-dev): bump @commitlint/cli from 17.1.2 to 17.2.0 (fb3e18c)
  • Merge pull request #448 from nanoexpress/dependabot/npm_and_yarn/jest-29.2.2 (9e41d7f)
  • chore(deps-dev): bump jest from 29.2.1 to 29.2.2 (e240b1a)
  • Merge pull request #447 from nanoexpress/dependabot/npm_and_yarn/eslint-8.26.0 (4762d0b)
  • chore(deps-dev): bump eslint from 8.25.0 to 8.26.0 (1e9804f)
  • Merge pull request #445 from nanoexpress/dependabot/npm_and_yarn/jest-29.2.1 (26103e6)
  • chore(deps-dev): bump jest from 29.2.0 to 29.2.1 (f708973)
  • Merge pull request #443 from nanoexpress/dependabot/npm_and_yarn/jest-29.2.0 (fb6b338)
  • chore(deps-dev): bump jest from 29.1.2 to 29.2.0 (3efa2d1)
  • docs(readme): update sponsors section (9f41470)
  • Merge pull request #440 from nanoexpress/dependabot/npm_and_yarn/eslint-8.25.0 (4a9843e)
  • chore(deps-dev): bump eslint from 8.24.0 to 8.25.0 (9decacf)
  • Merge pull request #439 from nanoexpress/dependabot/npm_and_yarn/jest-29.1.2 (8f78320)
  • chore(deps-dev): bump jest from 29.1.1 to 29.1.2 (a61fb85)
  • Merge pull request #438 from nanoexpress/dependabot/npm_and_yarn/jest-29.1.1 (431a7d4)
  • chore(deps-dev): bump jest from 29.0.3 to 29.1.1 (34e4f0e)
  • Merge pull request #437 from nanoexpress/dependabot/npm_and_yarn/eslint-8.24.0 (3410d0a)
  • chore(deps-dev): bump eslint from 8.23.1 to 8.24.0 (683b3c8)
  • Merge pull request #436 from nanoexpress/dependabot/npm_and_yarn/rollup-2.79.1 (d46c6ae)
  • chore(deps-dev): bump rollup from 2.79.0 to 2.79.1 (55bee21)
  • Merge pull request #435 from nanoexpress/dependabot/npm_and_yarn/eslint-8.23.1 (3f54d54)
  • chore(deps-dev): bump eslint from 8.23.0 to 8.23.1 (3507897)
  • Merge pull request #434 from nanoexpress/dependabot/npm_and_yarn/jest-29.0.3 (3e944b4)
  • chore(deps-dev): bump jest from 29.0.2 to 29.0.3 (e8458ac)
  • Merge pull request #433 from nanoexpress/dependabot/npm_and_yarn/jest-29.0.2 (e8d797e)
  • chore(deps-dev): bump jest from 29.0.1 to 29.0.2 (a2ab2b9)

Those commits should be moved to a valid branch with git merge or git cherry-pick and removed from branch master with git revert or git reset.

A valid branch could be next.

See the workflow configuration documentation for more details.


Good luck with your project ✨

Your semantic-release bot 📦🚀

res.render support?

Feature Request

Is you/your team sponsoring this project

  • Yes
  • No

Request

Hello, is there any way I can render EJS/PugJS templates like res.render() function of expressJS. Maybe even as an optional plugin?

Thanks!

Performance slowdown on Docker

Bug Report

Minimal reproducible repository

See https://github.com/nanoexpress/nanoexpress-vps-bench

Current Behavior

When comparing between native and Docker code execution difference is does 100% for me. After patching command it differs only ~35%. Looks like not a much difference, but it's a lot

Expected behavior/code

Maximum ~10% performance difference

Environment

  • Node/npm version: Node.js v10+
  • OS: Ubuntu, Debian, WSL2 Ubuntu/Debian
  • Addinational Info: Docker causes this

Possible Solution

Run code outside Docker, try use pm2 and cluster or Threaded mode

Additional context/Screenshots

See wrk results

Docker
~ 
❯ wrk -c8 -t8 -d60  http://localhost:4200/time
Running 1m test @ http://localhost:4200/time
  8 threads and 8 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency   188.99us  218.96us  17.18ms   97.72%
    Req/Sec     5.88k   472.61     8.56k    82.54%
  2808875 requests in 1.00m, 736.66MB read
Requests/sec:  46736.89
Transfer/sec:     12.26MB
~ took 1m 
❯ wrk -c8 -t8 -d60  http://localhost:4100/time
Running 1m test @ http://localhost:4100/time
  8 threads and 8 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency    71.53us   48.08us   7.54ms   98.93%
    Req/Sec    14.10k   320.84    14.62k    84.90%
  6745752 requests in 1.00m, 0.90GB read
Requests/sec: 112243.11
Transfer/sec:     15.31MB
~ took 1m 
❯ wrk -c8 -t8 -d60  http://localhost:4300/time
Running 1m test @ http://localhost:4300/time
  8 threads and 8 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency    62.87us   37.68us   8.32ms   98.91%
    Req/Sec    15.88k   274.27    16.46k    84.59%
  7597597 requests in 1.00m, 695.58MB read
Requests/sec: 126417.81
Transfer/sec:     11.57MB
~ took 1m 
❯ 
Native on host
~ 
❯ wrk -c8 -t8 -d60  http://localhost:4200/time
Running 1m test @ http://localhost:4200/time
  8 threads and 8 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency   158.28us  234.08us  16.64ms   98.04%
    Req/Sec     7.13k     1.27k    9.79k    54.36%
  3408243 requests in 1.00m, 0.87GB read
Requests/sec:  56709.17
Transfer/sec:     14.87MB
~ took 1m 
❯ wrk -c8 -t8 -d60  http://localhost:4100/time
Running 1m test @ http://localhost:4100/time
  8 threads and 8 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency    42.81us  483.85us  55.51ms   99.94%
    Req/Sec    27.49k   678.37    29.27k    83.59%
  13154310 requests in 1.00m, 1.75GB read
Requests/sec: 218875.77
Transfer/sec:     29.85MB
~ took 1m 
❯ wrk -c8 -t8 -d60  http://localhost:4300/time
Running 1m test @ http://localhost:4300/time
  8 threads and 8 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency    38.90us  394.14us  46.63ms   99.71%
    Req/Sec    33.28k     1.16k   36.65k    86.69%
  15918839 requests in 1.00m, 1.42GB read
Requests/sec: 264874.76
Transfer/sec:     24.25MB
~ took 1m 
❯ 

Is a nice pice of code but you can't sell it

Feature Request

  • missing benchmarks on main page ( this guy do it right ) http://gwan.com
    Missing info on main page
    Performance improvement by ~25%
    Try to call EXPERIMENTAL_FASTCALL=1 node server.js
  • missing information on main page say that is base uWebSockets
  • also benchmark link from homepage https://nanoexpress.js.org/benchmark ?? missing where is graphs

A clear and concise description of what the problem is. Ex. I have an issue when [...]

Describe the solution you'd like

A clear and concise description of what you want to happen. Add any considered drawbacks.

Describe alternatives you've considered

A clear and concise description of any alternative solutions or features you've considered.

nanoexpress Pro (CJS version) - End of Life date

Stage Start Date End Date Action
Active - April 30 2020 +
Maintenance May 1 2020 May 31 2020 cjs branch will be created and only bug-fixes
Freeze June 1 2020 June 30 2020 Only PR will be accepted on cjs branch
EOL July 1 2020 August 31 You should go-to ESM version
Full EOL September 1 - No support, for everyone

Notes

  • On Maintenance stage, @nanoexpress/gold-sponsors or higher level sponsors can ask new feature
  • On Freeze stage only @nanoexpress/platinum-sponsors or higher level sponsors can ask new feature or bug-fixes
  • After End-of-Life (no Full End-of-Life) stage only @nanoexpress/ultra-sponsors or higher can ask only bug-fixes

Any way to wait for server closed?

Hello, this is more of a doubt.

So when I call this:

// ...
app.listen(3000))

.. a promise is returned, and even if I wait for it:

await app.listen(3000))

the next line is executed immediately.

My answer is, how can I wait until the server is stopped to finish closing other resources?

try {
  //...
  await app.listen(3000))
  // ==> should be waiting here somehow until server stops listening; e.g.
  await app.closed() 
} finally (e) {
  // cleaning up resources
  databasePool.close()
  app.close()
}

Thanks

More of the framework needs type declarations

Feature Request

Is you/your team sponsoring this project

  • Yes
  • No

Is your feature request related to a problem? Please describe

I'm trying to set up a basic app using the Route class but there aren't any type declarations for it.
For example, in the following snippet Route is of type any and my editor warns me about missing declarations for nanoexpress/cjs/Route.js.

import Route from 'nanoexpress/cjs/Route.js';

Describe the solution you'd like

I'd like to have proper autocompletion and get warned whenever I do something I'm not supposed to do (type-wise), that's only possible if nanoexpress is rewritten in typescript or if type declarations are added for the rest of the library (and not just the main nanoexpress function).

Describe alternatives you've considered

I've started going through the code and writing my own .d.ts files but figuring out the expected types of things (for example the various options that can be passed to some functions) has proven to be difficult, since I'm not the one who wrote the code and don't know how these objects are meant to be used very well.

Teachability, Documentation, Adoption, Migration Strategy

If I understand it correctly all users will be able to benefit from a better editor experience, even if they don't use typescript for their own code.

P.S. thanks for making this, it looks really nice and I'd hate to have to switch libraries because of missing types.

cannot find module Route

Bug Report

use route feature then run node index.js throw error: Cannot find module '.../nanoexpress/src/Route'

$projectDict/node_modules/nanoexpress/src/Route.js is exist

(What exactly PRO PRO Slim version mean?)

Is you/your team sponsoring this project

  • Yes
  • No

Minimal reproducible repo

// file: index.js
const nanoexpress = require('nanoexpress')
const Route = require('nanoexpress/src/Route')
const app = nanoexpress()

const testRoute = new Route()
app.use('/test', testRoute)
testRoute.get('/', async () => 'hello')

app.listen(3000).then().catch(e => console.error)

Current Behavior

failed to run project

Expected behavior/code

service start with route

Environment

  • node -v: v16.2.0
  • OS: macOS Monterey 12.0 Beta

RegExp paths for Routes?

Feature Request

Can there be support for regular expression paths? I wanted to just copy over some code I had from express:

app.get(/\/[^.]+\.html/, (req, res) => ... );

but I get this error, and I'm guessing you only expect string paths because of it:

d:/projects/help-mee/node_modules/nanoexpress/src/Route.js:109
    const fetchUrl = path.indexOf('*') !== -1 || path.indexOf(':') !== -1;
                          ^
TypeError: path.indexOf is not a function
    at Route._prepareMethod (d:/projects/help-mee/node_modules/nanoexpress/src/Route.js:109:27)
    at App.exposeAppMethod [as get] (d:/projects/help-mee/node_modules/nanoexpress/src/App.js:218:44)

Is you/your team sponsoring this project

  • Yes
  • No

Describe alternatives you've considered

I've considered just looping over every html file and making a separate route for it, but this is tedious, adds a ton of startup time and cpu on app initialize, and makes the whole app laggier. I am still forced to use it, but if you can implement this, I would really appreciate it!

Crash randomly..

Bug Report

Is you/your team sponsoring this project

  • Yes
  • No

If your team sponsoring this project, please attach here your team lead or who purchased license GitHub login

Minimal reproducible repo

Link here

Current Behavior

Crash on POST request.
TypeError: stream.on is not a function
at readStream (/root/middleware/node_modules/raw-body/index.js:190:10)
at getRawBody (/root/middleware/node_modules/raw-body/index.js:108:12)
at read (/root/middleware/node_modules/body-parser/lib/read.js:77:3)
at urlencodedParser (/root/middleware/node_modules/body-parser/lib/types/urlencoded.js:116:5)
at /root/middleware/node_modules/nanoexpress-pro/cjs/nanoexpress.js:1718:17
at new Promise ()
at middleware (/root/middleware/node_modules/nanoexpress-pro/cjs/nanoexpress.js:1717:22)
at handler (/root/middleware/node_modules/nanoexpress-pro/cjs/nanoexpress.js:1910:40)

Expected behavior/code

Allow users to login.

Environment

  • Node/npm version: Node js 14.15.0
  • OS: Ubuntu 18.04

Possible Solution

Additional context/Screenshots

Add any other context about the problem here. If applicable, add screenshots to help explain.

Note

  • Project is provided as-is without any support nor warranty
  • If this issue not related to this project and exists on core of this project, please close issue or not open

NanoExpress can't write remove headers

Try to add headers in nanoExpress

res.removeHeader('Content-Type');
res.removeHeader('uWebSockets');
res.setHeader('Content-Type', 'image/jpg');

But got now 2 headers and old one was never remove any way why its add me application/json

Connection: close
Content-Length: 2470
Content-Type: image/jpg
Content-Type: application/json

And now get error on my image:

And or image got
SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data

app.use(bodyParser({ json: true,limit: '5mb'}));
app.use( expressSession({

Invalid access of discarded

Bug Report

Is you/your team sponsoring this project

  • Yes
  • No

If your team sponsoring this project, please attach here your team lead or who purchased license GitHub login

Minimal reproducible repo

Link here

Current Behavior

A canceled request crashes the service

Expected behavior/code

Canceled requests should not throw errors and crash the service

Environment

  • Node/npm version: Node 16/npm 8
  • OS: Windows 11

Possible Solution

Additional context/Screenshots

Add any other context about the problem here. If applicable, add screenshots to help explain.

Note

  • Project is provided as-is without any support nor warranty
  • If this issue not related to this project and exists on core of this project, please close issue or not open

Response and request .pipe() method seem bugged

Bug report

Is you/your team sponsoring this project

  • Yes
  • No

Current Behavior

res.pipe() expects callback: (pipe: Readable) => void, size?: number, compressed?: boolean
The callback gives me a Readable stream instead of a Writable so that I can stream data to the client
req.pipe() is defined on the interface but if called it throws req.pipe is not a function
A clear and concise description of what the problem is. Ex. I have an issue when [...]

Expected Behavior

res.pipe() should allow to pipe a readable stream to the client
req.pipe() should be pipeable into a writable stream or the method should be removed from the interface

Describe alternatives you've considered

Writing the response in chunks by attaching a listener to the readable stream and writing each chunk as it is read.

[NOT] Project business model will not change

Currently all project access will get access, but some of users we're using project on commercial project without being Sponsor (no, i didn't added analytics).

As planned this project was made for

  • Free for open-source projects (to support open-source community)
  • Paid for commercial projects (closed-source apps)
  • Discounts for students and non-profit organizations (should be contacted to me)
  • Discounts up-to 30% due of COVID-19 for new users (should be contacted to me)

Now, starting at 1-June 2020, project sponsors can stop supporting project on Patreon, everyone who wants support author (me) can support me via Patreon with small amount of donate.

New project model will be

  • Closed-source on GitHub (private)
  • Minified build for npm for everyone without code source-maps
  • Paid-support as NO support will be provided to everyone
  • Per-feature cost, see #33 for more info

Project old sponsors have right to access source code and will be able to install from GitHub releases with un-minified source code and code source-maps

Reason to change business model

  • Peoples used my project on commercial project without sponsorship
  • I didn't able grow sponsors list
  • Due of COVID-19
  • And other reasons...

Only five people can access to closed-source project repository and some of them are @yarsky-tgz @mrauhu and others who doesn't want show yourself (thank you)

Problems with websocket

So basically I am trying to reproduce the basic example found in the docs with no luck
This is my server code:

const nanoexpress = require('nanoexpress-pro/cjs')

const app = nanoexpress();

app.ws('/', (req, ws) => {
  console.log('Connected');

  ws.on('message', (message) => {
    console.log('Message received', message);
  });
});

app.listen(4000);

And this is my client code:

var ws = new WebSocket('ws://localhost:4000'); 

ws.onopen = function () { 
  ws.send("hello!"); 
}

ws.onmessage = function(msg) { 
console.log('msg',msg)
  if(msg.data instanceof Blob) { 
    processBlob(msg.data);
  } else {
    processText(msg.data);
  }
}

When we execute the client code the server will crash:
image

Any idea why?

[types] invalid HttpRoute typing

Bug Report

Is you/your team sponsoring this project

  • Yes
  • No

Minimal reproducible repo

https://codesandbox.io/s/clever-shirley-dy0l5?file=/src/index.ts

Current Behavior

Getting error:

error TS2769: No overload matches this call.
  Overload 1 of 4, '(path: string, callback: HttpRoute): nanoexpressApp', gave the following error.
    Argument of type '(req: HttpRequest, res: HttpResponse) => HttpResponse' is not assignable to parameter of type 'HttpRoute'.
      Type 'HttpResponse' is missing the following properties from type 'nanoexpressApp': connect, host, port, address, and 19 more.
  Overload 2 of 4, '(path: string, ...middlewares: MiddlewareRoute[]): nanoexpressApp', gave the following error.
    Argument of type '(req: HttpRequest, res: HttpResponse) => HttpResponse' is not assignable to parameter of type 'MiddlewareRoute'.
      Type 'HttpResponse' is not assignable to type 'nanoexpressApp'.
  Overload 3 of 4, '(path: string, options: RouteOption, ...middlewares: MiddlewareRoute[]): nanoexpressApp', gave the following error.
    Type '(req: HttpRequest, res: HttpResponse) => HttpResponse' has no properties in common with type 'RouteOption'.

Expected behavior/code

TO have proper type definitions =)

Environment

  • Node/npm version: node 15.11, yarn 1.22.10, npm 7.6.0
  • OS: Windows 10
  • Addinational Info:

Possible Solution

If to assume that docs are right, HttpRoute type definition should be like this:

type HttpRoute = (req: HttpRequest, res: HttpResponse) => any | Promise<any>;

Allow getting IP address of machine accessing the server

Feature Request

Is you/your team sponsoring this project

  • Yes
  • No

Is your feature request related to a problem? Please describe

I'm writing a ratelimiter that rate limits by ip but I hit a road block while trying to find the ip of the person requesting the resource.

Describe the solution you'd like

getRemoteIPv4 and getRemoteIPv6 or a similar api on the request object. According to uwebsockets.js docs because this project appears to be using it, we can get the IPV6 address of a client in the request object so this should be easy as adding a file in request-proto.

Describe alternatives you've considered

In production I don't actually need to think about this problem as a reverse proxy will pass the real ip as a header.

Teachability, Documentation, Adoption, Migration Strategy

Should be able to be documented similar to other request methods.

Other stuff

Since I need to exersice good coding style, I might just try doing my first legitimate PR on this

Duplicate Content-Length for CORS

I have written unit tests for my API and I realized that OPTIONS calls fails because Nanoexpress returns duplicated Content-Length header. I tried both Axios and GotJS clients. It seems that the exception is thrown inside NodeJS HTTP parser (I use NodeJS v12.16.2 now). I moved to backend and tested the same methods with NanoExpress and Express. Express test passes while Nanoexpress test fails.

Here is the repo to try it yourself: https://github.com/literakl/nano-options
Code:

const cors = require('cors');
app.options('/v1/users/:userId', cors());
app.options('/v1/polls/:pollId', cors(), () => {});

Exception:

RequestError: Parse Error: Duplicate Content-Length
GotError: Parse Error: Duplicate Content-Length
    at onError (node_modules\got\dist\source\request-as-event-emitter.js:140:29)
    at ClientRequest.<anonymous> (node_modules\got\dist\source\request-as-event-emitter.js:157:17)
    at ClientRequest.emit (events.js:322:22)
    at ClientRequest.origin.emit (node_modules\@szmarczak\http-timer\dist\source\index.js:39:20)
    at Socket.socketOnData (_http_client.js:483:9)
    at Socket.emit (events.js:310:20)
    at addChunk (_stream_readable.js:286:12)
    at readableAddChunk (_stream_readable.js:268:9)
    at Socket.Readable.push (_stream_readable.js:209:10)
    at Socket.socketOnData (_http_client.js:476:22)

Curl:

curl -v -X options http://127.0.0.1:3000/v1/users/sdd
*   Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to 127.0.0.1 (127.0.0.1) port 3000 (#0)
> options /v1/users/sdd HTTP/1.1
> Host: 127.0.0.1:3000
> User-Agent: curl/7.55.1
> Accept: */*
>
< HTTP/1.1 200 OK
< Access-Control-Allow-Origin: http://localhost:5000
< Vary: Origin
< Access-Control-Allow-Methods: GET,HEAD,PUT,PATCH,POST,DELETE
< Access-Control-Allow-Headers: Content-Type,Authorization
< Content-Length: 0
< uWebSockets: v0.17
< Content-Length: 0
<
* Connection #0 to host 127.0.0.1 left intact

req.body is undefined on patch requests

Bug Report

Is you/your team sponsoring this project

  • Yes
  • No

Minimal reproducible repo

https://github.com/kran6a/nanoexpress-bug-report

Current Behavior

req.body property is undefined on patch routes.

To test the route I used the following curl command: curl --request PATCH \ --url http://127.0.0.1:3030/ \ --header 'content-type: application/json' \ --data '{ "id": 1 }'

The route works as expected with other HTTP verbs

Expected behavior/code

req.body should work on patch routes the same way it works for all other methods

Environment

  • Node/npm version: Node 14.5.0/npm 6.14.5
  • OS: Debian

The automated release is failing 🚨

🚨 The automated release from the master branch failed. 🚨

I recommend you give this issue a high priority, so other packages depending on you can benefit from your bug fixes and new features again.

You can find below the list of errors reported by semantic-release. Each one of them has to be resolved in order to automatically publish your package. I’m sure you can fix this 💪.

Errors are usually caused by a misconfiguration or an authentication problem. With each error reported below you will find explanation and guidance to help you to resolve it.

Once all the errors are resolved, semantic-release will release your package the next time you push a commit to the master branch. You can also manually restart the failed CI job that runs semantic-release.

If you are not sure how to resolve this, here are some links that can help you:

If those don’t help, or if this issue is reporting something you think isn’t right, you can always ask the humans behind semantic-release.


The release 7.0.0 on branch master cannot be published as it is out of range.

Based on the releases published on other branches, only versions within the range >=6.0.4 <7.0.0 can be published from branch master.

The following commits are responsible for the invalid release:

  • fix(chore): upgrade to latest dependencies (1650cd1)
  • fix: upgrade dependencies for security fixes (05de9e0)
  • Merge pull request #547 from nanoexpress/dependabot/npm_and_yarn/eslint-8.37.0 (67e018a)
  • Merge pull request #546 from nanoexpress/dependabot/npm_and_yarn/commitlint/cli-17.5.1 (e36f49e)
  • chore(deps-dev): bump eslint from 8.36.0 to 8.37.0 (0ca215e)
  • chore(deps-dev): bump @commitlint/cli from 17.5.0 to 17.5.1 (fe55f79)
  • Merge pull request #544 from nanoexpress/dependabot/npm_and_yarn/rollup-3.20.2 (a45aef6)
  • chore(deps-dev): bump rollup from 3.20.1 to 3.20.2 (0f885c4)
  • Merge pull request #545 from nanoexpress/dependabot/npm_and_yarn/prettier-2.8.7 (adcaacd)
  • chore(deps-dev): bump prettier from 2.8.6 to 2.8.7 (8726a5e)
  • Merge pull request #543 from nanoexpress/dependabot/npm_and_yarn/rollup-3.20.1 (1e76703)
  • chore(deps-dev): bump rollup from 3.20.0 to 3.20.1 (38b9434)
  • Merge pull request #542 from nanoexpress/dependabot/npm_and_yarn/commitlint/cli-17.5.0 (9e6b5b3)
  • chore(deps-dev): bump @commitlint/cli from 17.4.4 to 17.5.0 (592c9ee)
  • Merge pull request #541 from nanoexpress/dependabot/npm_and_yarn/prettier-2.8.6 (c85d8a2)
  • chore(deps-dev): bump prettier from 2.8.5 to 2.8.6 (28ddd43)
  • Merge pull request #539 from nanoexpress/dependabot/npm_and_yarn/rollup-3.20.0 (eb82b37)
  • Merge pull request #540 from nanoexpress/dependabot/npm_and_yarn/prettier-2.8.5 (a9b6d8c)
  • chore(deps-dev): bump prettier from 2.8.4 to 2.8.5 (db380ca)
  • chore(deps-dev): bump rollup from 3.19.1 to 3.20.0 (4972500)
  • Merge pull request #537 from nanoexpress/dependabot/npm_and_yarn/rollup-3.19.1 (63ed99c)
  • Merge pull request #538 from nanoexpress/dependabot/npm_and_yarn/lint-staged-13.2.0 (85a3da5)
  • Merge pull request #536 from nanoexpress/dependabot/npm_and_yarn/eslint-8.36.0 (152a31d)
  • chore(deps-dev): bump lint-staged from 13.1.2 to 13.2.0 (2b5b68b)
  • chore(deps-dev): bump rollup from 3.19.0 to 3.19.1 (e43e835)
  • chore(deps-dev): bump eslint from 8.35.0 to 8.36.0 (e167775)
  • Merge pull request #533 from nanoexpress/dependabot/npm_and_yarn/prettier-config-airlight-2.0.1 (d35dfce)
  • Merge pull request #535 from nanoexpress/dependabot/npm_and_yarn/smartlint-6.0.1 (3347b8a)
  • chore(deps-dev): bump prettier-config-airlight from 2.0.0 to 2.0.1 (6630992)
  • chore(deps-dev): bump smartlint from 6.0.0 to 6.0.1 (3061acb)
  • Merge pull request #534 from nanoexpress/dependabot/npm_and_yarn/lint-staged-config-airlight-4.0.1 (219c700)
  • Merge pull request #532 from nanoexpress/dependabot/npm_and_yarn/eslint-config-airlight-node-4.0.1 (044f3b1)
  • chore(deps-dev): bump lint-staged-config-airlight from 4.0.0 to 4.0.1 (627165d)
  • Merge pull request #531 from nanoexpress/dependabot/npm_and_yarn/rollup-3.19.0 (060ccf7)
  • chore(deps-dev): bump eslint-config-airlight-node from 4.0.0 to 4.0.1 (9dff8a9)
  • chore(deps-dev): bump rollup from 3.18.0 to 3.19.0 (0ba82e2)
  • Merge pull request #530 from nanoexpress/dependabot/npm_and_yarn/jest-29.5.0 (d0d604e)
  • chore(deps-dev): bump jest from 29.4.3 to 29.5.0 (e72614f)
  • Merge pull request #529 from nanoexpress/dependabot/npm_and_yarn/rollup-3.18.0 (3210e7d)
  • chore(deps-dev): bump rollup from 3.17.3 to 3.18.0 (bbea93f)
  • Merge pull request #528 from nanoexpress/dependabot/npm_and_yarn/eslint-8.35.0 (a9108ae)
  • Merge pull request #527 from nanoexpress/dependabot/npm_and_yarn/rollup-3.17.3 (1340d47)
  • chore(deps-dev): bump eslint from 8.34.0 to 8.35.0 (63e8025)
  • chore(deps-dev): bump rollup from 3.17.2 to 3.17.3 (e524d57)
  • Merge pull request #526 from nanoexpress/dependabot/npm_and_yarn/rollup-3.17.2 (9d4ab38)
  • chore(deps-dev): bump rollup from 3.17.1 to 3.17.2 (c0867a1)
  • Merge pull request #524 from nanoexpress/dependabot/npm_and_yarn/commitlint/cli-17.4.4 (a937816)
  • Merge pull request #525 from nanoexpress/dependabot/npm_and_yarn/rollup-3.17.1 (56b15f4)
  • chore(deps-dev): bump rollup from 3.15.0 to 3.17.1 (988bc7f)
  • chore(deps-dev): bump @commitlint/cli from 17.4.3 to 17.4.4 (f5d9c36)

Those commits should be moved to a valid branch with git merge or git cherry-pick and removed from branch master with git revert or git reset.

A valid branch could be next.

See the workflow configuration documentation for more details.


Good luck with your project ✨

Your semantic-release bot 📦🚀

Error shown but cannot find where it's being thrown

When I use express - app starts on port 8080 as I designate and runs.

I trade out express for nanoexpress and I see:

git:(nanoexpress) ✗ node --trace-uncaught --trace-warnings server.js 
Text and data can only be passed by String, ArrayBuffer or TypedArray.

No other stack trace is emitted. I have no idea how to track down this particular error.

I'm going to guess that what this means is you cannot pass an argument to a function if that argument is not one of String, ArrayBuffer or TypedArray. And if that's true, then I'm going to suppose that passing a JSON object as an argument to a function is what's causing this error:

let { token, expiresAtTimestamp } = setupTokenAndTimestamp(contextPayload);

In the above - contextPayload here would be a JSON object.

If what I'm assuming is all correct, then I suppose this is not an issue with nanoexpress, but rather a feature request - because I can't use this server if it's not going to support JSON as arguments to functions.

Route cannot be reused with different path

We found such hackish solution for now (oldRoute is function which configures router):

const router = new Route();
app.use('/auth/api', router);
oldRoute(router);
app.use('/', router);
oldRoute(router);

waiting for better solution

POST Method doesn't seem to work

I am trying implement a sign up function which should take the body of the request then save it to MongoDB via mongoose.

  • NodeJS 14.3.0
  • Nanoexpress-pro 1.11.4
  • Mongoose 5.9.19
  • bodyparser 1.19.0

app.js

import nanoexpress from 'nanoexpress-pro';
import bodyParser from 'body-parser';
import morgan from 'morgan';
import multilang from './helpers/multilang.js';
import configRoute from './routes/auth.route.js'
import { signUp } from './controllers/auth.controller.js';

const app = nanoexpress();
if (process.env.NODE_ENV === 'development') app.use(morgan('dev'));

app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json({ limit: '10kb' }));
app.use(multilang({ baseLanguage: 'en', path: './locales' }));

app.get('/test', (req, res, next) => {
  res.status(200).json({
    msg: 'ok',
  });
});

app.post('/api/v1/users/signup', signUp);

export default app;

auth.controller.js

import User from '../models/user.model.js';

export const signUp = async (req, res, next) => {
  const newUser = await User.create(req.body);

  res.status(200).json({
    status: 'success',
    data: {
      user: newUser
    }
  });
};

In Postman, when I sent a raw request (JSON format) with blank body without the braces, the application encountered this error and got terminated immediately.

file:///home/vmtran/demonano/node_modules/nanoexpress-pro/src/request-proto/http/body.js:13
      req.body = buffer.toString('utf8').replace(SPACE_TRIM_REGEX, '');
                        ^

TypeError: Cannot read property 'toString' of undefined
    at Readable.<anonymous> (file:///home/vmtran/demonano/node_modules/nanoexpress-pro/src/request-proto/http/body.js:13:25)
    at Object.onceWrapper (events.js:421:28)
    at Readable.emit (events.js:315:20)
    at endReadableNT (_stream_readable.js:1224:12)
    at processTicksAndRejections (internal/process/task_queues.js:84:21)

Blank body with braces (even full body caused the same error):

TypeError: stream.on is not a function
    at readStream (/home/vmtran/demonano/node_modules/raw-body/index.js:190:10)
    at getRawBody (/home/vmtran/demonano/node_modules/raw-body/index.js:108:12)
    at read (/home/vmtran/demonano/node_modules/body-parser/lib/read.js:77:3)
    at jsonParser (/home/vmtran/demonano/node_modules/body-parser/lib/types/json.js:135:5)
    at file:///home/vmtran/demonano/node_modules/nanoexpress-pro/src/Route.js:247:17
    at new Promise (<anonymous>)
    at middleware (file:///home/vmtran/demonano/node_modules/nanoexpress-pro/src/Route.js:246:22)
    at file:///home/vmtran/demonano/node_modules/nanoexpress-pro/src/Route.js:434:38
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
POST /api/v1/users/signup - - ms - -

When I sent the request under form-data, I got this error:

Singup ...
----------------------------892368869056266361266620--st be an object, got ----------------------------892368869056266361266620
    at model.Document (/home/vmtran/demonano/node_modules/mongoose/lib/document.js:92:11)
    at model.Model (/home/vmtran/demonano/node_modules/mongoose/lib/model.js:107:12)
    at new model (/home/vmtran/demonano/node_modules/mongoose/lib/model.js:4706:15)
    at /home/vmtran/demonano/node_modules/mongoose/lib/model.js:3076:22
    at /home/vmtran/demonano/node_modules/mongoose/lib/model.js:3112:7
    at Array.forEach (<anonymous>)
    at /home/vmtran/demonano/node_modules/mongoose/lib/model.js:3111:15
    at /home/vmtran/demonano/node_modules/mongoose/lib/helpers/promiseOrCallback.js:31:5
    at new Promise (<anonymous>)
    at promiseOrCallback (/home/vmtran/demonano/node_modules/mongoose/lib/helpers/promiseOrCallback.js:30:10)
    at Function.create (/home/vmtran/demonano/node_modules/mongoose/lib/model.js:3046:10)
    at signUp (file:///home/vmtran/demonano/controllers/auth.controller.js:5:30)
    at routeFunction (file:///home/vmtran/demonano/node_modules/nanoexpress-pro/src/Route.js:218:32)
    at file:///home/vmtran/demonano/node_modules/nanoexpress-pro/src/Route.js:473:22
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
POST /api/v1/users/signup - - ms - -

Can't set required field for ajv schema validation

Bug Report

Is you/your team sponsoring this project

  • Yes
  • No

If your team sponsoring this project, please attach here your team lead or who purchased license GitHub login

Minimal reproducible repo

Link here

Current Behavior

Suppose I have a request schema like this.

const requestSchema: Schema = {
  query: {
    type: 'object',
    properties: {
      url: {
        type: 'string',
      },
    },
    required: ['url'],
  },
  ...
}

Setting the required field causes an error because the SchemaValue interface doesn't accept string[], while it is a valid syntax in Ajv.

Expected behavior/code

Make SchemaValue accept string[].

Environment

  • Node/npm version: [Node 12.16.0/npm 6.13.4]
  • OS: [MacOS Big Sur 11.2.2]
  • TypeScript: 4.2.3

Possible Solution

interface SchemaValue {
    [key: string]: string | string[] | SchemaValue;
  }

Additional context/Screenshots

Add any other context about the problem here. If applicable, add screenshots to help explain.

Note

  • Project is provided as-is without any support nor warranty
  • If this issue not related to this project and exists on core of this project, please close issue or not open

unhandledRejection attachOnAborted.push is not a function

unhandledRejection attachOnAborted.push is not a function
even when running the simplest test (same test works on nanoexpress but not in pro)
const app = nanoexpress();
app.get('/', (req, res) => {
return res.send({ status: 'ok' });
});
app.listen(3000);

after downgrading to 1.10.13 the error does not show

SSE implementation

Feature Request

Is your feature request related to a problem? Please describe

No

Describe the solution you'd like

SSE is a technology that allows the server to broadcast a stream of events to the clients subscribed to a specific endpoint. Is is like an unidirectional websocket connection without the extra overhead of continously pinging the server to prevent the browser from closing the ws connection.

In order to create a SSE endpoint you need to enable TCP_NODELAY on the underlying socket since you will be pushing events through the same socket without closing the connection and by default they are buffered until the buffer reach max capacity and it is flushed. Currently nanoexpress responses do not expose the raw socket so SSE endpoints are not easy to implement.

A clear and concise description of what you want to happen. Add any considered drawbacks.

  • Option 1: implement sse without a middleware just like websocket endpoints so we can create and use a sse endpoint like this:
const clients = app.sse('/events/:channel', config, middleware); //Config could contain an ajv JSON schema and headers to be able to support CORS middleware may reject the connection before it is handled by the sse implementation (for example the user did not privide the correct authorization header)
clients.broadcast('channel 1', {id: 0, event: 'message', data: 'hello world'});
  • Option 2: expose the raw socket so people can create their own middlewares.
res.socket.setNoDelay(true) //Works in express but res.socket is undefined in nanoexpress
  • Option 3: create a custom nanoexpress middleware so we can do
app.get('/events', {}, sseMiddleware, async (req, res)=>{}); //Option 1 is preferred over this since the handler will just add the response to an array to be able to broadcast events later.

Option 1 has no drawbacks and do not conflict with the existing nanoexpress methods.
Option 2 has no drawbacks but since socket is a common word someone might be already doing res.socket = "something"
Option 3 the drawback of not having a broadcast method so you have to implement broadcasting yourself, also you need keep track of the clients that join and disconnect.

Describe alternatives you've considered

Since my node servers are under nginx I have considered running sse endpoints on a separate express server but that increases the architectural complexity.

Teachability, Documentation, Adoption, Migration Strategy

This is a good-looking and very simple implementation of a sse middleware in express: https://www.npmjs.com/package/sse-broadcast

If you can, explain how users will be able to use this and possibly write out a version the docs.
Maybe a screenshot or design?

issue with nanoexpress in middleware

The issue I'm running into is that I have two apps that run express and I'm trying to convert to nanoexpress. The apps use middleware for everything. There are no routes on the main app, they are all defined in the middleware, so it looks something like..

const app = nanoexpress();

const PORT = process.env.PORT || 3000;

app.use(Api(config.Api));

const server = app.listen(PORT);

Then Api defines another nanoserver with routes and more middleware

  const app = nanoexpress();
  app.use(RequestTracking());

  app.use((req, res, next) => {
    let userAgent = req.get("User-Agent");

    if (!!userAgent) {
      if (userAgent.includes("Detectify")) {
        return res.status(404).send({
          message: "Not allow to access resource due to invalid client_id",
        });
      }
    }

    return next();
  });

  app.get("/", (req, res) => {
    res.redirect(307, "gotoplaces");
  });

And then at the bottom of that it uses another middleware that creates another nanoexpress and more routes.
The problem is none of the routes work. They all return

{
  "code": 404,
  "message": "The route does not exist"
}

Any help on how to get this to work would be appreciated.

req.body is undefined if request has large body

Bug Report

Is you/your team sponsoring this project

  • Yes
  • No

If your team sponsoring this project, please attach here your team lead or who purchased license GitHub login

Minimal reproducible repo

import nanoexpress from 'nanoexpress';
import cors from 'cors';
import bodyParser from '@nanoexpress/middleware-body-parser';

const app = nanoexpress();

app
.use(cors({
  allowedHeaders: ['Authorization', 'Content-Type']
}))
.use(bodyParser({
  urlEncoded: false
}))

.put('/user', (req, res) => {
  console.log(req.body);

  return res.send({ status: 'ok' });
});

app.listen(3000);

Current Behavior

If request has body > ~1mb, req.body is undefined, but small requests are parsed correctly

Expected behavior/code

Parse body correctly if large requests

Environment

  • Node/npm version: 14.17.1/7.23.0
  • OS: Windows 10

Additional context/Screenshots

I've tried to create a middleware too see body content, only with small requests buffer is returned, large requests are undefined. So i think the is not on @nanoexpress/middleware-body-parser

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.