Rivet: Node.js HTTP Server Framework

eyedev1 pts0 comments

@igosprojects/rivet - npm

npm

Search<br>Sign UpSign In

@igosprojects/rivet

1.1.0 • Public • Published 4 minutes ago<br>Readme<br>Code Beta<br>0 Dependencies<br>1 Dependents<br>8 Versions<br>Rivet

Rivet is a small Typescript based server platform for NodeJS, it is a Express inspired library for servers

Installing

To install Rivet you will need to have an NPM project setup, if not run the necessary commands.<br>Then you can run this command to install rivet:npm install @igosprojects/rivet

Usage

To use Rivet you first need to install it using your package manager(look at Installing).

Creating a basic server

To create a basic server you will need to initilize Rivet, and start the server. The following code does just that:

import { IncomingMessage } from 'node:http';<br>import { Rivet, RivetResponse } from '@igosprojects/rivet';

const app = new Rivet();

// This function is called when the route "/" is called<br>app.get('/', (req: IncomingMessage, res: RivetResponse) => {<br>res.send("hi!");<br>});

app.start(3000);

Serving static files

Rivet supports serving static files and folders, to do so you can use the app.static function after initilizing the server.<br>For example this code will serve the public directory next to the file:

import { Rivet } from '@igosprojects/rivet';

const app = new Rivet();

app.static("/", "./public");

app.start(3000);

Reading parameters(/:id)

Rivet can read parameters passed on the URL bar, to do that you can use the req.params option for that.<br>To read the parameters you can do: const { paramname } = req.params;, now paramname is equal to the parameter if it was passed in.<br>To register routes with parameters you shouldnt register /users but instead /users/:id otherwise it wont work!

Readme<br>Keywords<br>rivet<br>ts<br>typescript<br>http<br>server<br>framework

Package Sidebar<br>Install<br>npm i @igosprojects/rivet

Repository<br>Gitgithub.com/IgosProjects/rivet

Homepage<br>github.com/IgosProjects/rivet#readme

DownloadsWeekly Downloads<br>269

Version<br>1.1.0

License<br>MIT

Last publish<br>4 minutes ago

Collaborators

igosprojects

Analyze security with SocketCheck bundle size View package health Explore dependencies<br>Report malware

rivet igosprojects server install static parameters

Related Articles