Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
E
exam_11_back
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
zarina
exam_11_back
Commits
da051612
Commit
da051612
authored
Jul 22, 2020
by
Алексей Анпилогов
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#1
, подключила базу, настроила сервер
parent
6dced87a
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
0 deletions
+41
-0
config.js
config.js
+12
-0
server.js
server.js
+29
-0
No files found.
config.js
View file @
da051612
const
path
=
require
(
"path"
);
const
rootPath
=
__dirname
;
module
.
exports
=
{
rootPath
,
uploadPath
:
path
.
join
(
rootPath
,
"public"
,
"uploads"
),
db
:
{
name
:
"shop"
,
url
:
"mongodb://localhost"
}
};
server.js
View file @
da051612
const
express
=
require
(
"express"
);
const
cors
=
require
(
"cors"
);
const
mongoose
=
require
(
"mongoose"
);
const
products
=
require
(
"./app/products"
);
const
categories
=
require
(
"./app/categories"
);
const
users
=
require
(
"./app/users"
);
const
config
=
require
(
"./config"
);
const
app
=
express
();
const
PORT
=
8000
;
app
.
use
(
cors
());
app
.
use
(
express
.
static
(
"public"
));
app
.
use
(
express
.
json
());
mongoose
.
connect
(
`
${
config
.
db
.
url
}
/
${
config
.
db
.
name
}
`
,
{
useNewUrlParser
:
true
})
.
then
(()
=>
{
console
.
log
(
"Mongoose connected!"
);
app
.
use
(
"/products"
,
products
());
app
.
use
(
"/categories"
,
categories
());
app
.
use
(
"/users"
,
users
());
app
.
listen
(
PORT
,
()
=>
{
console
.
log
(
"Server started at http://localhost:"
+
PORT
);
});
});
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