-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.ts
31 lines (22 loc) · 879 Bytes
/
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
import express, {Express, Request, Response} from "express";
import mongoose from "mongoose"
import Redis from 'ioredis'
import {login, panel, register, verify} from "./apis/functions";
import checkToken from "./middleware/checkToken";
import crypto from "crypto";
const app: Express = express()
mongoose.connect('mongodb://localhost:27017/2stepAuth')
.then(() => console.log('connected to MongoDB'))
.catch(err => console.error(err))
export const redisClient = new Redis({
host:"localhost",
port: 6379
})
.on('error', err => console.log('Redis Client Error', err))
.on('connect', ()=> {console.log('Connected!');})
export const secretKey = Object.freeze(crypto.randomBytes(64).toString("base64"))
app.post('/register' , register)
app.post('/verify' , verify)
app.post('/login' , login)
app.post('/panel' , checkToken ,panel)
app.listen(5000)