Product
Introducing License Enforcement in Socket
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
@nodebrick/nodebrick-core
Advanced tools
Core of the Nodebrick framework
This is the core of the framework and works as a glue between all the modules and is required by all application you will create
Have a look at the existing modules, it's self explenatory.
Few things to note:
index.ts
I<ModuleNameModule>.ts
export abstract class I<ModuleName>
to define interface so they exists in the JS realm and are accessible by InversifyJS<ModuleNameModule>.ts
The module class implementing and extending the 'interface'<ModuleNameBindings>.ts
models
Folder storing all our models, i.e our business logic data@Exclude()
export abstract class IAPIResponse<TData>
{
@Expose({name: `request_id`, toClassOnly: true})
@IsOptional()
public abstract requestId?: string;
@Expose({name: `client_request_id`, toPlainOnly: true})
@IsString()
@IsOptional()
public abstract clientRequestId?: string;
@Expose({name: `start_time`, toPlainOnly: true})
@IsDate()
public abstract startTime?: Date;
@Expose({name: `end_time`, toPlainOnly: true})
@IsDate()
public abstract endTime: Date;
@Expose({toPlainOnly: true})
@IsInt()
@IsOptional()
// In milliseconds
public abstract duration?: number;
}
For instance a REST API returning the above will automatically create a JSON like
{
"client_request_id": "933ca46c-25a5-4166-903e-a437700ae4ef",
"startTime": "933ca46c-25a5-4166-903e-a437700ae4ef",
"end_time": "933ca46c-25a5-4166-903e-a437700ae4ef",
"duration": 50
}
I invite you to read the class-transformer and class-validator documentations.NodebrickCore provides dependency injection by using internally InversifyJS
All the bindings will be defined in the <ModuleNameBindings>.ts
as for instance
// bind the module to its interface using transitive binding, i.e we are reusing the singleton.
bind(INodebrickApiModule).toService(NodebrickApiModule);
// middlewares - transient
bind(IGlobalApiMiddleware).to(GlobalApiMiddleware).inTransientScope();
bind(IGlobalOptionsMiddleware).to(GlobalOptionsMiddleware).inTransientScope();
bind(IGlobalRequestMiddleware).to(GlobalRequestMiddleware).inTransientScope();
// services - singletons
bind(INodebrickApiService).to(NodebrickApiService).inSingletonScope();
As you can see you have multiple scope for those
A context can be defined as all the relevant information that a developer needs to complete a task.
NodebrickCore with the help of cls-hooked provides you with tools to create a context and attach any
FAQs
Core of Nodebrick
The npm package @nodebrick/nodebrick-core receives a total of 3 weekly downloads. As such, @nodebrick/nodebrick-core popularity was classified as not popular.
We found that @nodebrick/nodebrick-core 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.
Product
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
Product
We're launching a new set of license analysis and compliance features for analyzing, managing, and complying with licenses across a range of supported languages and ecosystems.
Product
We're excited to introduce Socket Optimize, a powerful CLI command to secure open source dependencies with tested, optimized package overrides.