Skip to content

Commit

Permalink
Create express server.
Browse files Browse the repository at this point in the history
  • Loading branch information
usbpendrive committed Jun 23, 2018
1 parent 1155a18 commit e7de0ac
Show file tree
Hide file tree
Showing 5 changed files with 162 additions and 9 deletions.
4 changes: 4 additions & 0 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
DB_HOST=
DB_NAME=
DB_USER=
DB_PASSWORD=
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ yarn-error.log*
/test/unit/coverage/
/test/e2e/reports/
selenium-debug.log
/.env

# Editor directories and files
.idea
Expand Down
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@
"dependencies": {
"bootstrap": "^4.1.1",
"bootstrap-vue": "^2.0.0-rc.11",
"cors": "^2.8.4",
"dotenv": "^6.0.0",
"express": "^4.16.3",
"mongoose": "^5.1.6",
"morgan": "^1.9.0",
"vue": "^2.5.2",
"vue-router": "^3.0.1",
"vuetify": "^1.0.19"
Expand Down
35 changes: 35 additions & 0 deletions server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
require('dotenv').config();
const express = require('express');
const mongoose = require('mongoose');
const cors = require('cors');
const morgan = require('morgan');
const fs = require('fs');

const app = express();
const router = express.Router();
app.use(morgan('combined'));
app.use(express.json());
app.use(cors());

const dbHost = process.env.DB_HOST;
const dbName = process.env.DB_NAME;
const dbUser = process.env.DB_USER;
const dbPass = process.env.DB_PASSWORD;

mongoose.connect(`mongodb://${dbUser}:${dbPass}@${dbHost}/${dbName}`, function () {
console.log('Connected to MongoDB');
})
.catch(err => {
console.error('App starting error', err.stack);
process.exit(1);
});

router.get('/', function (req, res) {
res.json({ message: 'Welcome to Movie Rating API' });
});

const port = process.env.PORT || 8081;
app.use('/', router);
app.listen(port, function () {
console.log(`API running on port ${port}`);
});
126 changes: 117 additions & 9 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ [email protected], async@^1.4.0, async@^1.5.2:
version "1.5.2"
resolved "https://registry.yarnpkg.com/async/-/async-1.5.2.tgz#ec6a61ae56480c0c3cb241c95618e20892f9672a"

async@^2.0.0, async@^2.1.2, async@^2.4.1:
async@2.6.1, async@^2.0.0, async@^2.1.2, async@^2.4.1:
version "2.6.1"
resolved "https://registry.yarnpkg.com/async/-/async-2.6.1.tgz#b245a23ca71930044ec53fa46aa00a3e87c6a610"
dependencies:
Expand Down Expand Up @@ -1053,6 +1053,12 @@ base@^0.11.1:
mixin-deep "^1.2.0"
pascalcase "^0.1.1"

basic-auth@~2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/basic-auth/-/basic-auth-2.0.0.tgz#015db3f353e02e56377755f962742e8981e7bbba"
dependencies:
safe-buffer "5.1.1"

[email protected]:
version "0.6.1"
resolved "https://registry.yarnpkg.com/batch/-/batch-0.6.1.tgz#dc34314f4e679318093fc760272525f94bf25c16"
Expand Down Expand Up @@ -1089,6 +1095,10 @@ [email protected]:
version "0.0.4"
resolved "https://registry.yarnpkg.com/blob/-/blob-0.0.4.tgz#bcf13052ca54463f30f9fc7e95b9a47630a94921"

[email protected]:
version "3.5.0"
resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.5.0.tgz#791420d7f551eea2897453a8a77653f96606d67c"

bluebird@^3.1.1, bluebird@^3.3.0, bluebird@^3.4.7, bluebird@^3.5.1:
version "3.5.1"
resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.5.1.tgz#d9551f9de98f1fcda1e683d17ee91a0602ee2eb9"
Expand Down Expand Up @@ -1274,6 +1284,10 @@ browserslist@^3.2.6:
caniuse-lite "^1.0.30000844"
electron-to-chromium "^1.3.47"

bson@~1.0.4, bson@~1.0.5:
version "1.0.9"
resolved "https://registry.yarnpkg.com/bson/-/bson-1.0.9.tgz#12319f8323b1254739b7c6bef8d3e89ae05a2f57"

buffer-from@^1.0.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.0.tgz#87fcaa3a298358e0ade6e442cfce840740d1ad04"
Expand Down Expand Up @@ -1815,6 +1829,13 @@ [email protected], core-util-is@~1.0.0:
version "1.0.2"
resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7"

cors@^2.8.4:
version "2.8.4"
resolved "https://registry.yarnpkg.com/cors/-/cors-2.8.4.tgz#2bd381f2eb201020105cd50ea59da63090694686"
dependencies:
object-assign "^4"
vary "^1"

cosmiconfig@^2.1.0, cosmiconfig@^2.1.1:
version "2.2.2"
resolved "https://registry.yarnpkg.com/cosmiconfig/-/cosmiconfig-2.2.2.tgz#6173cebd56fac042c1f4390edf7af6c07c7cb892"
Expand Down Expand Up @@ -2315,6 +2336,10 @@ [email protected]:
dom-serializer "0"
domelementtype "1"

dotenv@^6.0.0:
version "6.0.0"
resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-6.0.0.tgz#24e37c041741c5f4b25324958ebbc34bca965935"

duplexer@^0.1.1:
version "0.1.1"
resolved "https://registry.yarnpkg.com/duplexer/-/duplexer-0.1.1.tgz#ace6ff808c1ce66b57d1ebf97977acb02334cfc1"
Expand Down Expand Up @@ -2839,7 +2864,7 @@ expand-range@^1.8.1:
dependencies:
fill-range "^2.1.0"

express@^4.16.2:
express@^4.16.2, express@^4.16.3:
version "4.16.3"
resolved "https://registry.yarnpkg.com/express/-/express-4.16.3.tgz#6af8a502350db3246ecc4becf6b5a34d22f7ed53"
dependencies:
Expand Down Expand Up @@ -4230,6 +4255,10 @@ just-extend@^1.1.27:
version "1.1.27"
resolved "https://registry.yarnpkg.com/just-extend/-/just-extend-1.1.27.tgz#ec6e79410ff914e472652abfa0e603c03d60e905"

[email protected]:
version "2.2.1"
resolved "https://registry.yarnpkg.com/kareem/-/kareem-2.2.1.tgz#9950809415aa3cde62ab43b4f7b919d99816e015"

karma-coverage@^1.1.1:
version "1.1.2"
resolved "https://registry.yarnpkg.com/karma-coverage/-/karma-coverage-1.1.2.tgz#cc09dceb589a83101aca5fe70c287645ef387689"
Expand Down Expand Up @@ -4533,17 +4562,17 @@ [email protected]:
lodash.mergewith "^4.0.0"
lodash.rest "^4.0.0"

[email protected], lodash.get@^4.4.2:
version "4.4.2"
resolved "https://registry.yarnpkg.com/lodash.get/-/lodash.get-4.4.2.tgz#2d177f652fa31e939b4438d5341499dfa3825e99"

lodash.get@^3.7.0:
version "3.7.0"
resolved "https://registry.yarnpkg.com/lodash.get/-/lodash.get-3.7.0.tgz#3ce68ae2c91683b281cc5394128303cbf75e691f"
dependencies:
lodash._baseget "^3.0.0"
lodash._topath "^3.0.0"

lodash.get@^4.4.2:
version "4.4.2"
resolved "https://registry.yarnpkg.com/lodash.get/-/lodash.get-4.4.2.tgz#2d177f652fa31e939b4438d5341499dfa3825e99"

lodash.isarguments@^3.0.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/lodash.isarguments/-/lodash.isarguments-3.1.0.tgz#2f573d85c6a24289ff00663b491c1d338ff3458a"
Expand Down Expand Up @@ -4915,6 +4944,49 @@ mocha@^3.2.0:
mkdirp "0.5.1"
supports-color "3.1.2"

[email protected]:
version "3.0.9"
resolved "https://registry.yarnpkg.com/mongodb-core/-/mongodb-core-3.0.9.tgz#8327410c88811013fb3e4ac7c4c670f324349be1"
dependencies:
bson "~1.0.4"
require_optional "^1.0.1"

[email protected]:
version "3.0.10"
resolved "https://registry.yarnpkg.com/mongodb/-/mongodb-3.0.10.tgz#f948cb9595adcbfcad7444f6b24a040b653b23e8"
dependencies:
mongodb-core "3.0.9"

[email protected]:
version "1.0.2"
resolved "https://registry.yarnpkg.com/mongoose-legacy-pluralize/-/mongoose-legacy-pluralize-1.0.2.tgz#3ba9f91fa507b5186d399fb40854bff18fb563e4"

mongoose@^5.1.6:
version "5.1.6"
resolved "https://registry.yarnpkg.com/mongoose/-/mongoose-5.1.6.tgz#af92762c1e0317c897435594e83d6a5952873a0e"
dependencies:
async "2.6.1"
bson "~1.0.5"
kareem "2.2.1"
lodash.get "4.4.2"
mongodb "3.0.10"
mongoose-legacy-pluralize "1.0.2"
mpath "0.4.1"
mquery "3.0.0"
ms "2.0.0"
regexp-clone "0.0.1"
sliced "1.0.1"

morgan@^1.9.0:
version "1.9.0"
resolved "https://registry.yarnpkg.com/morgan/-/morgan-1.9.0.tgz#d01fa6c65859b76fcf31b3cb53a3821a311d8051"
dependencies:
basic-auth "~2.0.0"
debug "2.6.9"
depd "~1.1.1"
on-finished "~2.3.0"
on-headers "~1.0.1"

move-concurrently@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/move-concurrently/-/move-concurrently-1.0.1.tgz#be2c005fda32e0b29af1f05d7c4b33214c701f92"
Expand All @@ -4926,6 +4998,19 @@ move-concurrently@^1.0.1:
rimraf "^2.5.4"
run-queue "^1.0.3"

[email protected]:
version "0.4.1"
resolved "https://registry.yarnpkg.com/mpath/-/mpath-0.4.1.tgz#ed10388430380bf7bbb5be1391e5d6969cb08e89"

[email protected]:
version "3.0.0"
resolved "https://registry.yarnpkg.com/mquery/-/mquery-3.0.0.tgz#e5f387dbabc0b9b69859e550e810faabe0ceabb0"
dependencies:
bluebird "3.5.0"
debug "2.6.9"
regexp-clone "0.0.1"
sliced "0.0.5"

[email protected]:
version "0.7.1"
resolved "https://registry.yarnpkg.com/ms/-/ms-0.7.1.tgz#9cd13c03adbff25b65effde7ce864ee952017098"
Expand Down Expand Up @@ -5189,7 +5274,7 @@ [email protected]:
version "4.1.0"
resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.0.tgz#7a3b3d0e98063d43f4c03f2e8ae6cd51a86883a0"

object-assign@^4.0.1, object-assign@^4.1.0, object-assign@^4.1.1:
object-assign@^4, object-assign@^4.0.1, object-assign@^4.1.0, object-assign@^4.1.1:
version "4.1.1"
resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863"

Expand Down Expand Up @@ -6264,6 +6349,10 @@ regex-not@^1.0.0, regex-not@^1.0.2:
extend-shallow "^3.0.2"
safe-regex "^1.1.0"

[email protected]:
version "0.0.1"
resolved "https://registry.yarnpkg.com/regexp-clone/-/regexp-clone-0.0.1.tgz#a7c2e09891fdbf38fbb10d376fb73003e68ac589"

regexpp@^1.0.1:
version "1.1.0"
resolved "https://registry.yarnpkg.com/regexpp/-/regexpp-1.1.0.tgz#0e3516dd0b7904f413d2d4193dce4618c3a689ab"
Expand Down Expand Up @@ -6380,6 +6469,13 @@ require-uncached@^1.0.3:
caller-path "^0.1.0"
resolve-from "^1.0.0"

require_optional@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/require_optional/-/require_optional-1.0.1.tgz#4cf35a4247f64ca3df8c2ef208cc494b1ca8fc2e"
dependencies:
resolve-from "^2.0.0"
semver "^5.1.0"

requires-port@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/requires-port/-/requires-port-1.0.0.tgz#925d2601d39ac485e091cf0da5c6e694dc3dcaff"
Expand All @@ -6394,6 +6490,10 @@ resolve-from@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-1.0.1.tgz#26cbfe935d1aeeeabb29bc3fe5aeb01e93d44226"

resolve-from@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-2.0.0.tgz#9480ab20e94ffa1d9e80a804c7ea147611966b57"

resolve-from@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-3.0.0.tgz#b22c7af7d9d6881bc8b6e653335eebcb0a188748"
Expand Down Expand Up @@ -6521,7 +6621,7 @@ selfsigned@^1.9.1:
dependencies:
node-forge "0.7.5"

"semver@2 || 3 || 4 || 5", semver@^5.3.0, semver@^5.4.1, semver@^5.5.0:
"semver@2 || 3 || 4 || 5", semver@^5.1.0, semver@^5.3.0, semver@^5.4.1, semver@^5.5.0:
version "5.5.0"
resolved "https://registry.yarnpkg.com/semver/-/semver-5.5.0.tgz#dc4bbc7a6ca9d916dee5d43516f0092b58f7b8ab"

Expand Down Expand Up @@ -6673,6 +6773,14 @@ [email protected]:
dependencies:
is-fullwidth-code-point "^2.0.0"

[email protected]:
version "0.0.5"
resolved "https://registry.yarnpkg.com/sliced/-/sliced-0.0.5.tgz#5edc044ca4eb6f7816d50ba2fc63e25d8fe4707f"

[email protected]:
version "1.0.1"
resolved "https://registry.yarnpkg.com/sliced/-/sliced-1.0.1.tgz#0b3a662b5d04c3177b1926bea82b03f837a2ef41"

smart-buffer@^1.0.13:
version "1.1.15"
resolved "https://registry.yarnpkg.com/smart-buffer/-/smart-buffer-1.1.15.tgz#7f114b5b65fab3e2a35aa775bb12f0d1c649bf16"
Expand Down Expand Up @@ -7443,7 +7551,7 @@ validate-npm-package-license@^3.0.1:
spdx-correct "^3.0.0"
spdx-expression-parse "^3.0.0"

vary@~1.1.2:
vary@^1, vary@~1.1.2:
version "1.1.2"
resolved "https://registry.yarnpkg.com/vary/-/vary-1.1.2.tgz#2299f02c6ded30d4a5961b0b9f74524a18f634fc"

Expand Down

0 comments on commit e7de0ac

Please sign in to comment.