Skip to content
This repository has been archived by the owner on Jan 9, 2023. It is now read-only.

Commit

Permalink
📦 (openapi) Updating Generated Code
Browse files Browse the repository at this point in the history
  • Loading branch information
PhearZero committed Sep 12, 2019
1 parent e0bf74d commit 4588fe3
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 47 deletions.
10 changes: 5 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export { User } from './model/user'
import UserService from './service/user'

export {
UserService,
export { User } from './model/user'
import UserService from './service/user'

export {
UserService,
}
85 changes: 43 additions & 42 deletions src/service/user.ts
Original file line number Diff line number Diff line change
@@ -1,42 +1,43 @@
import PouchDB from 'pouchdb'
import { User } from '../model/user'
import Service, {DatabaseSync} from '../Service'
export default class UserService implements Service {
dbs: DatabaseSync = {
cache: new PouchDB<PouchDB.Core.Document<User>>('user'),
remote: new PouchDB<PouchDB.Core.Document<User>>('https://app.hospitalrun.io/next/user'),
master: new PouchDB<PouchDB.Core.Document<User>>('https://app.hospitalrun.io/next/master')
}
constructor(sync: any){
if(sync) {
this.dbs.cache.sync(this.dbs.remote, {
live: true,
retry: true
}).on('change', function (change: any) {
// yo, something changed!
}).on('paused', function (info: any) {
// replication was paused, usually because of a lost connection
}).on('active', function (info: any) {
// replication was resumed
}).on('error', function (err: any) {
// totally unhandled error (shouldn't happen)
});
}
}

/**
* Search for a User in the Database
*/
findUser({
}: User){
return this.dbs.cache.get(...arguments)
}
/**
* Search for a User in the Database
*/
findUserById({
id
}: User){
return this.dbs.cache.get(...arguments)
}
}
import PouchDB from 'pouchdb'
import { User } from '../model/user'
import Service, {DatabaseSync} from '../Service'
export default class UserService implements Service {
dbs: DatabaseSync = {
// TODO: Move db config to constructor OR setup helper to tell if we are NodeJS/Browser and prefix filepath in Node
cache: new PouchDB<PouchDB.Core.Document<User>>('./.data/user'),
remote: new PouchDB<PouchDB.Core.Document<User>>('https://app.hospitalrun.io/next/user'),
master: new PouchDB<PouchDB.Core.Document<User>>('https://app.hospitalrun.io/next/master')
}
constructor(sync: any){
if(sync) {
//this.dbs.cache.sync(this.dbs.remote, {
// live: true,
// retry: true
//}).on('change', function (change: any) {
// // yo, something changed!
//}).on('paused', function (info: any) {
// // replication was paused, usually because of a lost connection
//}).on('active', function (info: any) {
// // replication was resumed
//}).on('error', function (err: any) {
// // totally unhandled error (shouldn't happen)
//});
}
}

/**
* Search for a User in the Database
*/
findUser({
}: User){
return this.dbs.cache.get(...arguments)
}
/**
* Search for a User in the Database
*/
findUserById({
id
}: User){
return this.dbs.cache.get(...arguments)
}
}

0 comments on commit 4588fe3

Please sign in to comment.