@guoard/aliexpress
v1.0.3
Published
micro web framework written in TypeScript.
Downloads
1
Readme
Ali Express
micro web framework written in TypeScript.
Install
$ npm i @guoard/aliexpress
Run app
Open index.js
file :
const aliexpress = require('@guoard/aliexpress').default
const app = aliexpress();
// simple logger
app.use(function (req, res, next) {
console.log(`${req.method} ${req.url}`);
next();
});
app.get("/morning", function (req, res) {
console.log(req.query);
const name = req.query.name ? req.query.name : "anonymous";
res.send(`Good Morning ${name}`);
});
app.use(function (req, res, next) {
console.log(`in second middlerware`);
next();
});
app.get(
"/morning/:name",
function (req, res) {
res.send("Good morning, " + req.params.name);
}
);
app.post("/night", function (req, res) {
res.send("good Night");
});
app.delete(
"/go-to-night",
function (req, res) {
res.redirect("/night");
}
);
const port = 3000;
app.listen(port, () => {
console.log(`listening on port: ${port}`);
});