HTTP
Introduction
CairJS use ExpressJS.
Install package
yarn add @cairjs/http
Start Server
Example using Singleton instance
index.ts
import { server } from '@cairjs/http'
const port = process.env.HTTP_PORT || 3000
server.get('/', (req, res) => {
res.send('Welcome!')
})
server.listen(port, () => {
console.log(`Example app listening on port ${port}`)
})
Example using new express instance
index.ts
import { express } from '@cairjs/http'
const app = express()
const port = 3000
app.get('/', (req, res) => {
res.send('Hello World!')
})
app.listen(port, () => {
console.log(`Example app listening on port ${port}`)
})