Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation
This project
Loading...
Sign in
hfpp2012
/
merng
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 0f154540
authored
Sep 12, 2019
by
qiuzhi99
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
add mongodb database
1 parent
769951e1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
2 deletions
index.js
readme.md
index.js
View file @
0f15454
...
...
@@ -2,6 +2,8 @@ const { ApolloServer } = require("apollo-server");
const
gql
=
require
(
"graphql-tag"
);
const
mongoose
=
require
(
"mongoose"
);
const
typeDefs
=
gql
`
type Query {
sayHi: String!
...
...
@@ -19,6 +21,14 @@ const server = new ApolloServer({
resolvers
});
server
.
listen
({
port
:
5001
}).
then
(
res
=>
{
mongoose
.
connect
(
"mongodb://test:A12345678@ds119820.mlab.com:19820/merng"
,
{
useNewUrlParser
:
true
})
.
then
(()
=>
{
console
.
log
(
"MongoDB Connected"
);
return
server
.
listen
({
port
:
5001
});
})
.
then
(
res
=>
{
console
.
log
(
`Server running at
${
res
.
url
}
`
);
});
});
readme.md
0 → 100644
View file @
0f15454
File mode changed
Write
Preview
Markdown
is supported
Attach a file
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 post a comment