-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
27 lines (27 loc) · 1022 Bytes
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import express from 'express';
import { MessageController } from './controller/MessageController.js';
const server = express();
const port = 9000; // default port to listen
// Initialize Controllers
const messageControlloer = new MessageController();
// ////////////// Middleware //////////////
// Web API
// getting all messages from the database
// the only endpoint that we implemented fully together
server.get('/messages/all', (req, res) => {
console.log('trying get all messages');
return messageControlloer.getAllMessages(req, res);
});
// another example -> not implement
server.post('/messages/add', (req, res) => {
console.log('adding message');
return messageControlloer.add(req, res);
});
// another example -> not implement
server.post('messages/get-author-id-by-user-id', (req, res) => {
return messageControlloer.getAuthorIdByUserId(req, res);
});
// start the express server
server.listen(port, () => {
console.log(`server started at port:${port}`);
});