u-wave / http-api Goto Github PK
View Code? Open in Web Editor NEWNow part of u-wave/core.
Home Page: https://github.com/u-wave/core
License: MIT License
Now part of u-wave/core.
Home Page: https://github.com/u-wave/core
License: MIT License
Not sure why this is happening suddenly, but the YT duration parser is throwing on valid durations. Probably should look into YT duration parsers on npm.
Currently using pbkdf2 with only 2048 iterations (recommended >100k). that's not very good. Switch to scrypt or bcrypt instead. Will break existing logins on the test server.
We called this thing api-v1, but I expect when this is stable enough for an actual v1.x release we won't be finished. We really can't do major bumps in the Web api bc all clients would have to update. We also can't really create a new repository for every api major version, since most likely the breaking changes will not be that big, or will only be in one part (eg only in the websocket server).
Instead, I think we should rename this to u-wave-http-api or something similar. All major versions will live in this repository side by side, and they'll all remain available on side by side routes. I have to look more into how other people do it, but right now I'm thinking that different Web api versions can call into the same controller files and use different controller methods only where the versions differ.
(brief bc on mobile)
churny as all heck, but:
https://nodejs.org/api/esm.html
Need to figure out a good time to do this, probably going to finish up the existing PRs and try not to make new ones in the mean time
Branch | Build failing 🚨 |
---|---|
Dependency | babel-eslint |
Current Version | 8.2.5 |
Type | devDependency |
This version is covered by your current version range and after updating it in your project the build failed.
babel-eslint is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.
The new version differs by 2 commits.
b9067fa
8.2.6
c797a36
pin to [email protected]
See the full diff
There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.
Your Greenkeeper Bot 🌴
rate limiting errors totally clog up our free bugsnag account, they aren't bugs so they really shouldn't be logged at all.
This version is covered by your current version range and after updating it in your project the build failed.
This monorepo update includes releases of one or more dependencies which all belong to the babel7 group definition.
babel7 is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.
There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.
Your Greenkeeper Bot 🌴
(e; Maybe not to the wrong item, I'm not entirely sure. they don't apply to the correct item at least 😄 )
Example:
Request URL:http://u-wave.dev:8080/v1/playlists/563f390cf059363574f4d4dd/media/5663878c55c1ad895690fd5c?token=…
PUT data:
{"artist":"Marnie Stern ","title":"Ruler","start":0,"end":220}
Note the item id: 5663878c55c1ad895690fd5c
Response:
{"_id":"562babb5e5e6a8b72991703e","media":"562babb5e5e6a8b72991703d","artist":"Marnie Stern ","title":" Ruler ","__v":0,"end":220,"start":0}
Note the different item _id
.
The original item remains unchanged.
Currently all known state is always returned from /now. Ideally however it would only return the bits that clients need.
It should accept a comma-separated string:
fields=user,playlists
fields=booth,users,waitlist
When someone starts DJing, their playlist "cycles", i.e. the first item is moved to the very end. A socket event (playlistCycle
, perhaps) should be dispatched for this too, so clients also know to cycle their playlist.
Advance stuff happens here, for now:
https://github.com/goto-bus-stop/u-wave-api-v1/blob/8ad01591dfe77948312bbdbad3a72ba3066667d7/src/sockets.js#L222-L244
This error message is bizarrely unhelpful.
Unfortunately, MongoDB's error message is also bizarrely unhelpful:
MongoError: E11000 duplicate key error index: wlk_uwave.users.$slug_1 dup key: { : "reanna" }
So we should probably catch "user create" errors and check for:
.code
11000 or 11001…and make sure those duplicate errors aren't hidden.
Currently api-v1 contains all of the things, and it's very tightly coupled with core. There should be a meaningful separation between the two so other plugins/interfaces/ can be added by server hosts easily, while keeping everything in sync.
Ideally we'd want some multiprocess support so we can have like millions of people online and do 0-downtime server upgrades (I mean, I assume that's how it works! not an expert. But we need to be able to do that, anyway.) in the long term.
Idea:
https://docs.google.com/drawings/d/1xq_F4mUoF0gsE_q5LW26fA2pElgTBf2zOKKkQaKq6AU/view
To prevent joining the waitlist without a song to play
Branch | Build failing 🚨 |
---|---|
Dependency | rollup |
Current Version | 0.63.2 |
Type | devDependency |
This version is covered by your current version range and after updating it in your project the build failed.
rollup is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.
The new version differs by 3 commits.
d6c3ea8
0.63.3
68fdddf
Update changelog
4465018
Do not fail for binary expressions involving "in" and "instanceof" (#2344)
See the full diff
There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.
Your Greenkeeper Bot 🌴
Currently you can still send messages to the socket when you're logged out, if you connected with a valid session. That shouldn't be possible.
A simple-ish way to fix that would be to force-disconnect a logged-out user.
Another simple-ish way would be to replace the AuthedConnection with a GuestConnection in src/sockets.js
.
Maybe on /playlists/search?query=$QUERY
initially.
(So yeah, if #14 turns out good, it'd be AMAZING to have playlists, and the room history as search sources (like woa, abstractions).)
Currently API requests by users who aren't in the "online users" list, but do have a valid auth token, just go through. This can be a problem when a user does not connect to the socket, but does eg. join the waitlist, because now everybody else gets a "waitlist join" notification for a user who doesn't even appear to be online.
One way to fix this is to just block HTTP API requests when a connection is not alive. One better way would be to only block API requests that mutate state, so you can still view most things. Perhaps return something like, "You have to be online to do X"
Currently when you favourite a song, the existing playlist item is added to your own playlist:
That sort of works, but it means that the playlist item is shared. There are a few problems with this:
Solution: create a clone of the playlist item when favouriting a song, and add the clone to the relevant playlist.
…with things that need to be done on the web API end of things before it can be considered "publically usable". (i.e., by people who are not We ♥ Kpop)
Also, tradeoffs that were made for the sake of Getting It Working (Mostly)™, and what is useful to refactor.
Currently YouTube and SoundCloud queries are hardcoded into the search controller. Both should be abstracted into their own Source objects, with a common API, so we can much more easily add more source types later.
Initially they'll only need a search(query)
method to get ~25 search results and return them as üWave-style objects ({ sourceType, sourceID, artist, title, duration }
). That can then be used by the search controller, matched up with the media items that are already known, etc. (much like how it's done already)
They're a bit unusual on the user endpoints, needing POST requests to mute someone, DELETE requests to unmute, and with no way to list current mutes.
Instead we should have /mutes endpoints that you can PUT to to mute someone, DELETE to unmute, and GET to list.
Voting happens here:
https://github.com/goto-bus-stop/u-wave-api-v1/blob/master/src/sockets.js#L199
Needs to check that the booth is actually occupied.
To prevent servers from dying.
A good library could be https://github.com/tj/node-ratelimiter, which would work for both socket and HTTP request limiting. It can use our existing Redis connection from u-wave-core.
Tangential: Could also be used for limiting new socket connections, instead of just socket messages, to deal with massive user spam like Musiqpad saw on its first days.
Currently artist names and titles are handled pretty poorly. We should probably steal something like web-scrobbler's YouTube artist/title extraction:
https://github.com/david-sabata/web-scrobbler/blob/master/connectors/v2/youtube.js#L64-L109
https://github.com/david-sabata/web-scrobbler/blob/master/core/content/connector.js#L407-L422
That deals with all kinds of weird separators, and all the OFFICIAL VIDEO fluff as well, so we should have pretty good results without manual intervention 💪
Unhandled rejection:
/var/www/goz3rr/kuubstudios.com/public_html/uwave/u-wave-core/node_modules/bluebird/js/main/async.js:43
fn = function () { throw arg; };
^
MongoError: E11000 duplicate key error index: uwave.users.$username_1 dup key: { : "Goz3rr" }
at Function.MongoError.create (/var/www/goz3rr/kuubstudios.com/public_html/uwave/u-wave-core/node_modules/mongodb-core/lib/error.js:31:11)
at toError (/var/www/goz3rr/kuubstudios.com/public_html/uwave/u-wave-core/node_modules/mongodb/lib/utils.js:114:22)
at /var/www/goz3rr/kuubstudios.com/public_html/uwave/u-wave-core/node_modules/mongodb/lib/collection.js:1008:67
at commandCallback (/var/www/goz3rr/kuubstudios.com/public_html/uwave/u-wave-core/node_modules/mongodb-core/lib/topologies/server.js:1161:9)
at [object Object].Callbacks.emit (/var/www/goz3rr/kuubstudios.com/public_html/uwave/u-wave-core/node_modules/mongodb-core/lib/topologies/server.js:119:3)
at [object Object].messageHandler (/var/www/goz3rr/kuubstudios.com/public_html/uwave/u-wave-core/node_modules/mongodb-core/lib/topologies/server.js:295:23)
at Socket.<anonymous> (/var/www/goz3rr/kuubstudios.com/public_html/uwave/u-wave-core/node_modules/mongodb-core/lib/connection/connection.js:285:22)
at emitOne (events.js:90:13)
at Socket.emit (events.js:182:7)
at readableAddChunk (_stream_readable.js:153:18)
at Socket.Readable.push (_stream_readable.js:111:10)
at TCP.onread (net.js:529:20)
Branch | Build failing 🚨 |
---|---|
Dependency | eslint-plugin-import |
Current Version | 2.3.0 |
Type | devDependency |
This version is covered by your current version range and after updating it in your project the build failed.
As eslint-plugin-import is “only” a devDependency of this project it might not break production or downstream projects, but “only” your build or test tools – preventing new deploys or publishes.
I recommend you give this issue a high priority. I’m sure you can resolve this 💪
The new version differs by 10 commits.
44ca158
update utils changelog
a3728d7
bump eslint-module-utils to v2.1.0
3e29169
bump v2.4.0
ea9c92c
Merge pull request #737 from kevin940726/master
8f9b403
fix typos, enforce type of array of strings in allow option
95315e0
update CHANGELOG.md
28e1623
eslint-module-utils: filePath in parserOptions (#840)
2f690b4
update CI to build on Node 6+7 (#846)
7d41745
write doc, add two more tests
dedfb11
add allow glob for rule no-unassigned-import, fix #671
See the full diff
There is a collection of frequently asked questions and of course you may always ask my humans.
Your Greenkeeper Bot 🌴
There doesn't seem to be an easy way to move playlist items to the very end currently.
Would be useful to look into what other APIs that deal with lazy-loaded ordered lists do.
And once their turn ends, they're added back to the waitlist even if they're not online.
The simpler solution would be to remove the DJ from the booth when they leave.
ATM errors are handled entirely inside api-v1. It would be neat to have a hook when an error occurs so we can intercept it and in case of welovekpop.club report it via bugsnag.
I'm thinking of having an option for custom error handler middleware, since error reporting libraries usually know how to make nice stack traces from express middleware and maybe not from an 'error' event (not sure). for bugsnag that would be something like:
app.use(Bugsnag.requestHandler)
createWebApi(uw, {
// options
errorHandler: Bugsnag.errorHandler
})
Eg. for joining. If the joining user is the current DJ, the waitlist will happily accept them in.
Most playlist endpoints call toPlaylistResponse
before returning a playlist to the client, but the createPlaylist controller does not. This is an issue because now the returned size of a newly created playlist is undefined
instead of 0.
Solution: call toPlaylistResponse
on the created playlist.
When an error occurs, currently the api replies with a single English string. That's not particularly helpful for clients: some errors might be recoverable, and some might be because of an internal error whereas others are because of incorrect user input. Sometimes multiple errors occur, and they are currently either concatenated or ignored.
Ideally we'd return an object with an errors
property if errors occur, and list error objects there with useful metadata.
http://jsonapi.org/format/#errors would be a good format 😉
These votes should be ignored.
Something for @xBytez maybe? :)
Moving users to the end of the waitlist appears to move them to the start instead.
Any position that's at the end, or after the end of the waitlist should move the user to the end.
We probably want to add tests during #3—probably will be some refactoring going on, and that's a great opportunity to break things up into easily testable chunks.
Should do something like this:
https://en.wikipedia.org/wiki/Network_Time_Protocol
but like…over HTTP.
(This should also be included in the /now endpoint.)
Branch | Build failing 🚨 |
---|---|
Dependency | joi |
Current Version | 13.4.0 |
Type | dependency |
This version is covered by your current version range and after updating it in your project the build failed.
joi is a direct dependency of this project, and it is very likely causing it to break. If other packages depend on yours, this update is probably also breaking those in turn.
The new version differs by 21 commits.
63492d4
13.5.0
334c1e3
Cleanup for #1532.
3372df0
Merge pull request #1532 from rokoroku/patch-1
3414eb7
Update documentation for string.trim([enabled])
0a82b61
Add assertion for string.trim()
bcc5f12
Cleanup for #1510.
8b39221
Merge pull request #1510 from Shudrum/dataUri
2391f72
Cleanup for #1487.
7aa0df0
Merge pull request #1487 from BolajiOlajide/ft-allow-square-brackets-param-url-validator
37d3588
Add createError
documentation. Fixes #999.
77012b2
Add enabled flag to string.trim()
8eefd0d
Don't initialize options uselessly
52fd99b
Padding option added to dataUri like base64
840eaad
Move the dataUri tests after the base64 one
83eb8eb
Merge pull request #1511 from WesTyler/unique_ignoreUndefined_#1498
There are 21 commits in total.
See the full diff
There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.
Your Greenkeeper Bot 🌴
The createPlaylistItem controller currently always uses the artist, title and start/end times from the global media object (the one derived from the source media). This overrides any custom tags that users may have entered. For example, when your playlist contains a video of a full album, and you've set it to only play 3 minutes of a song halfway, it'll revert back to playing the full album when you drag it to another playlist.
Instead, it should copy the custom artist, title, and start/end times, and only fall back to the global defaults if no custom properties are available.
There's a booth/skip
endpoint but it only supports skips by moderators. However sometimes a user may want to skip their own turn as well.
Proposal: A POST
request to /booth/skip
without a body should skip the current user (if they're DJing.)
This would broadcast a
{
"command": "guests",
"data": 7
}
message whenever the amount of connected guests changes.
To prevent timeouts.
We need to standardise on a generic API response format, and also on the shape of the different types of objects that are in play.
I've looked into JSON-API a bit, which is really nice because it's standardised--but I'm not sure that it's exactly fit to our use case. Of course, it doesn't have to be for us to use it :)
Some important things to consider:
JSON-API:
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.