Comments (13)
@dsych Thanks for your contributions to the previous issue! Here's the continuation of it, if you want to work on it as well. I've already marked it as [In Progress] for you.
from licensed-mental-health-counselors-browser.
Here is what I am thinking: we certainly don't want to maintain two separate objects that are describing the Practitioner
, so we can have a base class that describes properties needed for the json. The base will be an es6 class (stored in .js
file inside /server/lib
) and will receive an array which it will proceed to parse or nothing. The derived class will be a typescript class that is stored inside src/components/practitioner.ts
. It will extend the base class and attache additional properties like address
, phone
etc.
This way, once we change anything inside the base class, the db, json signatures and the client side signatures are all in sync.
It will look something like this:
// /server/lib/practitioner.js
class Practitioner {
constructor(raw) {
if (raw && raw.length) {
this.licId = raw[0];
this.expDate = raw[1];
this.orgDate = raw[2];
this.licenseNum = raw[3];
this.statusDate = raw[4];
this.boardAction = raw[5];
...
this.prescriptionIndicator = raw[30];
this.dispensingIndicator = raw[31];
} else {
this.licId = "";
this.expDate = "";
this.orgDate = "";
this.licenseNum = "";
this.statusDate = "";
this.boardAction = "";
...
this.prescriptionIndicator = "";
this.dispensingIndicator = "";
}
}
}
import { Practitioner as P } from "../../server/lib/practitioner"
// /src/components/practitioner.ts
export class Practitioner extends P {
[x: string]: any;
phone: Phone;
mailingAddress: Address;
practiceAddress: Address;
constructor(src) {
super();
Object.keys(src).forEach(key => {
this[key] = src[key];
});
this.mailingAddress = {
line1: this.mailingAddressLine1
...
};
this.phone = {
phoneNum: this.phoneNumber
...
}
}
}
from licensed-mental-health-counselors-browser.
That looks solid to me.
Another option might be to just use typescript on the server!
For development we can use ts-node
as the executable for nodemon
, and for prod we can just compile with babel / typescript into build/
and use "start": "node build/server.js"
from licensed-mental-health-counselors-browser.
If migrating to TS is an option, I think we should do that instead. Makes sense to have server and client code living side by side on the same stack.
Once that is done, I can do proper inheritance between objects as per TS standards. Even though what I proposed above works, I hate the use of call type signatures in this way.
from licensed-mental-health-counselors-browser.
Yeah, definitely an option. I can create a separate ticket for that and work on it tonight, or if you'd like you can take that on as well!
from licensed-mental-health-counselors-browser.
You can go ahead.
from licensed-mental-health-counselors-browser.
Ended up getting home late yesterday. Will work on it tonight!
from licensed-mental-health-counselors-browser.
OK, #10 is closed. Had some issues extending the Express Request -- if you're able to get the declaration merging working properly, I'd be super appreciative! In the meantime we just had to specifically type the req param in our middlewares that access .db
.
from licensed-mental-health-counselors-browser.
From my perspective, looks like it's working properly (at least to vs-code), it just isn't being picked up by the typescript compiler:
from licensed-mental-health-counselors-browser.
So, I did something...
I don't think that's correct, but I'm fine with it for now since it's working.
from licensed-mental-health-counselors-browser.
Np, @Redmega, I will look into it tomorrow.
from licensed-mental-health-counselors-browser.
So saw this entry, definitely confirms that we need to show both line 1 and line 2.
from licensed-mental-health-counselors-browser.
👋 Made any progress on this yet?
I know hacktoberfest is over so if you're not so inclined I can take over this issue :)
from licensed-mental-health-counselors-browser.
Related Issues (14)
- Convert from table to contact-card format HOT 1
- Server should use Typescript
- Now deployment has error when starting the server HOT 1
- Consider agnostic package.json scripts implementation HOT 1
- Zip code needs to be separated from the state
- Create a roadmap. HOT 1
- Switch from now.sh to a different hosting provider HOT 1
- Implement elasticsearch HOT 2
- Styling HOT 1
- Add a README
- Process data in order to implement category based searching HOT 8
- Add a refresh button that checks if the ftp server has a file that's newer than the one in the database HOT 2
- Migrate from lowdb to dynamoDB HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from licensed-mental-health-counselors-browser.