Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
S
shop-api-js5
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Vadim
shop-api-js5
Commits
4f3d0f3e
Commit
4f3d0f3e
authored
Nov 26, 2020
by
Vadim
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixup! Конец занятия 74
parent
851d1c8a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
0 deletions
+33
-0
products.js
app/products.js
+21
-0
server.js
server.js
+12
-0
No files found.
app/products.js
View file @
4f3d0f3e
const
express
=
require
(
'express'
);
const
router
=
express
.
Router
();
const
db
=
require
(
'./db/fileDb'
);
db
.
init
();
router
.
get
(
'/'
,
(
req
,
res
)
=>
{
res
.
send
(
'List of products will be here'
)
});
router
.
get
(
'/:id'
,
(
req
,
res
)
=>
{
res
.
send
(
'Single product will be here'
+
req
.
params
.
id
)
});
router
.
post
(
'/'
,
(
req
,
res
)
=>
{
console
.
log
(
'Create product'
,
req
.
body
);
db
.
addItem
(
req
.
body
);
res
.
send
(
'Create product will be here'
)
});
module
.
exports
=
router
;
\ No newline at end of file
server.js
View file @
4f3d0f3e
const
express
=
require
(
'express'
);
const
products
=
require
(
'./app/products'
);
const
app
=
express
();
const
port
=
8000
;
app
.
use
(
express
.
json
())
app
.
use
(
'/products'
,
products
);
app
.
listen
(
port
,
()
=>
{
console
.
log
(
`Server started on port
${
port
}
`
)
});
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment