squashjs

0.0.5 • Public • Published

Squash · npm version

Squash is a TypeScript library for building backend services.

  • Declarative: Declarative components make your code more predictable, simpler to understand, and easier to debug.
  • Component-Based: Build encapsulated components that manage their own routing, being provided the handlers.
  • Separation of concerns: Inspired by React, each component represents a separation of your applications concerns, not the technology, moving away from having handlers, controllers, etc folders in your project.

Installation

  • npm install squashjs
  • yarn add squashjs

Examples

There is a complex example with middlewares in example.ts. Here is a simple one to get you started:

import { createApp, createComponent } from "squashjs";
const userComponent = createComponent({
  prefix: "/api/v1",
  routes: [
    {
      method: "GET",
      path: "/user",
      handler: (req, res) => res.json("happy person :)"),
    }
  ],
});

const app = createApp({ port: 8080, components: [userComponent] });
app.run();

This example will serve a route at /api/v1/user which returns "happy person :)", on port 8080.

Readme

Keywords

none

Package Sidebar

Install

npm i squashjs

Weekly Downloads

1

Version

0.0.5

License

ISC

Unpacked Size

17.2 kB

Total Files

6

Last publish

Collaborators

  • aimenhamed