-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathapp.js
More file actions
23 lines (20 loc) · 682 Bytes
/
app.js
File metadata and controls
23 lines (20 loc) · 682 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import express from "express";
import passport from "./config/passport.js";
import authRoutes from "./routes/auth.js";
import dotenv from "dotenv";
import OAuthServer from "express-oauth-server";
import oauthModel from "./oauthModel.js";
dotenv.config();
const app = express();
app.use(express.json());
app.use(passport.initialize());
app.use("/api/auth", authRoutes);
const port = process.env.PORT || 3000;
app.listen(port, () =>
console.log(`Server running on http://localhost:${port}`)
);
app.oauth = new OAuthServer({ model: oauthModel });
app.post("/oauth/token", app.oauth.token());
app.get("/secure", app.oauth.authenticate(), (req, res) =>
res.send("Secure Data")
);