@minimajs/server

0.1.2 • Public • Published

Introducing the groundbreaking HTTP framework for Node.js - an innovation tailored for the modern developer seeking efficiency, elegance, and speed. This framework is designed with a forward-looking mindset, embracing the latest advancements in JavaScript while prioritizing ease of use and performance.

Highlights

  • Functional Approach: Embracing the functional programming paradigm, this framework empowers developers to write clean, concise, and composable code, promoting modular design and scalability.

  • 100% TypeScript: Built entirely in TypeScript, ensures type safety throughout the development process, reducing errors and enhancing code quality.

  • Mandatory ESM Adoption: mandates the adoption of ECMAScript Modules (ESM) over CommonJS, ensuring developers unlock the full potential of modern JavaScript features like root-level await, code splitting and more...

  • Instant Context Access: seamless access to request data like headers or body with functions like getRequest() and getBody() anywhere within the same request context. Say goodbye to tedious req/res drilling.

  • No Boilerplate Needed: Bid farewell to boilerplate code. With its minimalist approach, eliminates unnecessary setup and configuration.

Getting started

Your project directory structure should look like this:

.
├── src
│   ├── index.ts         // Entry point
│   └── user             // User module
│       └── index.ts     // User module entry point
└── package.json

Ensure that your package.json file has the "type": "module" field to enable ECMAScript modules (ESM) support:

{
  "name": "hello-nodejs",
  "type": "module"
}

Creating Your Application

import { createApp, getParam } from "@minimajs/server";

const app = createApp();

app.get("/:name", () => `Hello ${getParam("name")}!`);

await app.listen({ port: 1234 });

This code creates a MinimaJS application with a single route handler for the root URL ("/") and a parameter name.

That's all!


Compiling and running your TypeScript project:

Using tsc Compiler

While you can compile your TypeScript code using the TypeScript Compiler (tsc) and then run the compiled JavaScript files, it might involve multiple steps. Here's how you can do it:

tsc src/*.ts --module NodeNext --moduleResolution NodeNext --outDir dist
node dist/index.js

Server listening at http://0.0.0.0:1234

curl http://0.0.0.0:1234/John
> Hello John!

Using ebx Bundler

On the other hand, you can utilize the ebx bundler, known for its lightning-fast performance and seamless bundling experience tailored specifically for Node.js projects. Read more https://npmjs.com/package/ebx

installing ebx

yarn add -D ebx

Add following inside your package.json file

{
  "scripts": {
    "dev": "ebx src/index.ts -wsr",
    "build": "ebx src/index.ts",
    "start": "node dist/index.js"
  }
}

With ebx, you can directly bundle and execute your TypeScript code in a single step, significantly reducing build times and simplifying your workflow.

To start your project in development mode.

yarn dev

To build your project for production deployment, run:

yarn build

Once your project is built, you can start the server using:

yarn start

This command runs the compiled JavaScript files in the dist directory.

See the full documentation https://minima-js.github.io/

Package Sidebar

Install

npm i @minimajs/server

Weekly Downloads

6

Version

0.1.2

License

MIT

Unpacked Size

45.7 kB

Total Files

54

Last publish

Collaborators

  • adil.sudo