Skip to content
This repository was archived by the owner on Apr 20, 2023. It is now read-only.

Commit 73d0cb5

Browse files
committed
added notion support
1 parent 5b7f0c4 commit 73d0cb5

File tree

5 files changed

+184
-11
lines changed

5 files changed

+184
-11
lines changed

app.js

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ const app = express();
88

99
const authRoutes = require("./routes/auth.routes");
1010
const courseRoutes = require("./routes/course.routes");
11+
const notionRoutes = require("./routes/notion.routes");
1112

1213
require("dotenv").config();
1314

@@ -17,20 +18,23 @@ app.use(
1718
cors({
1819
credentials: true,
1920
allowedHeaders: ["Content-Type", "Authorization"],
20-
origin: ["http://localhost:3001"],
21+
origin: ["http://localhost:3000"],
2122
})
2223
);
2324

2425
app.use("/auth", authRoutes);
2526
app.use("/course", courseRoutes);
27+
app.use("/notion", notionRoutes);
2628

27-
mongoose
28-
.connect("mongodb://localhost:27017/techoptimumdasboard")
29-
.then((result) => {
30-
app.listen(3000, () => {
31-
console.log("Connected!");
32-
});
33-
})
34-
.catch((err) => {
35-
console.log(err);
36-
});
29+
// mongoose
30+
// .connect("mongodb://localhost:27017/techoptimumdasboard")
31+
// .then((result) => {
32+
33+
// })
34+
// .catch((err) => {
35+
// console.log(err);
36+
// });
37+
38+
app.listen(3001, () => {
39+
console.log("Connected!");
40+
});

controllers/notion.controller.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
const { Client } = require("@notionhq/client");
2+
const notion = new Client({ auth: process.env.NOTION_API_KEY });
3+
const databaseId = process.env.NOTION_API_DATABASE;
4+
5+
6+
exports.readInternshipFinderData = async (req, res) => {
7+
const response = await notion.databases.query({ database_id: databaseId });
8+
console.log(response);
9+
res.send({response})
10+
}

package-lock.json

Lines changed: 150 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
{
22
"dependencies": {
3+
"@notionhq/client": "^2.2.3",
34
"@sendgrid/mail": "^7.7.0",
45
"bcrypt": "^5.0.1",
56
"body-parser": "^1.20.0",
67
"cookie-parser": "^1.4.6",
78
"cors": "^2.8.5",
89
"dotenv": "^16.0.1",
910
"express": "^4.18.1",
11+
"express-validator": "^6.14.2",
1012
"jsonwebtoken": "^8.5.1",
1113
"mongoose": "^6.4.7",
1214
"node-mailer": "^0.1.1"

routes/notion.routes.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
const notionControllers = require("../controllers/notion.controller");
2+
const express = require("express");
3+
const router = express.Router();
4+
5+
router.get("/", [], notionControllers.readInternshipFinderData);
6+
7+
module.exports = router;

0 commit comments

Comments
 (0)