-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathauthServer.js
45 lines (33 loc) · 1.09 KB
/
authServer.js
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
37
38
39
40
41
42
43
44
45
require('dotenv').config();
const express = require('express');
const app = express();
const mongoose = require('mongoose');
const authRouter = require('./routes/authRoutes')
const database = () => {
return mongoose.connect(process.env.MONGO_URI)
}
app.use(express.json());
app.use(express.urlencoded({extended: true}));
app.use('/auth', authRouter);
// app.post('/token', (req, res) => {
// const token = req.body.token;
// if(token == null)return res.sendStatus(401);
// if(!refreshTokens.includes(token)) return res.sendStatus(403);
// verify(token, process.env.REFRESH_TOKEN_SECRET, (err, user) => {
// if(err) return res.send('not verfiy').status(401);
// const accessToken = generateAccessToken({name: user.name});
// res.json({accessToken});
// });
// });
const port = process.env.PORT || 4000 ;
const connectDatabase = async () => {
try {
await database()
app.listen(port, () => {
console.log(`server listening to port ${port}`);
});
} catch (error) {
console.log(error);
}
}
connectDatabase()