Skip to content

Commit

Permalink
Add models
Browse files Browse the repository at this point in the history
  • Loading branch information
Giovanni Olivera committed Jan 16, 2018
1 parent 1d62827 commit c1789b5
Show file tree
Hide file tree
Showing 8 changed files with 348 additions and 15 deletions.
226 changes: 222 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"config": "^1.28.1",
"express": "4.13.4",
"maxmind": "^2.4.0",
"mongoose": "^4.13.9",
"webpack": "^3.6.0"
},
"devDependencies": {
Expand Down
4 changes: 3 additions & 1 deletion server.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
require("babel-register")
require("./src/app.js")
const App = require("./src/app.js")

App.run()
16 changes: 16 additions & 0 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import Server from "~/Server"
import config from "config"
import maxmind from "maxmind"
import path from "path"

const App = {
run() {
maxmind.open(path.join(__dirname, "/geoip/GeoLite2-City.mmdb"), (err, iplookup) => {
if(err) throw err;
const server = new Server(config.get("listen"))
server.start()
});
}
}.freeze;

export default App;
22 changes: 22 additions & 0 deletions src/Models/Mongo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import Mongoose from "mongoose"
Mongoose.Promise = global.Promise

const Mongo = {
connect(conn_str) {
const mongo = Mongoose.connect(
conn_str,
{
useMongoClient: true
},
err => {
if (err) {
console.error("Could not connect to MongoDB on port 27017")
}
}
)

return mongo
}
}.freeze()

export default Mongo
Loading

0 comments on commit c1789b5

Please sign in to comment.