Chore : move files out of directory

This commit is contained in:
Nathan Tien You
2024-09-18 08:54:54 +00:00
parent f282f6cc97
commit f47127cd1d
28 changed files with 0 additions and 0 deletions
+29
View File
@@ -0,0 +1,29 @@
import express from 'express'
import { createClient } from 'redis';
import cors from 'cors'
const client = createClient({
url: process.env.REDIS_URL
});
client.on('error', err => console.log('Redis Client Error', err));
await client.connect()
const app = express()
const port = 3000
app.use(cors())
app.use(express.json())
app.get('/', async (req, res) => {
res.send(await client.lRange("messages", 0, -1))
})
app.post('/', async (req, res) => {
await client.lPush("messages", JSON.stringify(req.body))
res.sendStatus(201)
})
app.listen(port, () => {
console.log(`Example app listening on port ${port}`)
})