-
Notifications
You must be signed in to change notification settings - Fork 546
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
63 changed files
with
9,347 additions
and
7,148 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
name: autofix.ci # needed to securely identify the workflow | ||
|
||
on: | ||
pull_request: | ||
push: | ||
branches: [ "main" ] | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
autofix: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- run: corepack enable | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: 16 | ||
cache: "pnpm" | ||
- run: pnpm install | ||
- name: Fix lint issues | ||
run: npm run lint:fix | ||
- uses: autofix-ci/action@40f4f7bccdde208056784fa907921be767412c5f |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,9 +19,9 @@ package-lock.json | |
# Generated dirs | ||
dist | ||
.nuxt | ||
.nuxt-* | ||
.output | ||
.gen | ||
.tmp | ||
nuxt.d.ts | ||
|
||
# Junit reports | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
*.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,103 +1,38 @@ | ||
[![npm version][npm-version-src]][npm-version-href] | ||
[![npm downloads][npm-downloads-src]][npm-downloads-href] | ||
[![npm-edge version][npm-edge-version-src]][npm-edge-version-href] | ||
[![npm-edge downloads][npm-edge-downloads-src]][npm-edge-downloads-href] | ||
|
||
<!-- [![GitHub Actions][github-actions-src]][github-actions-href] [![Codecov][codecov-src]][codecov-href] --> | ||
|
||
<h1 align="center">⚗️ Nitro</h1> | ||
<p align="center">Build and Deploy Universal JavaScript Servers</p> | ||
|
||
## Why use Nitro? | ||
|
||
Nitro provides a powerful toolchain and a runtime framework from the [UnJS](https://github.com/unjs) ecosystem to build and deploy **any JavaScript server, anywhere!** | ||
|
||
❯ 🐇 **Rapid development** experience with hot module replacement <br> | ||
❯ 😌 **Multi-provider** deployments with a single codebase and zero-configuration<br> | ||
❯ 💼 **Portable and compact** deployments without `node_modules` dependency <br> | ||
❯ 📁 **Directory structure** aware to register API routes and more with zero configuration <br> | ||
❯ 🤏 **Minimal Design** to fit into any solution with minimum overhead <br> | ||
❯ 🚀 **Code-splitting** and async chunk loading for fast server startup time <br> | ||
❯ 👕 **TypeScript** fully supported <br> | ||
❯ 💾 **Multi-driver storage** and caching layer <br> | ||
❯ 💰 **Route caching** and static **pre-rendering** with built-in crawler <br> | ||
❯ 🐱 **Hackable** to extend almost any part of nitro using options <br> | ||
❯ ✨ **Auto imports** for lazy folks and a tidy minimal codebase <br> | ||
❯ 🏛️ **Best-effort compatibility** for using legacy npm packages and mocking Node.js modules <br> | ||
|
||
## Who is using Nitro? | ||
|
||
[Nuxt 3](https://v3.nuxtjs.org/guide/concepts/server-engine) is using Nitro as its server engine. | ||
|
||
<br> | ||
<hr> | ||
<h3><a href="https://nitro.unjs.io">📖 Documentation</a></h3> | ||
<h3><a href="https://github.com/unjs/nitro/blob/main/CHANGELOG.md">✍️ Changelog</a></h3> | ||
<h3><a href="https://stackblitz.com/github/unjs/nitro/tree/main/examples/hello-world">🏀 Online playground</a></h3> | ||
<hr> | ||
<br> | ||
|
||
<h2 align="center">😺 Quick Start</h2> | ||
|
||
0️⃣ Create an empty directory `nitro-app` | ||
|
||
```bash | ||
mkdir nitro-app | ||
cd nitro-app | ||
``` | ||
|
||
1️⃣ Create `routes/index.ts`: | ||
|
||
```ts [routes/index.ts] | ||
export default defineEventHandler(() => "nitro is amazing!"); | ||
``` | ||
|
||
2️⃣ Start development server: | ||
|
||
```bash | ||
npx nitropack dev | ||
``` | ||
|
||
🪄 Your API is ready at `http://localhost:3000/` | ||
|
||
Check `.nitro/dev/index.mjs` if want to know what is happening | ||
|
||
3️⃣ You can now build your production-ready server: | ||
|
||
```bash | ||
npx nitropack build | ||
``` | ||
|
||
4️⃣ Output is in the `.output` directory and ready to be deployed on almost any VPS with no dependencies. You can locally try it too: | ||
|
||
```bash | ||
node .output/server/index.mjs | ||
``` | ||
|
||
That's it you got it! Read the [documentation](https://nitro.unjs.io) to learn more. | ||
|
||
<hr> | ||
<h3 align="center">🌱 nitro is young and under development</h3> | ||
|
||
Check [🐛 open issues](https://github.com/unjs/nitro/issues) for the known issues and roadmap and tell us [💡your ideas](https://github.com/unjs/nitro/discussions/new)! | ||
|
||
<hr> | ||
<p align="center"> | ||
<a href="https://nitro.unjs.io" target="_blank" rel="noopener noreferrer"> | ||
<img width="180" src="./docs/public/nitro.svg" alt="Nitro logo"> | ||
</a> | ||
</p> | ||
<p align="center"> | ||
<a href="https://npmjs.com/package/nitropack"><img src="https://img.shields.io/npm/v/nitropack?style=flat&colorA=18181B&colorB=d8c449" alt="npm version"></a> | ||
<a href="https://npmjs.com/package/nitropack"><img src="https://img.shields.io/npm/dm/nitropack?style=flat&colorA=18181B&colorB=d8c449" alt="npm downloads"></a> | ||
<a href="https://github.com/unjs/nitro/blob/main/LICENSE"><img src="https://img.shields.io/github/license/unjs/nitro.svg?style=flat&colorA=18181B&colorB=d8c449" alt="License"></a> | ||
</p> | ||
<br/> | ||
|
||
# Nitro | ||
|
||
> Build and deploy universal web servers | ||
> The open engine powering [Nuxt](https://nuxt.com) and [open to everyone](https://github.com/unjs/nitro/discussions/1015). | ||
- 🐇 Rapid development with HMR | ||
- 😌 Provider agnostic deployments with 15+ built-in presets | ||
- 💼 Portable and compact output | ||
- 📁 Directory structure conventions | ||
- 🤏 Minimal design | ||
- 🚀 Code-splitting | ||
- 👕 TypeScript support | ||
- 💾 Universal storage | ||
- 💰 Route caching | ||
- 🐱 Hackable | ||
- ✨ Auto Imports | ||
|
||
📖 Read [the documentation](https://nitro.unjs.io) to learn more or directly jump to the [getting started](https://nitro.unjs.io/guide/introduction/getting-started). | ||
|
||
## Contribution | ||
|
||
See [contribution guide](https://nitro.unjs.io/guide/community/contribution). | ||
|
||
## License | ||
|
||
Made with 💛 Published under [MIT](./LICENSE). | ||
|
||
<!-- Badges --> | ||
|
||
[npm-version-src]: https://flat.badgen.net/npm/v/nitropack?style=flat-square&label=stable | ||
[npm-version-href]: https://npmjs.com/package/nitropack | ||
[npm-downloads-src]: https://flat.badgen.net/npm/dm/nitropack?style=flat-square&label=stable | ||
[npm-downloads-href]: https://npmjs.com/package/nitropack | ||
[npm-edge-version-src]: https://flat.badgen.net/npm/v/nitropack-edge?style=flat-square&label=edge | ||
[npm-edge-version-href]: https://npmjs.com/package/nitropack-edge | ||
[npm-edge-downloads-src]: https://flat.badgen.net/npm/dm/nitropack-edge?style=flat-square&label=edge | ||
[npm-edge-downloads-href]: https://npmjs.com/package/nitropack-edge | ||
[github-actions-src]: https://flat.badgen.net/github/status/unjs/nitro?style=flat-square | ||
[github-actions-href]: https://github.com/unjs/nitro/actions?query=workflow%3Aci | ||
[codecov-src]: https://flat.badgen.net/codecov/c/gh/unjs/nitro/main?style=flat-square | ||
[codecov-href]: https://codecov.io/gh/unjs/nitro | ||
Made with 💛 Published under the [MIT](./LICENSE) license. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
shamefully-hoist=true | ||
strict-peer-dependencies=false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,40 @@ | ||
export default defineAppConfig({ | ||
docus: { | ||
title: '⚗️ Nitro', | ||
title: "Nitro", | ||
header: { | ||
title: false, | ||
logo: true | ||
logo: true, | ||
}, | ||
description: 'Build and Deploy Universal JavaScript Servers.', | ||
url: 'https://nitro.unjs.io', | ||
image: '/cover.png', | ||
description: "Build and Deploy Universal JavaScript Servers.", | ||
url: "https://nitro.unjs.io", | ||
image: "/cover.png", | ||
socials: { | ||
twitter: 'unjsio', | ||
github: 'unjs/nitro' | ||
twitter: "unjsio", | ||
github: "unjs/nitro", | ||
}, | ||
github: { | ||
owner: 'unjs', | ||
repo: 'nitro', | ||
branch: 'main', | ||
dir: 'docs/content', | ||
edit: true | ||
owner: "unjs", | ||
repo: "nitro", | ||
branch: "main", | ||
dir: "docs/content", | ||
edit: true, | ||
}, | ||
aside: { | ||
level: 1 | ||
level: 1, | ||
}, | ||
footer: { | ||
credits: { | ||
icon: '', | ||
text: 'Made with 💛', | ||
href: 'https://github.com/unjs/nitro' | ||
icon: "", | ||
text: "Made with 💛", | ||
href: "https://github.com/unjs/nitro", | ||
}, | ||
icons: [] | ||
} | ||
} | ||
}) | ||
iconLinks: [ | ||
{ | ||
href: "https://unjs.io", | ||
icon: "vscode-icons:file-type-js-official", | ||
label: "UnJS", | ||
}, | ||
], | ||
}, | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
<template> | ||
<span style="overflow: hidden;"> | ||
⚗️ Nitro | ||
<span style="overflow: hidden"> | ||
<img width="30" src="/nitro.svg" alt="Nitro Logo" style="display: inline" /> | ||
Nitro | ||
</span> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,57 +1,80 @@ | ||
# Getting Started | ||
# Getting Started | ||
|
||
Let's create a new Nitro app in few steps. | ||
|
||
## Play online | ||
## Play Online | ||
|
||
:button-link[Play on Stackblitz]{href="https://stackblitz.com/github/unjs/nitro/tree/main/examples/hello-world" icon="simple-icons:stackblitz" blank} | ||
:button-link[Open on Stackblitz]{href="https://stackblitz.com/github/unjs/nitro/tree/main/examples/hello-world" icon="simple-icons:stackblitz" blank style="margin-right: 10px;margin-bottom:10px;"} | ||
:button-link[Open on CodeSandox]{href="https://codesandbox.io/p/sandbox/nitro-template-5jssbm" icon="simple-icons:codesandbox" blank} | ||
|
||
## Create locally | ||
## Starter Template | ||
|
||
Create an empty directory `nitro-app` | ||
Before getting started, please make sure you have installed the recommended setup: | ||
|
||
```bash | ||
mkdir nitro-app | ||
cd nitro-app | ||
* **Node.js**<sup>*</sup> (latest LTS version) 👉 [[Download](https://nodejs.org/en/download/)] | ||
* **Visual Studio Code** [[Download](https://code.visualstudio.com/)] | ||
* [corepack](https://nodejs.org/api/corepack.html) for using pnpm and yarn. 👉 Run `corepack enable` | ||
|
||
Create a new project using starter template: | ||
|
||
::code-group | ||
|
||
```bash [npx] | ||
npx giget@latest nitro nitro-app | ||
``` | ||
|
||
Create `routes/index.ts`: | ||
```bash [pnpm] | ||
pnpm dlx giget@latest nitro nitro-app | ||
``` | ||
|
||
```ts [routes/index.ts] | ||
export default defineEventHandler(() => 'nitro is amazing!') | ||
:: | ||
|
||
```sh | ||
cd nitro-app | ||
``` | ||
|
||
Start development server: | ||
Install the dependencies: | ||
|
||
```bash | ||
npx nitropack dev | ||
::code-group | ||
|
||
```bash [npm] | ||
npm install | ||
``` | ||
|
||
🪄 Your API is ready at `http://localhost:3000/` | ||
```bash [yarn] | ||
yarn install | ||
``` | ||
|
||
**Tip:** Check `.nitro/dev/index.mjs` if want to know what is happening | ||
```bash [pnpm] | ||
pnpm install | ||
``` | ||
|
||
You can now build your production-ready server: | ||
:: | ||
|
||
```bash | ||
npx nitropack build | ||
```` | ||
|
||
Output is in the `.output` directory and ready to be deployed on almost any VPS with no dependencies. You can locally try it too: | ||
Start the development server: | ||
|
||
```bash | ||
node .output/server/index.mjs | ||
npm run dev | ||
``` | ||
|
||
You can add `nitropack` using your package manager now: | ||
🪄 Your API is ready at `http://localhost:3000/` | ||
|
||
::alert | ||
Check `.nitro/dev/index.mjs` if want to know what is happening | ||
:: | ||
|
||
Build your production-ready server: | ||
|
||
```bash | ||
# npm | ||
npm i -D nitropack | ||
npm run build | ||
```` | ||
|
||
Output is in the `.output` directory and ready to be deployed on almost any provider with no dependencies. | ||
|
||
# yarn | ||
yarn add -D nitropack | ||
You can try it locally with: | ||
|
||
# pnpm | ||
pnpm i -D nitropack | ||
```bash | ||
npm run preview | ||
``` | ||
|
Oops, something went wrong.