|
1 | 1 | import express from 'express'; |
2 | 2 | import cors from 'cors'; |
3 | | -import { createServer } from 'http'; |
| 3 | +import 'dotenv/config'; |
| 4 | +import db from './model/repository.js'; |
| 5 | + |
| 6 | +// const db = import('./model/repository.js'); |
4 | 7 |
|
5 | 8 | const app = express(); |
6 | | -app.use(express.urlencoded({ extended: true })) |
7 | | -app.use(express.json()) |
8 | | -app.use(cors()) // config cors so that front-end can use |
9 | | -app.options('*', cors()) |
| 9 | +const port = process.env.PORT || 8001; |
| 10 | + |
| 11 | +app.use(express.json()); |
| 12 | +app.use(express.urlencoded({ extended: true })); |
| 13 | +app.use(cors()); // config cors so that front-end can use |
| 14 | +app.options('*', cors()); // TODO: what's this? |
10 | 15 |
|
11 | | -app.get('/', (req, res) => { |
12 | | - res.send('Hello World from matching-service'); |
| 16 | +app.get('/api/matching', (req, res) => { |
| 17 | + res.status(200).send('Hello World from matching-service'); |
13 | 18 | }); |
14 | 19 |
|
15 | | -const httpServer = createServer(app) |
| 20 | +try { |
| 21 | + db.connection(); |
| 22 | +} catch (error) { |
| 23 | + console.log(error); |
| 24 | +} |
| 25 | + |
| 26 | +console.log('Calling app.listen()'); |
| 27 | + |
| 28 | +const server = app.listen(port, () => { |
| 29 | + console.log('Matching service server started on port ' + port); |
| 30 | +}); // TODO: socketio.listen(server) |
16 | 31 |
|
17 | | -httpServer.listen(8001); |
| 32 | +console.log('app.listen() executed'); |
0 commit comments