Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

bitter-express

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bitter-express

better express.js experience

  • 1.0.12
  • unpublished
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

BitterPress

Short Brief

It seems like you're encountering some challenges when trying to use TypeScript with Express, and you're looking for a solution that provides more structure and takes advantage of TypeScript decorators. One solution that fits this description is BitterPress.

BitterPress is a framework for building efficient, scalable, and maintainable server-side applications. It is built on top of Express and uses TypeScript as its primary language. BitterPress provides a structured, object-oriented approach to building applications, making it a great fit for developers who prefer a more organized and modular codebase.

Features

BitterPress focuses on providing decorators for Express.js API logic abstraction with the added benefit of a simple built-in dependency injection container for a lightweight and minimalistic approach to TypeScript development.

  • Controllers

  • Route, Query, Body, Params

  • Request

  • Response

  • Change Response Status Code

  • Set Headers

  • Middleware Support

  • Services

  • Dependency Injection based

  • Lifecycle hooks

  • Instance of express

Installation

To install the package:

  npm install bitter-press

Next, generate the tsconfig.json file at the root level of your project by running tsc --init, and within the compilerOptions object, include the following options:

{
  "compilerOptions": {
    "experimentalDecorators": true,
    "emitDecoratorMetadata": true
  }
}

Now you are ready to go.

@App Decorator

You can use a custom middleware with the app decorator, set the server's port, or use a specific controlle, also you can define a custom provider

import { App , Controller, useGlobalMiddlewares, customProdivers} from 'bitter-press';

@App({
  port: 3000,
  controller : [],
  useGlobalMiddlewares: [],
  customProdivers : []
})
export class ExampleAppModule {}

Http Methods

This framework supports classic HTTP methods and provides decorator-based support as well.

import { App , Controller} from 'bitter-press';

@Controller('/auth')
export class ExampleController {

    //GET
    @GET(':id')
    public async getSpecificUser() {
        return 'CANMERTINYO!'
    }

    //POST
    @POST('/register')
    public async register() {
        return "registered!"
    }

    //DELETE
    @DELETE()
    public deleteUser() {
        return "success"
    }
}

Custom Providers

In addition to registering services, BitterPress allows you to define custom providers that can be injected into your application. These custom providers can be associated with string tokens or redefine what is injected, replacing class instances by using class tokens.

To define custom providers, you should specify them within the @App decorator at the root level of your application. The customProviders property in the @App decorator's properties object is used to hold an array of these providers.

For each custom provider, two main aspects need to be defined:

Token: This specifies the identifier for the provider and can be either a string or a constructible type (class reference).

Instance: This is the actual object that will be injected when the token is used.

import { App , Controller, useGlobalMiddlewares, customProdivers} from 'bitter-press';

@App({
  port: 3000,
  controller : [],
  useGlobalMiddlewares: [],
  customProdivers : [{token : ExampleService, instance : new ExampleService()}]
})
export class ExampleAppModule {}

Cloning The Repo

Clone the repo

  git clone https://github.com/canmertinyo/bitter-press

Locate the root directory

  cd bitter-press

Install required dependencies with:

  npm install

FAQs

Package last updated on 15 Oct 2023

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc