Compare commits
7 Commits
6ada601a81
...
b75dce5352
Author | SHA1 | Date |
---|---|---|
Notoric | b75dce5352 | |
Wilkozx | 3ab0e1fa43 | |
Wilkozx | 822d9100db | |
Wilkozx | e2736d1c10 | |
Wilkozx | 184ec7196d | |
Wilkozx | f9c7359fd6 | |
Wilkozx | 0cad380e49 |
|
@ -10,3 +10,6 @@ backend/.env
|
|||
|
||||
# Frontend-specific
|
||||
frontend/node_modules/
|
||||
|
||||
# Database-specific
|
||||
database/data/
|
|
@ -0,0 +1,13 @@
|
|||
FROM node:14.15.4
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY package.json package-lock.json ./
|
||||
|
||||
RUN npm install
|
||||
|
||||
COPY . .
|
||||
|
||||
EXPOSE 5000
|
||||
|
||||
CMD ["node", "index.js"]
|
|
@ -0,0 +1,18 @@
|
|||
const express = require('express');
|
||||
|
||||
// Invoke express app
|
||||
const app = express();
|
||||
|
||||
const APIRoutes = require('./routes/api');
|
||||
const Loggerware = require('./middleware/Logger');
|
||||
|
||||
// Set up middleware
|
||||
app.use(Loggerware);
|
||||
|
||||
// Set up API routes
|
||||
app.use(APIRoutes);
|
||||
|
||||
// Listen on port 5000
|
||||
app.listen(5000, () => {
|
||||
console.log('Server is listening on port 5000');
|
||||
});
|
|
@ -0,0 +1,11 @@
|
|||
const express = require('express');
|
||||
|
||||
const Loggerware = express.Router();
|
||||
|
||||
Loggerware.use((req, res, next) => {
|
||||
let time = new Date().toLocaleTimeString();
|
||||
console.log(time + ' | Request received | path: ' + req.path + ' | method: ' + req.method);
|
||||
next();
|
||||
});
|
||||
|
||||
module.exports = Loggerware;
|
|
@ -9,6 +9,7 @@
|
|||
"version": "1.0.0",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"dotenv": "^16.4.5",
|
||||
"express": "^4.19.2",
|
||||
"mongoose": "^8.5.2",
|
||||
"socket.io": "^4.7.5"
|
||||
|
@ -228,6 +229,17 @@
|
|||
"npm": "1.2.8000 || >= 1.4.16"
|
||||
}
|
||||
},
|
||||
"node_modules/dotenv": {
|
||||
"version": "16.4.5",
|
||||
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.4.5.tgz",
|
||||
"integrity": "sha512-ZmdL2rui+eB2YwhsWzjInR8LldtZHGDoQ1ugH85ppHKwpUHL7j7rN0Ti9NCnGiQbhaZ11FpR+7ao1dNsmduNUg==",
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://dotenvx.com"
|
||||
}
|
||||
},
|
||||
"node_modules/ee-first": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz",
|
||||
|
|
|
@ -3,13 +3,15 @@
|
|||
"version": "1.0.0",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
"test": "echo \"Error: no test specified\" && exit 1",
|
||||
"dev": "nodemon index.js"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"description": "",
|
||||
"dependencies": {
|
||||
"dotenv": "^16.4.5",
|
||||
"express": "^4.19.2",
|
||||
"mongoose": "^8.5.2",
|
||||
"socket.io": "^4.7.5"
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
const express = require('express');
|
||||
|
||||
const APIRoutes = express.Router();
|
||||
|
||||
APIRoutes.get('/', (req, res) => {
|
||||
res.json({'message': 'Hello World!'});
|
||||
});
|
||||
|
||||
module.exports = APIRoutes;
|
|
@ -0,0 +1,31 @@
|
|||
services:
|
||||
backend:
|
||||
container_name: backend
|
||||
build:
|
||||
context: ./backend
|
||||
dockerfile: Dockerfile
|
||||
working_dir: /app
|
||||
ports:
|
||||
- "5000:5000"
|
||||
volumes:
|
||||
- ./backend:/app
|
||||
|
||||
frontend:
|
||||
container_name: frontend
|
||||
build:
|
||||
context: ./frontend
|
||||
dockerfile: Dockerfile
|
||||
ports:
|
||||
- "3000:3000"
|
||||
volumes:
|
||||
- ./frontend:/app
|
||||
- ./frontend:/node_modules
|
||||
|
||||
db:
|
||||
container_name: database
|
||||
image: mongodb/mongodb-community-server
|
||||
ports:
|
||||
- "27017:27017"
|
||||
volumes:
|
||||
- ./database/data:/data/db
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
FROM node:14.15.4
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY package.json package-lock.json ./
|
||||
|
||||
RUN npm install
|
||||
|
||||
COPY . .
|
||||
|
||||
EXPOSE 3000
|
||||
|
||||
CMD ["npm", "start"]
|
Loading…
Reference in New Issue