forked from synapsecns/analytics-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.ts
More file actions
34 lines (27 loc) · 878 Bytes
/
Copy pathindex.ts
File metadata and controls
34 lines (27 loc) · 878 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
31
32
33
34
import dotenv from "dotenv";
dotenv.config();
import express, { Express, Request, Response } from 'express';
import bodyParser from "body-parser";
// Import routes
import {MongoConnection} from "./api/db/MongoConnection";
import {RedisConnection} from "./api/db/RedisConnection";
import volume from "./api/v1/routes/volume";
// Connect to DBs
async () => {
await MongoConnection.createClient()
await RedisConnection.createClient()
}
// Setup app
const app: Express = express();
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.get('/', (req: Request, res: Response) => {
res.json({"message":"synapse analytics api"});
});
// Define routes
app.use('/api/v1/volume', volume);
// Start server
const port = process.env.PORT || 4001;
app.listen(port, () => {
console.log(`Server is running at http://localhost:${port}`);
});