-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
30 lines (22 loc) · 808 Bytes
/
app.js
File metadata and controls
30 lines (22 loc) · 808 Bytes
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
28
29
30
'use strict'
import {connectDB} from "./db/typeorm-connect";
const awsServerlessExpress = require('aws-serverless-express');
const apps = require('./index');
const server = awsServerlessExpress.createServer(apps);
exports.handler = (event, context) => {
const startServer = async () => {
awsServerlessExpress.proxy(server, event, context);
const io = require('./src/io/io').init(server);
io.on('connection', (socket) => {
console.log('Client Connected');
io.emit('posts', {message: 'I am connected'});
});
io.on('connect_failed', function() {
console.log("Sorry, there seems to be an issue with the connection!");
})
};
(async () => {
await connectDB();
await startServer();
})();
};