Skip to content

Commit 198c748

Browse files
Yasin YaqoobiYasin Yaqoobi
Yasin Yaqoobi
authored and
Yasin Yaqoobi
committed
simple api for addProfile
1 parent 9866159 commit 198c748

File tree

3 files changed

+47
-1
lines changed

3 files changed

+47
-1
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
.DS_Store
2-
/node_modules/
2+
node_modules/
3+
npm-debug.log

server/index.js

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
var express = require('express');
2+
var app = express();
3+
4+
app.use(function(req, res, next) {
5+
res.header("Access-Control-Allow-Origin", "*");
6+
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
7+
next();
8+
});
9+
10+
11+
app.get('/', function (req, res) {
12+
var json = [
13+
{
14+
name:'David',
15+
age: 30,
16+
bio: 'enjoys swimming and biking',
17+
hobbies: ['swimming','biking'],
18+
},
19+
{
20+
name:'Sara',
21+
age:40,
22+
bio: 'enjoys long walks on the beach',
23+
hobbies: ['gardening', 'games']
24+
}
25+
];
26+
res.send(json);
27+
});
28+
29+
app.listen(3000, function () {
30+
console.log('Example app listening on port 3000!');
31+
});

server/package.json

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"name": "node",
3+
"version": "1.0.0",
4+
"description": "",
5+
"main": "index.js",
6+
"scripts": {
7+
"test": "echo \"Error: no test specified\" && exit 1"
8+
},
9+
"author": "",
10+
"license": "ISC",
11+
"dependencies": {
12+
"express": "^4.14.0"
13+
}
14+
}

0 commit comments

Comments
 (0)