> For the complete documentation index, see [llms.txt](https://kidkung.gitbook.io/node-js/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://kidkung.gitbook.io/node-js/library/express.md).

# Express

Framework ของ NodeJS ที่สามารถใช้ในการทำ WebService อย่าง REST API

### install

```batch
npm install express
npm i @types/express --save-dev
```

```typescript
#index.ts
import express, { Application, Request, Response } from 'express'
const port = process.env.PORT || 4000
const app: Application = express()
app.get('/', (req: Request, res: Response) => {
    res.send('Hello World!')
})
app.listen(port, () => {
    console.log(`Express server has started on port ${port}`);
});

```

{% embed url="<https://alchemist.itbangmod.in.th/cookbook-%E0%B8%AA%E0%B8%AD%E0%B8%99-nodejs-%E0%B8%81%E0%B8%B1%E0%B8%9A-express-ver-%E0%B9%80%E0%B8%94%E0%B9%87%E0%B8%81-java-%E0%B8%AA%E0%B8%B9%E0%B9%88-nodejs-832e5a52e1f4>" %}
อ่านเพิ่มเติม
{% endembed %}
