Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
microframework
Advanced tools
Microframework is a minimalistic framework you can use with TypeScript and JavaScript.
Microframework is a simple tool that allows you to execute and configure your modules (called loaders) in a proper order, helping you to organize bootstrap code in your application.
First, install microframework:
npm i microframework
Second, create a simple "loader" named expressLoader
.
Loader is a place where you can configure all your modules during microframework bootstrap.
All loaders are executed one by one in a sequential order.
import {MicroframeworkSettings} from "microframework";
export function expressLoader(settings: MicroframeworkSettings) {
// create express app
const app = express();
// register all routes, Routes are just routes that should be stored outside of this module
const routes: any = Routes;
Object.keys(routes).forEach(routePath => app.get(routePath, routes[routePath]));
// run application to listen on given port
app.listen(3000);
// your loader also can return a promise and microframework will wait for it in a proper order
}
Create app.ts
and bootstrap a microframework and your express loader:
import {bootstrapMicroframework} from "microframework";
import {expressLoader} from "./expressLoader";
bootstrapMicroframework([
expressLoader
])
.then(() => console.log("Application is up and running."))
.catch(error => console.log("Application is crashed: " + error));
That's all. You can do same for other loaders. Take a look on sample to understand better how concept of loaders and their bootstrapping in microframework.
You can specify additional options to microframework.
logo
- Logo needs to be used before application launches. To use logo ansi-art node module should be installed.showBootstrapTime
- If set to true then framework shows how much time was spend to bootstrap microframework.bootstrapTimeout
- Number of milliseconds to wait before framework will bootstrap.Example of using settings:
import {bootstrapMicroframework} from "microframework";
import {expressLoader} from "./expressLoader";
bootstrapMicroframework({
config: {
logo: "MyApp",
showBootstrapTime: true,
bootstrapTimeout: 10
},
loaders: [
expressLoader,
// ...
]
})
.then(() => console.log("Application is up and running."))
.catch(error => console.log("Application is crashed: " + error));
Sometimes few loaders need to communicate between each other and use shared data.
For such purpose you can store the data in settings
object passed to each loader
and use stored data across all other loaders. For example:
import {MicroframeworkSettings} from "microframework";
export function expressLoader(settings: MicroframeworkSettings) {
// create express app
const app = express();
// register all routes, Routes are just routes that should be stored outside of this loader
const routes: any = Routes;
Object.keys(routes).forEach(routePath => app.get(routePath, routes[routePath]));
// run application to listen on given port
app.listen(3000);
settings.setData("express_app", app);
}
And another loaders can use data this way:
import {MicroframeworkSettings} from "microframework";
export function socketIoLoader(settings: MicroframeworkSettings) {
const io = io();
io.useExpress(settings.getData("express_app"));
}
In the case if you want to shutdown running application you need to do following:
import {bootstrapMicroframework} from "microframework";
import {expressLoader} from "./expressLoader";
bootstrapMicroframework({
config: {
logo: "MyApp",
showBootstrapTime: true,
bootstrapTimeout: 10
},
loaders: [
expressLoader,
// ...
]
})
.then(framework => {
// do something before shutdown
// and shutdown everything
return framework.shutdown();
})
.then(() => {
// now everything is turned off
})
.catch(error => console.log("Application is crashed: " + error));
All loaders which use resources should release them, for example:
export async function typeormModule(settings: MicroframeworkSettings) {
const connection = await createConnection({
driver: {
type: "mysql",
host: "localhost",
username: "test",
password: "test",
database: "test"
}
});
settings.onShutdown(() => connection.close()); // closing connection on microframework shutdown
}
FAQs
Microframework is a minimalistic framework you can use with TypeScript and JavaScript.
The npm package microframework receives a total of 371 weekly downloads. As such, microframework popularity was classified as not popular.
We found that microframework demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.