-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ts
31 lines (26 loc) · 1.08 KB
/
index.ts
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
31
import express, { Express, Request, Response, Application } from "express";
import dotenv from "dotenv";
import cors from "cors";
import { contract } from "./Contracts/Contract";
import { createExpressEndpoints, initServer } from "@ts-rest/express";
import bodyParser from "body-parser";
import Contractroutes from "./Controller/Contractroutes";
import { dbConnect } from "./db/db";
import { AuthContract } from "./Contracts/AuthContract";
import AuthController from "./Controller/AuthRoutes";
import { UserContract } from "./Contracts/UserContracts";
import UserController from "./Controller/UserController";
//For env File
dotenv.config();
const app: Application = express();
const port = process.env.PORT || 8000;
app.use(cors());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());
dbConnect();
createExpressEndpoints(contract, Contractroutes, app);
createExpressEndpoints(AuthContract, AuthController, app);
createExpressEndpoints(UserContract, UserController, app);
app.listen(port, () => {
console.log(`Server is started at http://localhost:${port}`);
});