starting db connection and cleaning things out
This commit is contained in:
+25
-30
@@ -1,48 +1,43 @@
|
||||
import express, { Application, Request, Response } from "express";
|
||||
import './repository/db';
|
||||
|
||||
import GetAllSocketClients from "@nirvana/core/sockets/getAllActiveSocketClients";
|
||||
import InitializeWs from "./sockets";
|
||||
import { NextFunction } from "express";
|
||||
import NirvanaResponse from "@nirvana/core/responses/nirvanaResponse";
|
||||
import ReceiveSignal from "../core/sockets/receiveSignal";
|
||||
import SendSignal from "@nirvana/core/sockets/sendSignal";
|
||||
import SocketChannels from "@nirvana/core/sockets/channels";
|
||||
import { UserService } from "./services/user.service";
|
||||
import { UserStatus } from "@nirvana/core/models";
|
||||
import cors from "cors";
|
||||
import getLineRoutes from "./routes/line";
|
||||
import getSearchRoutes from "./routes/search";
|
||||
import getUserRoutes from "./routes/user";
|
||||
import * as Sentry from '@sentry/node';
|
||||
import * as Tracing from '@sentry/tracing';
|
||||
|
||||
/* eslint-disable @typescript-eslint/no-var-requires */
|
||||
import express, { Application, NextFunction, Request, Response } from 'express';
|
||||
|
||||
import InitializeWs from './services/SocketService';
|
||||
import cors from 'cors';
|
||||
import morgan from 'morgan';
|
||||
|
||||
const app = express();
|
||||
|
||||
app.use(morgan('combined'));
|
||||
app.use(cors());
|
||||
app.use(express.json());
|
||||
|
||||
app.use((req: Request, res: Response, next: NextFunction) => {
|
||||
console.log("Time: ", new Date());
|
||||
console.log('Time: ', new Date());
|
||||
next();
|
||||
});
|
||||
|
||||
app.get("/", (req: Request, res: Response) => {
|
||||
res.send("hello world.");
|
||||
app.get('/', (req: Request, res: Response) => {
|
||||
res.send('hello world.');
|
||||
});
|
||||
app.use('/api/status', (req: Request, res: Response) => {
|
||||
res.json({ message: 'wohoo, server is healthy' });
|
||||
});
|
||||
|
||||
app.use("/api/status", (req: Request, res: Response) => {
|
||||
res.json(new NirvanaResponse("wohoo, server is healthy"));
|
||||
});
|
||||
const PORT = process.env.PORT || 8080;
|
||||
const server = app.listen(PORT, () =>
|
||||
console.log(`express running on port | ${PORT} in host machine`),
|
||||
);
|
||||
|
||||
app.use("/api/user", getUserRoutes());
|
||||
app.use("/api/search", getSearchRoutes());
|
||||
app.use("/api/lines", getLineRoutes());
|
||||
// won't catch any errors here and we don't want it to
|
||||
console.log();
|
||||
|
||||
const PORT = 5000;
|
||||
const server = app.listen(PORT, () => console.log("express running"));
|
||||
|
||||
const io = require("socket.io")(server, {
|
||||
const io = require('socket.io')(server, {
|
||||
// todo: add authentication
|
||||
cors: {
|
||||
origin: "*",
|
||||
origin: '*',
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user