-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
44 lines (36 loc) · 1.04 KB
/
index.js
File metadata and controls
44 lines (36 loc) · 1.04 KB
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
import express from "express";
import twit from "twit";
import dotenv from "dotenv";
import path from 'path';
const __dirname = path.resolve();
dotenv.config();
const app = express();
app.use(express.urlencoded({ extended: true }))
app.use(express.json())
const port = 5050;
const T = new twit({
consumer_key: process.env.consumer_key,
consumer_secret: process.env.consumer_secret,
access_token: process.env.token,
access_token_secret: process.env.token_secret,
});
app.get("/", (req, res) => {
res.sendFile(__dirname + "/frontend/index.html")
})
app.get("/profile/:screen_name", (req, res) => {
const options = {
screen_name: req.params.screen_name,
};
console.log(options);
T.get("/users/show", options, function (err, data) {
console.log(data)
res.removeHeader("x-powered-by")
res.json(data)
})
})
app.get("/profile", ((req, res) => {
res.sendFile(__dirname + "/frontend/profile.html")
}))
app.listen(port, "localhost", () => {
console.log(`app listening on port ${port}`)
})