Change example to ES6 imports#400
Conversation
sadortun
left a comment
There was a problem hiding this comment.
Awesome! This will really help!
I left a few suggestions, feel free to ignore them if you want 😅
| * `/src/public` contains public assets. | ||
| * `/src/views` contains views that express can render. | ||
| * `/src/config.js` contains all Parse Server settings. | ||
| * `index.js` is the main entry point for `npm start`, and includes express routing. |
There was a problem hiding this comment.
I think it’s pretty common practise for index to be the main entry point for package.json
| if (!databaseUri) { | ||
| console.log('DATABASE_URI not specified, falling back to localhost.'); | ||
| } | ||
| export const config = { |
There was a problem hiding this comment.
We have a type defined for options I think ? ParseServerOptopns ?
You should cast it as that type so user have code completion
There was a problem hiding this comment.
That would require babel/typescript though right? I was thinking we could leave that to a TS branch
There was a problem hiding this comment.
Mmm, if you import ParseServer, you should also be able to import the Options type
| @@ -0,0 +1,14 @@ | |||
| const databaseUri = process.env.DATABASE_URI || process.env.MONGODB_URI; | |||
There was a problem hiding this comment.
To help with visual clarity, here's 2 ideas
-
Consider add a helper function that either return the ENV if defined, or default string.
-
Collect/prepare all variables before the big
configobject.
src/public/assets/js/script.js
Outdated
| updateStatus('Please correct the invalid fields.'); | ||
| return; | ||
| } | ||
| await resolve(Parse.User.logIn(username, password)); |
There was a problem hiding this comment.
Why do you await resolve() and not just await Parse.User.login() ?
Maybe consider renaming resolve to updateStatus or similar. resolve is associated to the thing you call when you completed work inside a promise
There was a problem hiding this comment.
Yeah it’s a utility function that handles UI work and resolves the promise. Maybe I should cut it out from this simple version
| async function saveObject() { | ||
| if (testObjectSaved) { | ||
| showTab(2); | ||
| findObjects(); |
There was a problem hiding this comment.
Nope! This is for moving to the next step after user has already saved an object
| </div> | ||
| <script src="/public/assets/js/script.js"></script> | ||
| <script | ||
| src="https://npmcdn.com/parse@3.3.0/dist/parse.min.js" |
There was a problem hiding this comment.
Probably for another day ;) but we really need to be able to import Parse from 'parse'
- It would allow us to auto update it with NPM
- Do tree shaking to reduce package size
- better autocompletiom
There was a problem hiding this comment.
Can browsers use node imports? Wouldn’t we need a compiler
import / exportinstead ofrequire / module.exports