Upload files to "sk1"

This commit is contained in:
Sabareesan Murugesan 2026-05-13 07:48:31 +00:00
parent 4125a9bb9c
commit 89bde8c234
3 changed files with 54 additions and 0 deletions

13
sk1/Dockerfile Normal file
View File

@ -0,0 +1,13 @@
FROM node:20
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
EXPOSE 3000
CMD ["node", "server.js"]

9
sk1/package.json Normal file
View File

@ -0,0 +1,9 @@
{
"name": "notes-app",
"version": "1.0.0",
"main": "server.js",
"dependencies": {
"express": "4.18.2",
"mongoose": "8.0.0"
}
}

32
sk1/server.js Normal file
View File

@ -0,0 +1,32 @@
const express = require('express');
const mongoose = require('mongoose');
const app = express();
app.use(express.json());
app.use(express.static('public'));
mongoose.connect(process.env.MONGO_URL);
const Note = mongoose.model('Note', {
text: String
});
app.get('/notes', async (req, res) => {
const notes = await Note.find();
res.json(notes);
});
app.post('/notes', async (req, res) => {
const note = new Note({
text: req.body.text
});
await note.save();
res.json(note);
});
app.listen(3000, () => {
console.log('Server started');
});