This repository has been archived on 2024-09-15. You can view files and clone it, but cannot push or open issues or pull requests.
neste/README.md
Matheus Sampaio Queiroga 37d2c52a4e
Some checks failed
Teste / Test in node ${{ matrix.node }} (14.x) (push) Successful in 50s
Teste / Test in node ${{ matrix.node }} (15.x) (push) Failing after 37s
Teste / Test in node ${{ matrix.node }} (16.x) (push) Failing after 35s
Teste / Test in node ${{ matrix.node }} (17.x) (push) Failing after 35s
Teste / Test in node ${{ matrix.node }} (18.x) (push) Successful in 41s
Teste / Test in node ${{ matrix.node }} (19.x) (push) Successful in 38s
Teste / Test in node ${{ matrix.node }} (20.x) (push) Successful in 39s
Add next.js middler and Update code
Signed-off-by: Matheus Sampaio Queiroga <srherobrine20@gmail.com>
2023-12-15 22:45:29 -03:00

61 lines
1.6 KiB
Markdown

![npm](https://img.shields.io/npm/dw/neste) [![Teste](https://sirherobrine23.org/utils/neste/actions/workflows/test.yml/badge.svg)](https://sirherobrine23.org/utils/neste/actions/workflows/test.yml)
A fork of [express](https://github.com/expressjs/express) with patches and improvements for new integrations, fixes and more.
```js
import neste from "neste";
const app = neste();
app.get("/", (req, res) => res.send("hello world"));
app.get("/json", (req, res) => res.json({message: "hello world"}));
app.listen(3000, () => {
console.log("Listen on %s", 3000);
});
```
### Example
#### Standalone Nodejs
```js
import neste from "neste";
const app = neste();
app.get("/", (req, res) => res.set("Content-Type", "text/html").send("<p>Hello world</p>"));
const PORT = Number(process.env.PORT || 3000);
app.listen(PORT, () => console.log("Listen on %s", PORT));
```
#### Next.js API Routes
- path: `/[...root].ts`
```js
import { Router } from "Neste";
const app = new Router();
export default app;
app.get("/", (req, res) => res.send(`<p>Hello from root API</p>`));
```
- path: `/form/[...formsSlugs].ts`
```js
import { Router } from "Neste";
const app = new Router({ "app path": "/form" });
export default app;
app.get("/", (req, res) => res.send(`<p>Hello from forms router</p>`));
```
## 3.x notice
version 3.0.0 is removing support for CommonJS, keeping only the ESM module. if you app/module is Commonjs module migrate to ESM or keep on ExpressJS.
## Express middleware's
> **Important**
> as a fork of express will be compatible some, probably some others have stopped in the future.