npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-express-fiber

v1.0.0

Published

Using react write JSX to decleratively (and dynamically 😲) construct an express application

Downloads

6

Readme

react-express-fiber

Using react write JSX to decleratively (and dynamically 😲) construct an express application

⚠ Note: this is a working proof of concept, while structurally it makes sense to look at express applications in a ree-like structure, and declaring it in JSX seems really convenient, there is more power in using something like tRPC (or my library eproxe) to reduce client sided boiler plate, we can still levarage superpowers we are familiar with from react tho! see kontext/express

I will not continue development on this as i got it to a working state, and I dont see a valid reason to use this, it was fun writing this and learning about the react-reconciler tho

Current issues which might be related to the design which annoy me:

  • No simple way to maintain context syntax inside requests using kontext, kontext imitates React hooks' look and feel, but will cause confusion in this scenario, as they will either encourage users to break rules of hooks (because they do not need to follow it) or be used while not inside a request and vice versa (there are now two different context types, one for React while constructing elements, and one for Node while passing requests through the handler stack)

Example

import React, { useState } from 'react';
import express from 'express';

import { render, settings } from 'react-express-fiber';

import send from './handlet/send';

settings.mergeParams = true;

const ExpressApp = () => {
	const [enabled, setEnabled] = useState(false);

	return (
		<route>
			<route path='*.ts'>
				<x-get handler={send((req) => req.baseUrl)} />
			</route>
			<route path='/users'>
				<x-get handler={send('hello get')} />
				<x-post handler={send('hello post')} />
				<x-put handler={send('hello put')} />
				<x-delete handler={send('hello delete')} />

				<x-get
					path='/enable'
					handler={send(() => {
						setEnabled(true);
						return 'enabled!😎';
					})}
				/>
				<x-get
					path='/disable'
					handler={send(() => {
						setEnabled(false);
						return 'disabled!🤐';
					})}
				/>

				{enabled && (
					<route path='/:uuid'>
						<x-get h={send('Not trapped!!🍹')} />

						<route path='/:id'>
							<x-get
								h={send((req) => {
									console.log(req.params);
									console.log(req.baseUrl);

									return `hello id: ${req.params.uuid}/${req.params.id}`;
								})}
							/>
						</route>
					</route>
				)}

				<x-get path='/*' h={send('Its a trap!')} />
			</route>
		</route>
	);
};

const app = express();

render(<ExpressApp />, app);

const PORT = 3000;

app.listen(PORT, () => {
	console.log(`react-express-fiber is running on port ${PORT}`);
});