
Research
Security News
Malicious PyPI Package Exploits Deezer API for Coordinated Music Piracy
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
@jsenv/server
Advanced tools
@jsenv/server
helps to write flexible server code with a declarative API.
import { startServer } from "@jsenv/server";
await startServer({
port: 8080,
services: [
{
handleRequest: () => {
return {
status: 200,
headers: {
"content-type": "text/plain",
},
body: "Hello world",
};
},
},
],
});
Code starting a server with 2 request handlers:
/*
* starts a server which:
* - when requested at "/"
* -> respond with 200
* - otherwise
* -> respond with 404
*/
import { startServer, composeServices } from "@jsenv/server";
const server = await startServer({
services: [
{
name: "index",
handleRequest: (request) => {
if (request.resource === "/") {
return { status: 200 };
}
return null;
},
},
{
name: "otherwise",
handleRequest: () => {
return { status: 404 };
},
},
],
});
const fetch = await import("node-fetch");
const responseForOrigin = await fetch(server.origin);
responseForOrigin.status; // 200
const responseForFoo = await fetch(`${server.origin}/foo`);
responseForFoo.status; // 404
Code starting a server in https:
import { readFileSync } from "node:fs";
import { startServer } from "@jsenv/server";
await startServer({
https: {
certificate: readFileSync(new URL("./server.crt", import.meta.url), "utf8"),
privateKey: readFileSync(new URL("./server.key", import.meta.url), "utf8"),
},
allowHttpRequestOnHttps: true,
services: [
{
handleRequest: (request) => {
const clientUsesHttp = request.origin.startsWith("http:");
return {
status: 200,
headers: {
"content-type": "text/plain",
},
body: clientUsesHttp ? `Welcome http user` : `Welcome https user`,
};
},
},
],
});
Code starting a server for static files:
import { startServer, fetchFileSystem } from "@jsenv/server";
await startServer({
services: [
{
handleRequest: async (request) => {
const fileUrl = new URL(request.resource.slice(1), import.meta.url);
const response = await fetchFileSystem(fileUrl, request);
return response;
},
},
],
});
npm install @jsenv/server
FAQs
Write your Node.js server using pure functions
The npm package @jsenv/server receives a total of 153 weekly downloads. As such, @jsenv/server popularity was classified as not popular.
We found that @jsenv/server 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 researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.
Security News
Newly introduced telemetry in devenv 1.4 sparked a backlash over privacy concerns, leading to the removal of its AI-powered feature after strong community pushback.