adamvig / gocoapi Goto Github PK
View Code? Open in Web Editor NEWAPI Server for the GoCoStudent app.
Home Page: https://gocostudent.adamvig.com/api
License: GNU General Public License v3.0
API Server for the GoCoStudent app.
Home Page: https://gocostudent.adamvig.com/api
License: GNU General Public License v3.0
The API endpoint has changed from api.forecast.io to api.darksky.net.
Check for platform information on incoming request. If exists, save data to user's database entry.
Data is sent from app on X-Platform and X-Platform-Version headers with each request.
(Migrated from adamvig/adamvigdata/#54)
The current regression test only checks for 200 OK
responses, but does not check if the returned data is in the correct format or of the correct type.
Looks like Chai has a plugin called chai-json-schema that would integrate well with the existing tests written with Mocha.
Missing:
/setproperty username, password, propertyName, value
/createuser username, password
In the old API, every request was logged to the user's doc in the database by incrementing the number of requests the user had made to that endpoint.
This became less relevant when the app gained the autoload feature that requests data for all enabled modules every time the app is opened. It may be more relevant to keep separate global-level and user-level statistics, though the global statistics would be better generated by a logging/analytics platform such as New Relic.
User Statistics
Duplicates #3.
Instead of using POST
with authentication in the body, use GET
(endpoint method is configurable in endpointName.ENDPOINT
) and do not require authentication.
GoCoStudent/#84 must be completed before making this change.
CouchDB is currently hosted for free on CloudAnt.
Switching over to the actual server would allow for more control over the database configuration, faster data retrieval/storage, and higher security.
(Migrated from adamvig/adamvigdata/#49)
See 4TO5GUIDE for details on breaking changes.
After some research, it seems that the two best options for programmatic (not command-line) HTTP load testing are:
Artillery is good, but requires that variables for use in requests are defined in CSV files. It would be better for the test library to use exported variables from vars.js
, where test credentials are already defined.
It looks like loadtest has a better API.
The app expects an array of lines of text from /nextmeal
, but it is currently returning a string with newlines embedded.
Instead of returning zero meal points, return an informative error:
Cannot get mealpoints; transfers open Sept. 8
Instead of allowing unfettered access to the API, restrict access to users with generated API keys.
Currently, the database (the app only supports one database) is abstracted behind a simple interface supporting get
and save
operations, and nothing else. The database interaction is handled by the nano
library. An instance of nano
is instantiated in the db
module and shared by all modules that depend on it.
Possible improvements:
Info
and User
should suffice)
Model
will be a generic class for handling documentsInfo
and User
will extend Model
and add methods as well as instantiate the appropriate database for each one using the Database
classModel
for performing operations on multiple models at once.
Endpoints should expect a parameter that tells them to skip cached data if it exists.
This allows for more predictable behavior when conducting load and regression tests, which report how long the requests took.
config.ROUTES
. Instead of depending on a list of endpoint names set in config.js
, dynamically load endpoints based on their definitions in the routes
directory.Endpoint
class defined centrally that is instantiated in each endpoint's definition, and that endpoint should call the function that defines itself on the app
object. Exploring ES6's chapter on Classes is an excellent resource on the subject./helpers
.getter
and processor
functions with dummy data..jshintrc
and .eslintrc
and fix all issues that come up (copy files from GoCoStudent).function () {}
with () => {}
.var
with either let
or const
.Currently, each request is sent to /api/[app version]
, which is helpful but somewhat backwards. Instead, the app should send requests to /api/
with the Accept-Version
header, then the API version can be changed and the app will never know the difference.
Restify supports versioned routes out of the box.
API versioning on the request-level should go hand-in-hand with API versioning on the release level, meaning that this project should get on a release schedule using semantic versioning.
Use the default ESLint configuration to enforce a huge number of stylistic rules.
Instead of returning only a friendly error message as text/plain
, return a JSON object containing the following fields:
{
description: "Actual description of error message for debugging purposes"
message: "User-facing message, ex: Something went wrong! ๐ "
}
This change should also come with more descriptive use of error codes.
Should return contents of the database document message
in the Info database.
InternalServerError: Error: getaddrinfo ENOTFOUND my.gordon.eduundefined my.gordon.eduundefined:443
at Object.utils.handleError (/var/www/gocoapi/helpers/utils.js:30:17)
at getData.then.then.catch (/var/www/gocoapi/routes/endpoint.js:91:27)
Currently, the cacheGlobal()
method in cache.js
is unused, and global caching seems to be entirely disabled. The whole file could be refactored to be clearer, as well.
This depends on #4 "Run CouchDB on server instead of externally", because testing the global cache would require modifying documents in the actual database (issue is now closed).
CouchDB leaves a lot to be desired. Its basic functionality is good, but it fails in two major areas:
The advantage of CouchDB is quick and dirty data modelling. For example, it will be a challenge to convert the Highland Express data to a relational schema.
CouchDB is also a practical, if improper, solution for caching data. MySQL makes that much more difficult, so Etags and the Expires
header should be used in place of a homegrown caching solution.
Using MySQL will make it easier to reduce data duplication. Instead of storing a number of requests for each endpoint and a total number of requests, the new schema can store just the number of requests per endpoint. A view can be created to sum the total number of requests for each user and the total number of requests for each endpoint.
A view can also be created to calculate the date and time of each user's last request based on a timestamp in the endpoint usage table.
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.