Git Product home page Git Product logo

middlewares'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

middlewares's People

Contributors

dalisoft avatar dependabot[bot] avatar game5413 avatar mrauhu avatar

Stargazers

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

Watchers

 avatar  avatar  avatar

middlewares's Issues

The requested module '@nanoexpress/*' does not provide an export named 'default'

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

https://github.com/torbjorn-kvist/nanoexpress-default-import
npm i && npm start

Current Behavior

import schemator from '@nanoexpress/middleware-schemator'
results in error message

nanoexpress-default-import/src/simple-doc.js:5
import schemator from '@nanoexpress/middleware-schemator'
       ^^^^^^^^^
SyntaxError: The requested module '@nanoexpress/middleware-schemator' does not provide an export named 'default'
    at ModuleJob._instantiate (internal/modules/esm/module_job.js:104:21)
    at async ModuleJob.run (internal/modules/esm/module_job.js:149:5)
    at async Loader.import (internal/modules/esm/loader.js:166:24)
    at async Object.loadESM (internal/process/esm_loader.js:68:5)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start: `node src/simple-doc.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/torbjorn/.npm/_logs/2021-01-03T09_43_53_627Z-debug.log

The same happens for

import staticServe from '@nanoexpress/middleware-static-serve'
import bodyParser from '@nanoexpress/middleware-body-parser'

Expected behavior/code

Getting access to imported object and that the server will start on port 4000

Environment

  • Node/npm version: v14.15.3 / 6.14.9
  • OS: Debian GNU/Linux 10 (buster)

Note

Only tested this on the three middlewares mention above, so it could be the same problem on the other modules when using ESM.

Static serve middleware is not working

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

create a folder with index.js
Also create a subfolder "static" containing index.html with "hello world" in it

const nanoexpress = require('nanoexpress');
const staticServe = require('@nanoexpress/middleware-static-serve/cjs');
const path = require('path');
const app = nanoexpress();
app.use(staticServe(path.join(__dirname, 'static')));
app.get('/', (req, res) => {
    return res.send({ status: 'ok' });
});
app.listen(3000);

then open http://localhost:3000/index.html
this return: {"code":404,"message":"The route does not exist"}
but http://localhost:3000/ do return "hello world"

so the issue seems to be the routing for all other paths except "/"

Environment

  • Node/npm version: v12.14.0 / v 6.13.4
  • OS: Ubunutu 20.04
    "dependencies": {
    "@nanoexpress/middleware-static-serve": "^1.0.1",
    "nanoexpress": "^2.4.9"
    }

"staticServe" sending wrong file issue

Hi,

I have been testing this framework today and stubbled over this issue.

I implemented the build-in static file module:

const staticServe = require('nanoexpress-pro/cjs/static');
app.use(staticServe(__dirname + '/public'));

I have two files in two different folders:

  1. /public/img/flag/in.svg
  2. /public/img/testin.svg

When trying to check in the browser for image number 2 (example.com/img/testin.svg), I'm getting the first image instead. You can type any name instead of "test", as long as I have a file ending in.svg it will send back the first file.

Thanks a lot.

module not found formidable middleware

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

https://github.com/nanoexpress/middlewares/tree/master/packages/formidable

Current Behavior

const formidable = require('@nanoexpress/middleware-formidable/cjs');

got an error with message:

Error: Cannot find module 'D:\www\nano\node_modules\@nanoexpress\middleware-formidable\cjs\file-upload.cjs.js'
. Please verify that the package.json has a valid "main" entry
     at tryPackage (internal/modules/cjs/loader.js:308:19)
     at Function.Module._findPath (internal/modules/cjs/loader.js:521:18)
     at Function.Module._resolveFilename (internal/modules/cjs/loader.js:872:27)
     at Module.Hook._require.Module.require (D:\www\nano\node_modules\require-in-the-middle\index.js:61:29)
     at require (internal/modules/cjs/helpers.js:88:18)
     at Object.<anonymous> (D:\www\nano\services\user\middlewares\index.js:2:20)
     at Module._compile (internal/modules/cjs/loader.js:1068:30)
     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1097:10)
     at Module.load (internal/modules/cjs/loader.js:933:32)
     at Function.Module._load (internal/modules/cjs/loader.js:774:14) {
   code: 'MODULE_NOT_FOUND',
   path: 'D:\\www\\nano\\node_modules\\@nanoexpress\\middleware-formidable\\cjs\\package.json',
   requestPath: '@nanoexpress/middleware-formidable/cjs'
 }

Expected behavior/code

not getting error exception MODULE_NOT_FOUND

Environment

  • Node/npm version: 14.17.0 / 7.15.0
  • OS: Windows 10 Home
  • Addinational Info: @nanoexpress/middleware-formidable:1.1.0

Possible Solution

modify main file on package.json

Pull Request #20

Additional context/Screenshots

image

Note

  • already tested on local by editing main file on node_modules folder

@nanoexpress/middleware-schemator Possibility to add title to initialize options

Feature Request

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

Is your feature request related to a problem? Please describe

Currently there is no way to set a title from the Initialize options
app.get('/swagger', render({ exposePath: /${exposePath} }));

But possible if you call schematorInstance.render(options) directly. So one way is probably to just define the app.get('swagger', func) to override the path.

Describe the solution you'd like

Add an option to Initialize options e.g options.swaggerUITitle or similar.

Willing to create a PR for the change! Just wanted to check if this is something that are inline in what the middleware should do.

Describe alternatives you've considered

Expose it in some other way or just override app.get('swagger', func)?

Teachability, Documentation, Adoption, Migration Strategy

CJS version - End-of-Life

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

Expressjs-Session returns error

Bug Report

Is you/your team sponsoring this project

  • Yes
  • No

Minimal reproducible repo

app.use(session({
    secret: process.env.SESSION_SECRET || '',
    resave: true,
    saveUninitialized: true,
    cookie: {
      maxAge: 1000 * 86400,
      path: '/',
      signed: true,
      httpOnly: true,
      secure: process.env.NODE_ENV === 'production',
      sameSite: process.env.NODE_ENV === 'production',
    },
  }));

Current Behavior

TypeError: res._implicitHeader is not a function

Expected behavior/code

Session details without error

Environment

  • Node/npm version: Node 16.13.1/NPM 8.3.0
  • OS: Debian 11

@nanoexpress/middleware-schemator esModule import on cjs

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

https://github.com/nanoexpress/middlewares/tree/master/packages/schemator

Current Behavior

const schemator = require('@nanoexpress/middleware-schemator/cjs');

got an error message:

Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: D:\febryan\www\mindtrex-executive-microservice\node_modules\@nanoexpress\middleware-static-serve\static.es.js
require() of ES modules is not supported.
require() of D:\febryan\www\mindtrex-executive-microservice\node_modules\@nanoexpress\middleware-static-serve\static.es.js from D:\febryan\www\mindtrex-executive-microservice\node_modules\@nan
oexpress\middleware-schemator\cjs\schemator.cjs.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES mo
dules.
Instead rename static.es.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from D:\febryan\www\mindtrex-executive-microservice\node_modules\@nanoexpress\
middleware-static-serve\package.json.
     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1085:13)
     at Module.load (internal/modules/cjs/loader.js:933:32)
     at Function.Module._load (internal/modules/cjs/loader.js:774:14)
     at Module.require (internal/modules/cjs/loader.js:957:19)
     at Module.Hook._require.Module.require (D:\febryan\www\mindtrex-executive-microservice\node_modules\require-in-the-middle\index.js:80:39)
     at require (internal/modules/cjs/helpers.js:88:18)
     at Object.<anonymous> (D:\febryan\www\mindtrex-executive-microservice\node_modules\@nanoexpress\middleware-schemator\cjs\schemator.cjs.js:3:19)
     at Module._compile (internal/modules/cjs/loader.js:1068:30)
     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1097:10)
     at Module.load (internal/modules/cjs/loader.js:933:32) {
   code: 'ERR_REQUIRE_ESM'
 }

Expected behavior/code

not getting error exception ERR_REQUIRE_ESM.

Environment

  • Node/npm version: 14.17.0 / 7.15.0
  • OS: Windows 10 Home
  • Addinational Info: @nanoexpress/middleware-schemator:3.0.5

Possible Solution

  • Create another format using CommonJS, but it's wasting time
  • Add environment variables to determine source code when rollup compiling to CommonJS

Pull Request #23

Additional context/Screenshots

image
image

Note

  • already tested on local using esModule import and CommonJS

Body parser not working

Bug Report

Is you/your team sponsoring this project

  • Yes
  • No

Minimal reproducible repo

import bodyParser from '@nanoexpress/middleware-body-parser';
app.use(bodyParser({ json: true, urlEncoded: true }));

Current Behavior

TSError: ⨯ Unable to compile TypeScript
 error TS2769: No overload matches this call.

Expected behavior/code

load body parser without error

Environment

  • Node/npm version: Node 16.13.1/Npm 8.3
  • OS:debian 11

@nanoexpress/middleware-static not give an response if file not found

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

https://github.com/nanoexpress/middlewares

Current Behavior

HTTP request got pending because server not return an response.

Expected behavior/code

HTTP requeset got an response HTTP status code 404 for file not found.

Environment

  • Node/npm version: 14.17.0 / 7.15.0
  • OS: Windows 10 Home
  • Addinational Info: @nanoexpress/middleware-schemator:>=3.0.5, @nanoexpress/middleware-static:1.0.3

Possible Solution

Issue #24 comment-893676670

Additional context/Screenshots

Conversation discussion at Issue #24 comment-892647304, Issue #24 comment-893634574, Issue #24 comment-893676670

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

[Security Bug]: CVE GHSA-ff7x-qrg7-qggm

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

GHSA-ff7x-qrg7-qggm

Current Behavior

GHSA-ff7x-qrg7-qggm

Expected behavior/code

No CVE or security issue should be

Environment

  • Node/npm version: All
  • OS: All
  • Addinational Info: type here

Possible Solution

Wait to lerna fix this this issue as this project depends to lerna

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/middleware-schemator error serve swagger

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

https://github.com/nanoexpress/middlewares

Current Behavior

  1. Issue #24 comment-892607148
  2. Issue #24 comment-892688684

Expected behavior/code

  1. Static serve module executed
  2. Variable config can be accessed

Environment

  • Node/npm version: 14.17.0 / 7.15.0
  • OS: Windows 10
  • Addinational Info: @nanoexpress/middleware-schemator:>=3.0.5

Possible Solution

Pull Request #34

  1. game5413@9214498
  2. game5413@1ee3733

Additional context/Screenshots

Reference conversation from comment this to this.

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

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.