![Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility](https://cdn.sanity.io/images/cgdhsj6q/production/97774ea8c88cc8f4bed2766c31994ebc38116948-1664x1366.png?w=400&fit=max&auto=format)
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
@aldojs/application
Advanced tools
A generic application which uses internally a service container and a middleware dispatcher to handle any context object.
import { createApplication } from '@aldojs/application'
let app = createApplication()
// add a sum handler
app.use(({ a, b }) => a + b)
// handle the context
let result = app.handle({ a: 1, b: -1 })
Middlewares could be a common or an async function. please refer to @aldojs/middleware for more information on how middlewares are dispatched.
// Handler function signature
declare type Middleware = (ctx: Context, next: () => any) => any;
You can register as many middlewares as needed with the application's method .use(fn)
.
// to add a handler directly in the stack
app.use(middleware)
The context is a plain object, containing all data needed by the middlewares to do their job.
A proxied version is passed to the middleware chain, instead of the original context object, to provide the same fields, in addition to the properties defined with .set(key, value)
or .bind(key, factory)
methods. In other, you can access the services registered within the application, directly in the middlewares
declare interface Context {
[key: string]: any;
}
You may use Application::set(key, instance)
to share instances between contexts, like a DB connection or a global logger.
import Mongoose from 'mongoose'
// set up the mongon db connection
// let connection = ...
// register it within the context
app.set('db', connection)
You may also use .bind(key, fn)
to bind per-context instances.
This method takes the field name, and the factory
function to create the service object on demand.
let options = {/* some session options */}
// a new instance of Session is `lazily` created for each context
app.bind('session', () => new Session(options))
.has(key)
and .get(key)
are aldo available to check the existence of a certain service or to get a previously defined one.
FAQs
Generic application for Node.js projects
The npm package @aldojs/application receives a total of 2 weekly downloads. As such, @aldojs/application popularity was classified as not popular.
We found that @aldojs/application 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
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.