임태민

Update app.js

- check the url mapping
1 const express = require('express'); 1 const express = require('express');
2 const bodyParser = require('body-parser'); 2 const bodyParser = require('body-parser');
3 - 3 +const session = require('express-session');
4 const app = express(); 4 const app = express();
5 5
6 app.use(bodyParser.json()); 6 app.use(bodyParser.json());
...@@ -16,40 +16,48 @@ app.use(session({ ...@@ -16,40 +16,48 @@ app.use(session({
16 app.get('/', function(req,res){ 16 app.get('/', function(req,res){
17 res.send("Home page"); 17 res.send("Home page");
18 }) 18 })
19 +
19 //login 20 //login
20 app.put('/login',function(req,res){ 21 app.put('/login',function(req,res){
21 res.send("Login page"); 22 res.send("Login page");
22 }) 23 })
24 +
23 //logout 25 //logout
24 app.put('/logout',function(req,res){ 26 app.put('/logout',function(req,res){
25 res.send("Logout page"); 27 res.send("Logout page");
26 }) 28 })
29 +
27 //register 30 //register
28 app.post('/register',function(req,res){ 31 app.post('/register',function(req,res){
29 - res.send('register page'); 32 + res.send('Register page');
30 }) 33 })
34 +
31 //Mapmain 35 //Mapmain
32 app.get('/Mapmain',function(req,res){ 36 app.get('/Mapmain',function(req,res){
33 res.send('Mapmain page'); 37 res.send('Mapmain page');
34 }) 38 })
39 +
35 //Read post 40 //Read post
36 app.get('/Mapmain/posts/:postId',function(req,res){ 41 app.get('/Mapmain/posts/:postId',function(req,res){
37 var postId = req.params.postId; 42 var postId = req.params.postId;
38 - res.send("Mapmain post page", postId); 43 + res.send("Mapmain post page " + postId);
39 }) 44 })
45 +
40 //Create post 46 //Create post
41 app.post('/Mapmain/posts',function(req,res){ 47 app.post('/Mapmain/posts',function(req,res){
42 res.send("Mapmain create page"); 48 res.send("Mapmain create page");
43 }) 49 })
50 +
44 //Update post 51 //Update post
45 app.put('/Mapmain/posts/:postId',function(req,res){ 52 app.put('/Mapmain/posts/:postId',function(req,res){
46 var postId = req.params.postId; 53 var postId = req.params.postId;
47 - res.send("Mapmain update page"); 54 + res.send("Mapmain update page " + postId);
48 }) 55 })
56 +
49 //Delete post 57 //Delete post
50 app.delete('/Mapmain/posts/:postId',function(req,res){ 58 app.delete('/Mapmain/posts/:postId',function(req,res){
51 var postId = req.params.postId; 59 var postId = req.params.postId;
52 - res.send("Mapmain update page"); 60 + res.send("Mapmain delete page " + postId);
53 }) 61 })
54 //Mapmain/category/:_category 62 //Mapmain/category/:_category
55 //Mapmain/post/:_pk 63 //Mapmain/post/:_pk
......
This diff is collapsed. Click to expand it.
1 { 1 {
2 - "name": "mapmory", 2 + "name": "Mapmory",
3 "version": "1.0.0", 3 "version": "1.0.0",
4 "description": "", 4 "description": "",
5 "main": "app.js", 5 "main": "app.js",
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
12 "body-parser": "^1.19.0", 12 "body-parser": "^1.19.0",
13 "express": "^4.17.1", 13 "express": "^4.17.1",
14 "express-session": "^1.17.1", 14 "express-session": "^1.17.1",
15 - "mysql": "^2.18.1" 15 + "mysql": "^2.18.1",
16 + "package.json": "^2.0.1"
16 } 17 }
17 } 18 }
......