-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
incorporated DB, starting to layout svcs
- Loading branch information
Showing
16 changed files
with
442 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
"use strict"; | ||
class Service { | ||
} | ||
exports.Service = Service; | ||
; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
"use strict"; | ||
class Service { | ||
} | ||
exports.Service = Service; | ||
; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
"use strict"; | ||
const Datastore = require("nedb"); | ||
class Model { | ||
} | ||
exports.Model = Model; | ||
; | ||
class Service { | ||
constructor() { | ||
this.db = new Datastore({ filename: "./users.db", autoload: true }); | ||
} | ||
signup(user) { | ||
return new Promise((resolve, reject) => this.db.insert(user, (err, document) => { | ||
if (err) { | ||
return reject(err); | ||
} | ||
return resolve(); | ||
})); | ||
} | ||
; | ||
login(username, password) { | ||
return new Promise((resolve, reject) => this.db.findOne({ | ||
username: username, password: password | ||
}, (err, document) => { | ||
if (err) { | ||
return reject(err); | ||
} | ||
else { | ||
return resolve(document); | ||
} | ||
})); | ||
} | ||
; | ||
} | ||
exports.Service = Service; | ||
; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export class Service { | ||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export class Service { | ||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import Datastore = require("nedb"); | ||
|
||
export class Model { | ||
username: string; | ||
password: string; | ||
}; | ||
|
||
export class Service { | ||
db: Datastore; | ||
constructor() { | ||
this.db = new Datastore({filename: "./users.db", autoload: true}); | ||
} | ||
signup(user: Model): Promise<any> { | ||
return new Promise((resolve,reject) => this.db.insert(user, (err,document) => { | ||
if (err) { | ||
return reject(err); | ||
} | ||
return resolve(); | ||
})); | ||
}; | ||
login(username: string, password: string): Promise<Model> { | ||
return new Promise<Model>((resolve,reject) => this.db.findOne({ | ||
username: username, password: password | ||
}, (err,document) => { | ||
if (err) { | ||
return reject(err); | ||
} | ||
else { | ||
return resolve(document as Model); | ||
} | ||
})); | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,9 @@ | ||
{ | ||
"name": "smartbnbkit-backend", | ||
"dependencies": {} | ||
"dependencies": { | ||
"es6-promise": "registry:npm/es6-promise#3.0.0+20160723033700" | ||
}, | ||
"globalDependencies": { | ||
"nedb": "registry:dt/nedb#0.0.0+20160505185910" | ||
} | ||
} |
Oops, something went wrong.