aboutsummaryrefslogtreecommitdiff
path: root/index.ts
diff options
context:
space:
mode:
authorEugene Sokolov <eug-vs@keemail.me>2020-06-27 00:19:17 +0300
committerGitHub <noreply@github.com>2020-06-27 00:19:17 +0300
commit08994137ddbeee5c3d407c215575e9681fd3962b (patch)
tree76eafd1739ca8e85882990ad8b8c50626ad450ce /index.ts
parentc4619eb6d3fb3b9df5d921250391bb49700f055d (diff)
parent1fbf5ffbabc1ea2924e68c735e4d2b87643b5fc0 (diff)
downloadwhich-api-08994137ddbeee5c3d407c215575e9681fd3962b.tar.gz
Merge pull request #13 from which-ecosystem/deployment
Setup project for Heroku deployment
Diffstat (limited to 'index.ts')
-rw-r--r--index.ts15
1 files changed, 12 insertions, 3 deletions
diff --git a/index.ts b/index.ts
index 8b01536..9ba0431 100644
--- a/index.ts
+++ b/index.ts
@@ -4,7 +4,17 @@ import app from './app';
mongoose.Promise = Promise;
-mongoose.connect('mongodb://localhost:27017/which', { useNewUrlParser: true });
+
+const MONGODB_URL = process.env.MONGODB_URI || 'mongodb://localhost:27017/which';
+const PORT = process.env.PORT || 3030;
+
+mongoose.connect(MONGODB_URL, {
+ useNewUrlParser: true,
+ useUnifiedTopology: true,
+ useCreateIndex: true,
+ useFindAndModify: false,
+ family: 4 // Use IPv4, skip trying IPv6
+});
const db = mongoose.connection;
db.on('error', console.error.bind(console, 'connection error:'));
@@ -18,6 +28,5 @@ app.on('connection', connection => app.channel('everybody').join(connection));
app.publish(() => app.channel('everybody'));
-const port = 3030;
-app.listen(port).on('listening', () => console.log(`Feathers server listening on localhost:${port}`));
+app.listen(PORT).on('listening', () => console.log(`Feathers server listening on localhost:${PORT}`));