2023-07-25 01:40:22 +00:00
|
|
|
|
|
|
|
|
2023-07-24 20:27:36 +00:00
|
|
|
require('dotenv').config();
|
|
|
|
import express, { NextFunction, Request, Response } from 'express';
|
|
|
|
import config from 'config';
|
|
|
|
import cors from 'cors';
|
|
|
|
import { AppDataSource } from './db/data-source';
|
2023-07-24 23:15:27 +00:00
|
|
|
import AppError from './errors/appError';
|
2023-07-24 20:27:36 +00:00
|
|
|
|
2023-07-25 01:40:22 +00:00
|
|
|
import groupRoutes from "./routes/group.routes";
|
2023-07-25 03:22:48 +00:00
|
|
|
import slackRoutes from "./routes/slack.routes";
|
2023-07-24 20:27:36 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
AppDataSource.initialize()
|
|
|
|
.then(async () => {
|
|
|
|
|
|
|
|
const app = express();
|
2023-07-25 01:40:22 +00:00
|
|
|
app.use(express.json({limit: "10kb"}));
|
|
|
|
|
|
|
|
app.get('/healthcheck', async (_, res: Response) => {
|
|
|
|
res.status(200).json({
|
|
|
|
status: "online!!!!"
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
app.use('/groups', groupRoutes);
|
2023-07-24 20:27:36 +00:00
|
|
|
|
2023-07-25 03:22:48 +00:00
|
|
|
// app.use('/slack', async (req:Request, res:Response) => {
|
|
|
|
// console.log(req)
|
|
|
|
// let code = req.query.code;
|
|
|
|
// });
|
|
|
|
|
|
|
|
app.use('/slack', slackRoutes);
|
|
|
|
|
2023-07-24 20:27:36 +00:00
|
|
|
app.all('*', (req: Request, res: Response, next: NextFunction) => {
|
|
|
|
next(new AppError(404, `Route ${req.originalUrl} not found`));
|
|
|
|
});
|
|
|
|
|
2023-07-25 01:40:22 +00:00
|
|
|
const port = config.get<number>('port');
|
|
|
|
app.listen(port);
|
|
|
|
|
|
|
|
console.log(`Server started on port: ${port}`)
|
|
|
|
|
2023-07-24 20:27:36 +00:00
|
|
|
})
|