aboutsummaryrefslogtreecommitdiff
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
parentc4619eb6d3fb3b9df5d921250391bb49700f055d (diff)
parent1fbf5ffbabc1ea2924e68c735e4d2b87643b5fc0 (diff)
downloadwhich-api-08994137ddbeee5c3d407c215575e9681fd3962b.tar.gz
Merge pull request #13 from which-ecosystem/deployment
Setup project for Heroku deployment
-rw-r--r--index.ts15
-rw-r--r--package-lock.json54
-rw-r--r--package.json18
-rw-r--r--populateDb.ts10
4 files changed, 83 insertions, 14 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}`));
diff --git a/package-lock.json b/package-lock.json
index 6a3838a..779e864 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -458,6 +458,11 @@
"color-convert": "^1.9.0"
}
},
+ "arg": {
+ "version": "4.1.3",
+ "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz",
+ "integrity": "sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA=="
+ },
"argparse": {
"version": "1.0.10",
"resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz",
@@ -614,6 +619,11 @@
"resolved": "https://registry.npmjs.org/buffer-equal-constant-time/-/buffer-equal-constant-time-1.0.1.tgz",
"integrity": "sha1-+OcRMvf/5uAaXJaXpMbz5I1cyBk="
},
+ "buffer-from": {
+ "version": "1.1.1",
+ "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz",
+ "integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A=="
+ },
"bytes": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.0.tgz",
@@ -855,6 +865,11 @@
"resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz",
"integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA="
},
+ "diff": {
+ "version": "4.0.2",
+ "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz",
+ "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A=="
+ },
"doctrine": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/doctrine/-/doctrine-3.0.0.tgz",
@@ -1933,6 +1948,11 @@
"resolved": "https://registry.npmjs.org/long-timeout/-/long-timeout-0.1.1.tgz",
"integrity": "sha1-lyHXiLR+C8taJMLivuGg2lXatRQ="
},
+ "make-error": {
+ "version": "1.3.6",
+ "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz",
+ "integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw=="
+ },
"media-typer": {
"version": "0.3.0",
"resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz",
@@ -2703,6 +2723,20 @@
"isarray": "2.0.1"
}
},
+ "source-map": {
+ "version": "0.6.1",
+ "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
+ "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g=="
+ },
+ "source-map-support": {
+ "version": "0.5.19",
+ "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.19.tgz",
+ "integrity": "sha512-Wonm7zOCIJzBGQdB+thsPar0kYuCIzYvxZwlBa87yi/Mdjv7Tip2cyVbLj5o0cFPN4EVkuTwb3GDDyUx2DGnGw==",
+ "requires": {
+ "buffer-from": "^1.0.0",
+ "source-map": "^0.6.0"
+ }
+ },
"sparse-bitfield": {
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/sparse-bitfield/-/sparse-bitfield-3.0.3.tgz",
@@ -2929,6 +2963,18 @@
"resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.0.tgz",
"integrity": "sha512-yaOH/Pk/VEhBWWTlhI+qXxDFXlejDGcQipMlyxda9nthulaxLZUNcUqFxokp0vcYnvteJln5FNQDRrxj3YcbVw=="
},
+ "ts-node": {
+ "version": "8.10.2",
+ "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-8.10.2.tgz",
+ "integrity": "sha512-ISJJGgkIpDdBhWVu3jufsWpK3Rzo7bdiIXJjQc0ynKxVOVcg2oIrf2H2cejminGrptVc6q6/uynAHNCuWGbpVA==",
+ "requires": {
+ "arg": "^4.1.0",
+ "diff": "^4.0.1",
+ "make-error": "^1.1.1",
+ "source-map-support": "^0.5.17",
+ "yn": "3.1.1"
+ }
+ },
"tsconfig-paths": {
"version": "3.9.0",
"resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-3.9.0.tgz",
@@ -2983,8 +3029,7 @@
"typescript": {
"version": "3.9.5",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-3.9.5.tgz",
- "integrity": "sha512-hSAifV3k+i6lEoCJ2k6R2Z/rp/H3+8sdmcn5NrS3/3kE7+RyZXm9aqvxWqjEXHAd8b0pShatpcdMTvEdvAJltQ==",
- "dev": true
+ "integrity": "sha512-hSAifV3k+i6lEoCJ2k6R2Z/rp/H3+8sdmcn5NrS3/3kE7+RyZXm9aqvxWqjEXHAd8b0pShatpcdMTvEdvAJltQ=="
},
"uberproto": {
"version": "2.0.6",
@@ -3090,6 +3135,11 @@
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/yeast/-/yeast-0.1.2.tgz",
"integrity": "sha1-AI4G2AlDIMNy28L47XagymyKxBk="
+ },
+ "yn": {
+ "version": "3.1.1",
+ "resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz",
+ "integrity": "sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q=="
}
}
}
diff --git a/package.json b/package.json
index c6e4038..ca39263 100644
--- a/package.json
+++ b/package.json
@@ -3,6 +3,7 @@
"version": "1.0.0",
"main": "index.ts",
"scripts": {
+ "start": "ts-node index.ts",
"lint": "eslint . --ext ts --max-warnings 0",
"test": "npm run lint"
},
@@ -18,11 +19,19 @@
"@feathersjs/feathers": "^4.5.3",
"@feathersjs/socketio": "^4.5.4",
"@feathersjs/transport-commons": "^4.5.3",
+ "@types/bluebird": "^3.5.32",
+ "@types/cors": "^2.8.6",
+ "@types/lodash": "^4.14.155",
+ "@types/mongoose": "^5.7.23",
+ "@typescript-eslint/eslint-plugin": "^3.2.0",
+ "@typescript-eslint/parser": "^3.2.0",
"bluebird": "^3.7.2",
"cors": "^2.8.5",
"feathers-mongoose": "^8.3.0",
"lodash": "^4.17.15",
"mongoose": "^5.9.18",
+ "ts-node": "^8.10.2",
+ "typescript": "^3.9.5",
"which-types": "^1.4.1"
},
"repository": {
@@ -35,15 +44,8 @@
"homepage": "https://github.com/eug-vs/which-api#readme",
"description": "",
"devDependencies": {
- "@types/bluebird": "^3.5.32",
- "@types/cors": "^2.8.6",
- "@types/lodash": "^4.14.155",
- "@types/mongoose": "^5.7.23",
- "@typescript-eslint/eslint-plugin": "^3.2.0",
- "@typescript-eslint/parser": "^3.2.0",
"eslint": "^7.2.0",
"eslint-config-airbnb-typescript": "^8.0.2",
- "eslint-plugin-import": "^2.21.2",
- "typescript": "^3.9.5"
+ "eslint-plugin-import": "^2.21.2"
}
}
diff --git a/populateDb.ts b/populateDb.ts
index e978403..b3e46af 100644
--- a/populateDb.ts
+++ b/populateDb.ts
@@ -5,7 +5,15 @@ import { User, Poll, Vote } from 'which-types';
import app from './app';
-mongoose.connect('mongodb://localhost:27017/which', { useNewUrlParser: true });
+const MONGODB_URL = process.env.MONGODB_URI || 'mongodb://localhost:27017/which';
+
+mongoose.connect(MONGODB_URL, {
+ useNewUrlParser: true,
+ useUnifiedTopology: true,
+ useCreateIndex: true,
+ useFindAndModify: false,
+ family: 4 // Use IPv4, skip trying IPv6
+});
const POLLS_AMOUNT = 20;