sw2express
Version:
A lite & simple cross-platform Express-like web application framework
25 lines (20 loc) • 550 B
JavaScript
import sw2express, { checkPlatform } from "../index.js";
const app = new sw2express({
logger: false,
ETag: false,
cluster: 10,
});
app
.route("/")
.POST(
async (req, rep) =>
`Hello World \nPOST Body: ${req.body}\n\nHeaders: ${JSON.stringify(
req.headers
)}`
)
.all(
async (req, rep) => `你好 世界 \n\nHeaders: ${JSON.stringify(req.headers)}`
);
app.route("/echo").GET(async (req, rep) => "Hello World");
app.route("/json").GET(async (req, rep) => new Object({ hello: "world" }));
app.listen(8081);