tmilar / meli-manager Goto Github PK
View Code? Open in Web Editor NEWNode.js + MercadoLibre API + Google Spreadsheets API = 🎉
Node.js + MercadoLibre API + Google Spreadsheets API = 🎉
Some project instructions are not entirely clear yet. Items I can think of right now:
Implement a REST API for user sheets.
Stop referencing sheets in app configuration env variables.
Also, 'active' sheets should be re-assignable.
Many places will need to use MercadoLibre API (read + write), while supporting multiple accounts aggregation.
There doesn't seem to exist any good MeLi node client implementation for this task, so it might be a good idea to extract refactor all MeLi API access to a centralized MeliClient implementation.
Sometimes, when more than one notification for one (not yet stored) Order are received, both are written in spreadsheet almost simultaneously, which leads to duplicated row
Possible solution:
Serialize the spreadsheet writing requests to prevent duplicated entries. For example, by enqueing the writing requests, then writing one at a time. Or at least one at a time per resource (order) id.
Suggested: passport authentication which is easy to integrate with current express structure.
Preferred Google Authentication since we'll also need to integrate with Google Spreadsheets OAuth.
Related: vercel/micro#345
Originally posted by @fmiras in https://github.com/tmilar/meli-manager/pull/40/files
🚨 You need to enable Continuous Integration on all branches of this repository. 🚨
To enable Greenkeeper, you need to make sure that a commit status is reported on all branches. This is required by Greenkeeper because it uses your CI build statuses to figure out when to notify you about breaking changes.
Since we didn’t receive a CI status on the greenkeeper/initial
branch, it’s possible that you don’t have CI set up yet. We recommend using Travis CI, but Greenkeeper will work with every other CI service as well.
If you have already set up a CI for this repository, you might need to check how it’s configured. Make sure it is set to run on all new branches. If you don’t want it to run on absolutely every branch, you can whitelist branches starting with greenkeeper/
.
Once you have installed and configured CI on this repository correctly, you’ll need to re-trigger Greenkeeper’s initial pull request. To do this, please delete the greenkeeper/initial
branch in this repository, and then remove and re-add this repository to the Greenkeeper App’s white list on Github. You'll find this list on your repo or organization’s settings page, under Installed GitHub Apps.
Currently a test user account can be created using Mercadolibre API, but this retrieves only a {nickname, password} pair, and has some problems:
MERCADOLIBRE_CLIENT_ID
)
Provide a tool/script to manage Mercadolibre Test accounts easily.
There are a lot of invalid JSDoc comment blocks that need to be fixed, or else removed.
Running xo
will complain about this with warnings.
Expected: xo
doesn't complain about this.
Example of wrong case:
/**
* Callback after Mercadolibre authorization.
* Uses default meliAuth.onAuth() callback, but it can be overwritten for custom logic ie. CLI app.
*
* @param accessToken
* @param refreshToken
* @param profile
* @param done
* @returns {Promise<*>}
*/
const authorizedCb = async (accessToken, refreshToken, profile, done) => {
// ...
}
Example of correct case:
/**
*
* @param {Object} loggedUser - the mercadolibre logged user info
* @param {Object} loggedUser.profile - mercadolibre account profile info
* @param {Object} loggedUser.tokens.<accessToken, refreshToken>
* - mercadolibre account tokens
*
* @returns {Promise<void>} - exec promise
*/
async function registerAccount({profile, tokens}) {
// ...
}
Originally commented by @fmiras in https://github.com/tmilar/meli-manager/pull/40/files#r224301316
Right now, the entire row is being written in the spreadsheet.
If it's a Save operation, it will append the row in the end of the sheet document.
If it's an Update operation, it will overwrite the row that matches the 'id' field. But, in this case, we probably should only write the desired/updatable fields, not all of them?
For example: if a question/answer text is banned/deleted, we probably should not overwrite the info from the spreadsheet when updating the row.
This would require a refactor in the current flow.
API docs are not 100% complete, ie. response info is missing.
Some guidelines:
https://gist.github.com/iros/3426278
https://bocoup.com/blog/documenting-your-api
There are some fields that are relevant to Order entity that are being ignored such as shipping costs, order id, buyer id, and more.
Also order status and payment status is broken in some scenarios.
The current spreadsheet library doesn't handle a rare scenario when the spreadsheet given locks are lost.
To reproduce, call /order?store=true endpoint (with no dates limiter) to get a large operations writing request, then wait for this case to hit.
Also, the same library not only doesn't handle this error, but also uses some weird setTimeout callbacks in it's implementation, therefore, using this after promisifying doesn't allow to handle this exception which bubbles to the event loop itself and breaks the application.
.
I'll provide logs/screenshots/more references later.
This package name does not describe at all what it actually does, re-think it!
Originally posted by @fmiras in https://github.com/tmilar/meli-manager/pull/40/files/ded8c9013e1ce09734cd0ddac85d435d5e7060fa
The db connection, and other services such as SheetsService need to start up before the express server should be able to listen for requests.
This is a must have connection for the app, you should try this connection before setting up the express server, otherwise you're running a server and executing more code in vane since you already know that there's a critical error. Also show a more friendly error, a simple process.exit(1)
just sucks
Originally posted by @fmiras in https://github.com/tmilar/meli-manager/pull/40/files/ded8c9013e1ce09734cd0ddac85d435d5e7060fa
Until now, rows are being written in series to:
But, so far, there have been almost no errors in this process, and the sheet size re-calculation can be done in advance with some extra care (some 'lock' on the rows to be written, maybe a temporal cells paint to 'reserve' them).
It can be a good time to work on parallel writing.
When a MeLi account authorization (not to be confused with the access_token
) expires, we currently have no way of noticing it.
A solution could be:
Somewhere:
When user account logs in and authorizes again:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.