New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

kocoon

Package Overview
Dependencies
Maintainers
0
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

kocoon

Build fullstack apps, powered by ExpressJS/React

latest
Source
npmnpm
Version
0.6.70
Version published
Maintainers
0
Created
Source

Rumbo

Rumbo allows you to build fullstack app with Express and React in NodeJS, inspired by NextJS.

This library will automatically resolve paths for your apps, so you don't have to register paths with Express on the server, or with React Router for the client.

Have a look at Rumbo Typescript Template for an example to use Rambo with Typescript

Supported:

  • Basic methods: GET, POST, PATH, OPTIONS, DELETE
  • Middleware using _middleware
  • Nested routes

Example folder structure

src
├── apps
│   ├── api
│   │   ├── _middleware.ts
│   │   ├── index.ts // or get.ts
│   │   │── post.ts
│   │   │── users
│   │       ├── index.ts
│   ├── client
│   │   ├── _layout.ts
│   │   ├── index.ts
│   │   │── users
│   │       ├── index.ts
├── dev.ts
├── index.ts
├── rumboConfigs.ts

Rumbo configs

import path from "path";
import { RumboProps } from "rumbo";

const rumboConfigs: RumboProps = {
  debug: true,
  rootDir: __dirname,
  listen: {
    port: parseInt(process.env.PORT || "3000"),
    host: process.env.HOST || "localhost"
  },
  routes: {
    "/": {
      type: "client-ssr",
      location: path.join(__dirname, "routes/client"),
    },
    "/api": {
      type: "server",
      location: path.join(__dirname, "routes/api"),
      excludePaths: ["includes"]
    },
  },
  // must specify for generating files in runtime
  staticRoutes: null
};

export default rumboConfigs;

Register middleware

// src/app/api/_middleware.ts
import { Request, Response, NextFunction } from "express";

export default function(req: Request, res: Response, next: NextFunction) {
  console.log("/admin/_middleware");
  next()
}

Register GET

// src/app/server/index.ts
import { Request, Response } from "express";

export default function(req: Request, res: Response) {

  res.json({
    message: "ok"
  })
}

Register nested route

// src/app/server/users/index.ts
import { Request, Response } from "express";

export default function(req: Request, res: Response) {
  res.json({
    message: "ok"
  })
}

Register routes

// app.ts
import express from "express";
import rumbo from "rumbo";

import configs from "./rumboConfigs";

const app = express();
rumbo(app, configs);

Keywords

express

FAQs

Package last updated on 10 Sep 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts