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.
express-service-bootstrap
Advanced tools
This is a convenience package for starting a express API with security, health checks, process exits etc.
This is a convenience package for starting a express based API server with
import { ApplicationBuilder, ApplicationStartupStatus, ApplicationTypes, Convenience } from "../../dist/src/index.js";
import * as OpenApiDefinition from "./api-def.json" with { type: "json" };
const applicationName = "Test Simple App";
const app = new ApplicationBuilder(applicationName, OpenApiDefinition);
const utilities = new Convenience();
async function AppStartUp(rootRouter, DIContainer, application) {
//Connect to DB or create DB Pool
//Apply Migrations
//Register Routes,Middleware,etc
DIContainer.registerInstance("msg", { message: "Hello from DI" }); //Simulate things stored in DI container
rootRouter
.get("/", (req, res) => {
res.send(req.DIProp.fetchInstance("msg").message);
})
.post("/", (req, res) => {
console.log(req.body);
})
.get("/error", (req, res) => {
throw new Error("This is an error to validate final 'ErrorResponseTransformer' error handling of library");
});
//Configure your application.
const apiDocs = utilities.swaggerAPIDocs(OpenApiDefinition);
application.overrideAppPort(8080) //override the default port 8080(Default 3000)
.overrideHealthPort(8081) //override the default health port 8081(Default 5678)
.registerApplicationHandler(utilities.helmetMiddleware(), "*", 1, ApplicationTypes.Both) //register helmet middleware for both application and health
.registerApplicationHandler(utilities.bodyParserURLEncodingMiddleware(), "*", 2, ApplicationTypes.Main) //register body parser url middleware for application
.registerApplicationHandler(utilities.bodyParserJSONEncodingMiddleware({ limit: '50M' }), "*", 3, ApplicationTypes.Main) //register body parser json middleware for application
.registerApplicationHandler(apiDocs.router, apiDocs.hostingPath, 4, ApplicationTypes.Main) //register api docs
.registerApplicationHandler(utilities.injectInRequestMiddleware("DIProp", DIContainer), "*", 6, ApplicationTypes.Main) //register DI container middleware
.overrideCatchAllErrorResponseTransformer((req, error) => ({ //override the default catch all error response transformer
path: req.path,
status: 500,
body: { message: error.message }
}))
return {
status: ApplicationStartupStatus.UP, // Indicates startup was successful
data: { message: "Connected to database" } // Additional data to be returned(Optional)
};
}
app.overrideStartupHandler(AppStartUp)
.start()
.then(() => console.log(`${applicationName} started successfully.`))
.catch(console.error);
//*******************************
// You can wait for your application to be called by process exit signal
// OR
// If you are done call the Dispose method to stop the application
// await app[Symbol.asyncDispose](); //stop the application and release all resources
//*******************************
This project is contribution to public domain and completely free for use, view LICENSE.md file for details.
FAQs
This is a convenience package for starting a express API with security, health checks, process exits etc.
The npm package express-service-bootstrap receives a total of 24 weekly downloads. As such, express-service-bootstrap popularity was classified as not popular.
We found that express-service-bootstrap demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 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.