Giter Club home page Giter Club logo

nitro's Introduction

Nitro

npm version npm downloads

Create web servers that run anywhere! ๐Ÿ“– documentation

Contribution

Local development
  • Clone this repository
  • Install the latest LTS version of Node.js
  • Enable Corepack using corepack enable
  • Install dependencies using pnpm install
  • Run tests using pnpm dev or pnpm test

License

Published under the MIT license. Made by @pi0 and community ๐Ÿ’›


๐Ÿค– auto updated with automd

nitro's People

Contributors

antfu avatar ascorbic avatar atinux avatar barbapapazes avatar clarkdo avatar damianglowala avatar danielroe avatar dargmuesli avatar dario-piotrowicz avatar didavid61202 avatar farnabaz avatar harlan-zw avatar hebilicious avatar higherorderlogic avatar huang-julien avatar kwarkjes avatar luc122c avatar mahdiboomeri avatar mannil avatar markthree avatar minidigger avatar moshetanzer avatar noook avatar pi0 avatar quiibz avatar renovate[bot] avatar siegerts avatar smaeda-ks avatar tobiasdiez avatar yassilah 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nitro's Issues

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Awaiting Schedule

These updates are awaiting their schedule. Click on a checkbox to get an update now.

  • chore(deps): update all non-major dependencies (@cloudflare/workers-types, @scalar/api-reference, miniflare, node, pnpm, undici)

Ignored or Blocked

These are blocked by an existing closed PR and will not be recreated unless you click a checkbox below.

Detected dependencies

bun
docs/package.json
  • undocs ^0.2.21
devcontainer
.devcontainer/devcontainer.json
  • node 20.13.1
github-actions
.github/workflows/autofix.yml
  • actions/checkout v4
  • actions/setup-node v4
  • autofix-ci/action ea32e3a12414e6d3183163c3424a7d7a8631ad84
.github/workflows/ci.yml
  • actions/checkout v4
  • actions/setup-node v4
  • actions/checkout v4
  • actions/setup-node v4
  • oven-sh/setup-bun v1
npm
package.json
  • @cloudflare/kv-asset-handler ^0.3.2
  • @netlify/functions ^2.7.0
  • @rollup/plugin-alias ^5.1.0
  • @rollup/plugin-commonjs ^25.0.8
  • @rollup/plugin-inject ^5.0.5
  • @rollup/plugin-json ^6.1.0
  • @rollup/plugin-node-resolve ^15.2.3
  • @rollup/plugin-replace ^5.0.5
  • @rollup/plugin-terser ^0.4.4
  • @rollup/pluginutils ^5.1.0
  • @types/http-proxy ^1.17.14
  • @vercel/nft ^0.27.1
  • archiver ^7.0.1
  • c12 ^1.10.0
  • chalk ^5.3.0
  • chokidar ^3.6.0
  • citty ^0.1.6
  • confbox ^0.1.7
  • consola ^3.2.3
  • cookie-es ^1.1.0
  • croner ^8.0.2
  • crossws ^0.2.4
  • db0 ^0.1.4
  • defu ^6.1.4
  • destr ^2.0.3
  • dot-prop ^9.0.0
  • esbuild ^0.21.4
  • escape-string-regexp ^5.0.0
  • etag ^1.8.1
  • fs-extra ^11.2.0
  • globby ^14.0.1
  • gzip-size ^7.0.0
  • h3 ^1.11.1
  • hookable ^5.5.3
  • httpxy ^0.1.5
  • ioredis ^5.4.1
  • is-primitive ^3.0.1
  • jiti ^1.21.0
  • klona ^2.0.6
  • knitwork ^1.1.0
  • listhen ^1.7.2
  • magic-string ^0.30.10
  • mime ^4.0.3
  • mlly ^1.7.0
  • mri ^1.2.0
  • node-fetch-native ^1.6.4
  • ofetch ^1.3.4
  • ohash ^1.1.3
  • openapi-typescript ^6.7.6
  • pathe ^1.1.2
  • perfect-debounce ^1.0.0
  • pkg-types ^1.1.1
  • pretty-bytes ^6.1.1
  • radix3 ^1.1.2
  • rollup ^4.18.0
  • rollup-plugin-visualizer ^5.12.0
  • scule ^1.3.0
  • semver ^7.6.2
  • serve-placeholder ^2.0.1
  • serve-static ^1.15.0
  • std-env ^3.7.0
  • ufo ^1.5.3
  • uncrypto ^0.1.3
  • unctx ^2.3.1
  • unenv ^1.9.0
  • unimport ^3.7.2
  • unstorage ^1.10.2
  • untyped ^1.4.2
  • unwasm ^0.3.9
  • @azure/functions ^3.5.1
  • @azure/static-web-apps-cli ^1.1.8
  • @biomejs/biome 1.7.3
  • @cloudflare/workers-types ^4.20240512.0
  • @deno/types ^0.0.1
  • @scalar/api-reference ^1.22.51
  • @types/archiver ^6.0.2
  • @types/aws-lambda ^8.10.138
  • @types/bun ^1.1.3
  • @types/estree ^1.0.5
  • @types/etag ^1.8.3
  • @types/fs-extra ^11.0.4
  • @types/node-fetch ^2.6.11
  • @types/semver ^7.5.8
  • @types/serve-static ^1.15.7
  • @types/xml2js ^0.4.14
  • @vitest/coverage-v8 ^1.6.0
  • automd ^0.3.7
  • better-sqlite3 ^11.0.0
  • changelogen ^0.5.5
  • edge-runtime ^2.5.10
  • eslint ^9.3.0
  • eslint-config-unjs 0.3.1
  • execa ^9.1.0
  • expect-type ^0.19.0
  • firebase-admin ^12.1.1
  • firebase-functions ^4.9.0
  • get-port-please ^3.1.2
  • miniflare ^3.20240512.0
  • prettier ^3.2.5
  • typescript ^5.4.5
  • unbuild ^2.0.0
  • undici ^6.18.1
  • vitest ^1.6.0
  • xml2js ^0.6.2
  • xml2js ^0.6.2
  • node ^16.11.0 || >=17.0.0
  • undici ^6.18.0
  • pnpm 9.1.2

  • Check this box to trigger a request for Renovate to run again on this repository

CommonJS error when trying to `import { Pool } from 'pg'`

Environment

NodeJS version : 14.16.2
Nitropack : 0.2.2

Reproduction

  • Install the library "pg" (e.g : npm i pg)
  • Use import { Pool } from 'pg' in a route

Describe the bug

I have a problem when trying to import Pool from 'pg', a postgres library to connect to a postgres database.

I get the following error :

SyntaxError: Named export 'Pool' not found. The requested module 'file:///project_root/node_modules/.pnpm/[email protected]/node_modules/pg/lib/index.js' is a CommonJS module, which may not support all module.exports as named exports.

Nitro then make the recommandation to use use the default export, however it still doesn't work, I get a typescript error : Module pg has no default export.

Is there a way to get around the problem ? If no do you know any esm library for postgres ?

Additional context

No response

Logs

No response

Images are incorrectly encoded after Azure Functions Deployment

When deploying a Nitro app with the azure-functions preset, static Images such as .pngs and .jpgs are rendered incorrectly. (They are converted to string, which messes with their encoding.)

Issues to check:

  • is this a limitation of azure functions? (not serving binary files)
  • could this be resolved with something similar to #96?

context: nuxt/nuxt#12677

`prerender:` hooks

nuxt/nuxt#11786

Most importantly prerender:route hook which can be useful to modify and inspect pretender results. (eg: for service-worker to inject it's script)

Make provider dependencies optional

Currently, we have some small dependencies that are only usable for some presets:

  • @cloudflare/kv-asset-handler
  • @netlify/functions
  • archiver (for azure)

Their install size overhead is very small (3.4M non-shared!) but this can be a problem if we are more presets that require such dependencies. Currently we do not include any cli and suggest using npx for tools such as wrangler and miniflare

Once we had the ability to auto-install deps, we can come back to this as check cons/pros.

Also related: nuxt/nuxt#13166

Support sending stream

h3 support: unjs/h3#68 is landed for Node.js compatible environments.

We might need to improve unenv mocks as well to universally make stream support available.

Currently waiting for h3 Event API to be completed and especially with Event class we can leverage native web API for sending streams.

Inspector

List all possible API routes as / or /_nitro and another runtime state of nitro. This can be initially implemented as a devserver feature.

[bug] building for cloudflare uses too much memory

Environment

node --version
v16.14.2

Reproduction

https://github.com/X7md/nitropack-test

git clone https://github.com/X7md/nitropack-test
cd nitropack-test
npm install
# there is npm pkg @imagemagick/magick-wasm 

Describe the bug

Try to build using NITRO_PRESET=cloudflare npx nitropack build, but I got this error

image

Additional context

No response

Logs

<--- Last few GCs --->

[35531:0x5f79840]    15787 ms: Scavenge 2030.8 (2065.6) -> 2028.6 (2066.1) MB, 3.6 / 0.0 ms  (average mu = 0.118, current mu = 0.110) allocation failure 
[35531:0x5f79840]    15794 ms: Scavenge 2031.3 (2066.1) -> 2029.5 (2067.3) MB, 4.6 / 0.0 ms  (average mu = 0.118, current mu = 0.110) allocation failure 
[35531:0x5f79840]    15801 ms: Scavenge 2032.4 (2067.3) -> 2030.4 (2076.3) MB, 4.5 / 0.0 ms  (average mu = 0.118, current mu = 0.110) allocation failure 


<--- JS stacktrace --->

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
 1: 0xb09980 node::Abort() [node]
 2: 0xa1c235 node::FatalError(char const*, char const*) [node]
 3: 0xcf784e v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [node]
 4: 0xcf7bc7 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [node]
 5: 0xeaf465  [node]
 6: 0xeaff46  [node]
 7: 0xebe46e  [node]
 8: 0xebeeb0 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [node]
 9: 0xec1da5 v8::internal::Heap::HandleGCRequest() [node]
10: 0xe4f447 v8::internal::StackGuard::HandleInterrupts() [node]
11: 0x11fb805 v8::internal::Runtime_StackGuard(int, unsigned long*, v8::internal::Isolate*) [node]
12: 0x15f0b19  [node]
Aborted (core dumped)```

layer0 preset

Refs:

TODO:

  • Move POC as a published preset
  • Add deployment guide (@tristanlee85)

Improvements:

  • Use direct builder/core API instead of invoking CLI
  • Layer0 config
    • Option to set layer0 core/cli version
    • Pin used version on first build to .nitrorc
  • Map route rules <> Layer0 router
    • Any reference for JSON format instead of routes.js?
  • Map Proxy support (#113) <> Layer0 backends

improve heroku preset

heroku is very customisable but mostly this is done with buildpacks. Here's the node one.

By default the node buildpack will build, prune dev dependencies + package the entire app folder into a docker image. This is lots more space than Nitro needs. Options:

  1. create our own heroku buildpack
  2. create docker image (which can be shared with other platforms): #54

If you use the default heroku buildpack, you'll need to run heroku config:set HOST=0.0.0.0

[proxy] socket hang up

Environment

NodeJS: 17.19.0
@nuxt/nitro@npm:@nuxt/[email protected]
@nuxt/[email protected]

Reproduction

https://github.com/devind-team/eleden

But its not easy, because it need server.

Describe the bug

This error is related to sockets, when on the client I establish a connection with the server via apollo-subscription.

In console I get:
image
And the page hangs in an endless reload.

And client does not set cookie. Before, on nuxt 2.5 it worked good.
image

Additional context

I use apollo subscription.

Logs

No response

preset creation guide

A quick guide in advanced section about preset creation probably and ideally an starter template for POC.

Adding a contribution guide also for steps.

  • The issue to ask for preset and platform requirements
  • POC with a nitro starter template
  • PR with always a named preset and docs section

render.com preset

Looks like render.com does not have a separate setup for serverless/edge rendering: https://render.com/docs/web-services.

Setting up render was super-simple, and took only 30 sec. or so from creating an account to connecting the repository. This may just be a documentation task. (It deploys as a node server within a docker container.)

cc: @Atinux

server lifecycle timing

nuxt/nuxt#11428

@danielroe we have server timings for loading chunks but would be nice to know (particularly where we are performing internal $fetch) what the timings for each handler are

Context and how-to are not really clear to me at the moment but we might benefit from more nitro lifecycle hooks to make such a thing possible.

Related unjs/hookable#37

Hint prerender crawler with http headers

While generating pages, the crawler scans for href="" links (filtering for local and without extension) This is the most straightforward way. We can allow the runtime to hint crawler with HTTP headers to crawl more with a header like X-Nitro-Prerender: link1, link2, ... (the alternative is using standardLink: header with prefetch strategy to infer this)

digital ocean preset

Usage notes/documentation:

  1. Need to add engines.node version to package.json (docs)
  2. set HOST to 0.0.0.0

also supports docker images: #54

project fails to import uuid package

Environment

Operating System: Linux
Node Version: v17.1.0
Nuxt Version: 3.0.0-27319101.3e82f0f
Package Manager: [email protected]
Bundler: Vite
User Config: -
Runtime Modules: -
Build Modules: -

Reproduction

  1. Add server/api/test.ts
import { v4 } from "uuid";

export default () => {
  return v4();
};

Describe the bug

Building the project causes the package uuid to fail to be imported. The problem does not exist when running the dev server.

Cannot find module '/home/me/dev/nuxt3-app/.output/server/node_modules/uuid/wrapper.mjs' imported from /home/me/dev/nuxt3-app/.output/server/chunks/test.mjs
  at new NodeError (node:internal/errors:371:5)  
  at finalizeResolution (node:internal/modules/esm/resolve:394:11)  
  at moduleResolve (node:internal/modules/esm/resolve:915:10)  
  at defaultResolve (node:internal/modules/esm/resolve:1005:11)  
  at ESMLoader.resolve (node:internal/modules/esm/loader:475:30)  
  at ESMLoader.getModuleJob (node:internal/modules/esm/loader:245:18)  
  at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:79:40)  
  at link (node:internal/modules/esm/module_job:78:36)

Additional context

Moved from nuxt/nuxt#13040

Logs

No response

use chunks for service-worker target

nuxt/nuxt#11779

We can use renderDynamicImport (todo) to load async chunks for server-worker target instead of using one chunk with either fetch+eval or importScripts. This will allow us deploying a real world app (like docus transformers) to static hosting without huge startup time.

Alternative: We can also use experimental ES worker modules (blog) but I think last time there was a chrome only support for this and firefox was unable

swagger API

expose swagger compatible API from dev server based on handler defenitions.

Serve assets with compression

Environment

  • Operating System: macOS
  • Node Version: v16.14.0
  • Nitro Version: 0.2.1
  • Package Manager: [email protected]

Reproduction

n/a

Describe the bug

It would be a nice addition to nitro if there is be a possibility to change the response of static assets. Then it would also be possible to implement content encoding like brotli or gzip.

Additional context

There does exist a discussion in the nuxt repo. https://github.com/nuxt/framework/discussions/3472

In addition to the discussion i already found the corresponding lines, which i changed in nuxt, in the nitro package:

https://github.com/unjs/nitro/blob/main/src/runtime/static.ts#L68
https://github.com/unjs/nitro/blob/main/src/rollup/plugins/public-assets.ts#L44

Logs

No response

Update 21.07.2022

I wrote a module which can handle the compression https://github.com/exreplay/nuxt-compression. This is still no official way and messes with the internal nitro code but there is no need to use patches.

docker preset

Built with node and a minimal generated docker image:

  • Default: Only generate Dockerfile
  • Build option provided: Try to also build an image using the local docker client CLI (alternative would be a JS client but is too much hassle)
  • Compose option provided: Generate basic docker-compose
  • Registry option provided: Also push to the register

Note: It might improve heroku preset as well (#49)

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.