-
Notifications
You must be signed in to change notification settings - Fork 0
Home
ajitirto edited this page Jul 5, 2024
·
1 revision
Welcome to the express-simple-hello-world wiki!
Belajar tentang express js
- routing
- listen port 3000
exxpress js : framewok javascipt khusus untuk web.
-
dari pada native javascipt lebih baik menggunakan framewok, selain meringkas perkerjaan, framewok juga menajadi standard developer, supaya ketika bekerja dengan tim lebih berpola.
-
minimalis, cukup ringan saat dijalankan
-
dapat intergrasi dengan library laninya di atas node js
-
cocok juga untuk membuat rest api
This project is used by :
- Personal research
kode simple express
import express from 'express';
const app = express();
const birdAscii = `
___
__/o \\_ | Documentation : (package.json)
\\______ \\ | "dependencies": {
\\ \\ | "express": "^4.17.1"
\\ \\ | ""nodemon": "^3.1.4"
______ \\ \\_ |}
/ \\__| o\\_ |
| \\__ \\ \ |
\\________ __/ |
\\_____/ |
============================
=> curl localhost:3000/
`;
app.get('/', (req, res) => {
res.send(`<pre>${birdAscii}</pre>`);
});
const port = process.env.PORT || 3000;
app.listen(port, () => {
console.log(`Listening on localhost:${port}`);
});
memanggil library expres, membuat routing index dengan reposd hello world dan dibind dengan port 3000 atau apabila adan env port yang di custom juga bisa. berikan trigger lewat console.