Security News
npm Updates Search Experience with New Objective Sorting Options
npm has a revamped search experience with new, more transparent sorting options—Relevance, Downloads, Dependents, and Publish Date.
bitter-express
Advanced tools
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.
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
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.
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 {}
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"
}
}
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 {}
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
better express.js experience
The npm package bitter-express receives a total of 0 weekly downloads. As such, bitter-express popularity was classified as not popular.
We found that bitter-express demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
npm has a revamped search experience with new, more transparent sorting options—Relevance, Downloads, Dependents, and Publish Date.
Security News
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.