Skip to content

Commit

Permalink
Initial Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Gael Leblan committed Aug 28, 2020
1 parent 1219e72 commit cc997a6
Show file tree
Hide file tree
Showing 7 changed files with 242 additions and 40 deletions.
3 changes: 3 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ const port = 3000;
const nodeSlicer = require('./slicers/slic3r/slic3r');
const prusaSlicer = require('./slicers/prusaslicer/prusaslicer');
const converter = require('./utils/converter');
const database = require('./utils/database');

const express = require('express')
const app = express()
const fs = require('fs-extra');
const compression = require('compression')
const cors = require('cors')

// compress responses
app.use(compression())
// default options
Expand Down Expand Up @@ -81,5 +83,6 @@ app.get('/public/profiles', function(req, res) {
});

app.listen(port, hostname, () => {
database.init(undefined, () => {})
console.log(`Server running at http://${hostname}:${port}/`);
});
12 changes: 12 additions & 0 deletions db/schema/user.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
var mongoose = require('mongoose');
var Schema = mongoose.Schema;
var user = {};

var userSchema = new Schema({
name: String,
mail: String
});

user.schema = userSchema;

module.exports = user;
Empty file added db/service/userService.js
Empty file.
40 changes: 0 additions & 40 deletions npm-debug.log

This file was deleted.

204 changes: 204 additions & 0 deletions package-lock.json

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

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
"fs-extra": "^9.0.1",
"js-yaml": "^3.2.5",
"json-schema-defaults": "0.0.2",
"mongodb": "^3.6.0",
"mongoose": "^5.10.0",
"temp": "^0.8.1",
"tv4": "^1.1.5"
}
Expand Down
21 changes: 21 additions & 0 deletions utils/database.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
var database = {};
const uri = "mongodb://localhost/baldr-db"
const mongoose = require('mongoose');

database.init = function(config, callback) {
mongoose.connect(uri, {
useNewUrlParser: true
});
const db = mongoose.connection;
db.on('error', function() {
console.log("Error while connecting to database")
callback(false);
});
db.once('open', function() {
// we're connected!
console.log("Connected to database")
callback(true);
});
}

module.exports = database;

0 comments on commit cc997a6

Please sign in to comment.