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

my-nodejs-framework

v1.0.4

Published

Simple nodejs framework

Downloads

253

Readme

My Framework

Overview

My Framework is a lightweight and modular framework for building server-side applications with TypeScript. It provides a clean and intuitive way to define and manage modules, controllers, and services, allowing for a streamlined development experience. The framework integrates decorators and a factory pattern to handle dependency injection, routing, and application bootstrapping efficiently.This framework features a clean and intuitive approach to application development by integrating a dependency container to manage services and dependencies seamlessly.

Example of usage of my framework

Features

  1. Modular Architecture: Define application modules, controllers, and services with a clear separation of concerns.
  2. Decorators: Utilize decorators for defining routes, request methods, and dependency injections.
  3. Dependency Injection: Seamlessly inject services into controllers and manage dependencies.
  4. Routing: Configure routing with support for multiple HTTP methods (GET, POST, PUT, PATCH, DELETE).
  5. Bootstrapping: Simple application initialization using a factory pattern.

Implementation

Bootstrapping the Application

To start the application, use the Factory class to create an instance of the AppModule and listen on a specified port.

async function bootstrap() {
	const app = await Factory.create(AppModule);
	await app.listen(3000);
}

bootstrap();

Defining Modules

Modules define the structure of the application, including controllers and providers.

import { Module } from "../decorators";
import { AppController } from "./app.controller";
import { AppService } from "./app.service";

@Module({
	imports: [],
	controllers: [AppController],
	providers: [AppService],
})
export class AppModule {
}

Creating Controllers

Controllers handle HTTP requests and use decorators to define routes and request methods.

import { Body, Controller, Delete, Get, Param, Patch, Post, Put } from "../decorators";
import { AppService } from "./app.service";

@Controller()
export class AppController {
	constructor(private readonly appService: AppService) {
	}

	@Get()
	getHello(): string {
		return this.appService.getHello();
	}

	@Post('body/:id')
	recieveBody(@Body() data: any, @Param('id') id: string) {
		return 'body: ' + JSON.stringify(data) + ` has been received and id: ${id}`;
	}

	@Patch('body/:id')
	examplePatch(@Body() data: any, @Param('id') id: string) {
		return 'patch body: ' + JSON.stringify(data) + ` has been received and id: ${id}`;
	}

	@Put('body/:id')
	examplePut(@Body() data: any, @Param('id') id: string) {
		return 'put body: ' + JSON.stringify(data) + ` has been received and id: ${id}`;
	}

	@Delete('body/:id')
	exampleDelete(@Param('id') id: string) {
		return `Delete has been received and id: ${id}`;
	}
}

Implementing Services

Services provide business logic and can be injected into controllers.

import { Injectable } from "../decorators";

@Injectable()
export class AppService {
	getHello(): string {
		return 'Hello World!';
	}
}

Feel free to customize and extend the framework to fit your needs. Thanks for checking out the functionality of my self-written framework, I hope you like it