Skip to content

Commit 7347641

Browse files
committedMar 5, 2022
Initial working prototype
0 parents  commit 7347641

File tree

7 files changed

+3196
-0
lines changed

7 files changed

+3196
-0
lines changed
 

‎.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules/

‎package-lock.json

+3,119
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"name": "foss-weekend-participants-api",
3+
"version": "1.0.0",
4+
"description": "",
5+
"main": "server.js",
6+
"scripts": {
7+
"start": "node server.js",
8+
"devStart": "nodemon server.js"
9+
},
10+
"repository": {
11+
"type": "git",
12+
"url": "git+https://github.com/N-Shar-ma/FOSS-Weekend-Participants-API.git"
13+
},
14+
"keywords": [],
15+
"author": "",
16+
"license": "ISC",
17+
"bugs": {
18+
"url": "https://github.com/N-Shar-ma/FOSS-Weekend-Participants-API/issues"
19+
},
20+
"homepage": "https://github.com/N-Shar-ma/FOSS-Weekend-Participants-API#readme",
21+
"dependencies": {
22+
"express": "^4.17.1"
23+
},
24+
"devDependencies": {
25+
"nodemon": "^2.0.15"
26+
}
27+
}

‎profiles.json

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[
2+
{
3+
"name": "John Doe",
4+
"roll-number": "LCS2020000",
5+
"age": "19",
6+
"hobbies": ["reading", "writing", "playing badminton", "singing"]
7+
}
8+
]

‎public/index.html

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
7+
<title>FOSS Weekend Participants API</title>
8+
</head>
9+
<body>
10+
<p>Endpoint is <a href="./profiles">/profiles</a></p>
11+
</body>
12+
</html>

‎routes/profiles.js

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
const data = require('../profiles.json')
2+
const express = require("express")
3+
const router = express.Router()
4+
5+
// router.get('/:language', (req, res) => { // returns hello world program in the requested language
6+
// const result = data.find(code => code.language_name.toLowerCase() === req.params.language.toLowerCase())
7+
// if(result) res.send(result)
8+
// else res.sendStatus(404)
9+
// })
10+
11+
router.get('/', (req, res) => { // returns profiles of all the participants
12+
res.send(data)
13+
})
14+
15+
module.exports = router

‎server.js

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
2+
const express = require("express")
3+
const app = express()
4+
5+
app.use(express.json())
6+
app.use(express.static('public'))
7+
8+
const profilesRouter = require("./routes/profiles")
9+
10+
app.use("/profiles", profilesRouter)
11+
12+
app.listen(process.env.PORT || 3000, () => {
13+
console.log("listening at http://localhost:3000/ in development")
14+
})

0 commit comments

Comments
 (0)
Please sign in to comment.