-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.ts
36 lines (30 loc) · 1.09 KB
/
app.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
32
33
34
35
36
import express from "express";
import cookieParser from "cookie-parser";
import logger from "morgan";
import "dotenv/config";
import Moralis from "moralis/node";
import { createServer } from "http";
import { handleError } from "./middlewares/error-handler.middleware";
import accountRoutes from "./routes/account.routes";
import nftRoutes from "./routes/nft.routes";
// info: instantiating express and http server
var app = express();
const server = createServer(app);
// info: using middlewares
app.use(logger("dev"));
app.use(express.json());
app.use(express.urlencoded());
app.use(cookieParser());
// info: application routes
app.use("/api", [accountRoutes, nftRoutes]);
// info: error handler middleware
app.use(handleError);
// info: initializing moralis
const serverUrl = process.env.MORALIS_SERVER_URL;
const appId = process.env.MORALIS_APPLICATION_ID;
const masterKey = process.env.MORALIS_MASTER_KEY;
(async () => await Moralis.start({ appId, serverUrl, masterKey }))();
// info: initializing server
server.listen(process.env.PORT, () => {
console.log(`Server started on ${process.env.PORT}`);
});