nitrotasks / nitro-server Goto Github PK
View Code? Open in Web Editor NEWThe Nitro syncing server
License: GNU Affero General Public License v3.0
The Nitro syncing server
License: GNU Affero General Public License v3.0
It would make the sign up procedure instant.
Create a list, sync.
Delete the list & sync again.
It comes back from the dead.
- init.coffee
- controllers/
- router.coffee
- socket.coffee
- validation.coffee
- routes/*.coffee
- controllers/
- auth.coffee
- connect.coffee
- query.coffee
- sync.coffee
- table.coffee
- users.coffee
- database/*.coffee
- models/*.coffee
Sync
Create a custom list.
Create a new task.
Move the task to Next
Sync
It breaks. No idea why.
It's currently very repetitive, but can be cut down by replacing duplicate code with functions.
Instead of compressing tasks into a single blob, we should store them in a table called 'tasks'.
e.g When there is no internet
Not sync, just the login.
These are the bugs found using test/fuzz.coffee
.
id
a required property using xType.tasks
array set causes the server to crash.tasks
a required property.changes.id
in sync.update.tasks
property that contains task IDs that don't exist.tasks
property that contains different contents.listID
set to a list ID that doesn't exist.tasks
array.task.listId
creates a new list with that id (if one doesn't already exist).When a task is created on the client, two messages are sent to the server: list.update
and task.create
.
list.update({
"id": "inbox",
"tasks": [
"c0"
]
},{
"tasks": 1390074290378
})
task.create({
"id": "c0",
"listId": "inbox",
"date": 0,
"name": "This is a new task",
"notes": "",
"priority": 1,
"completed": 0
}, 1390074290379).fn(2)
The server then stores the following.
{
"data_task": {
"s1": {
"id": "s1",
"listId": "inbox",
"date": 0,
"name": "This is a new task",
"notes": "",
"priority": 1,
"completed": 0
}
},
"data_list": {
"inbox": {
"name": "Inbox",
"tasks": [
"c0",
"s1"
],
"id": "inbox"
}
}
}
See the problem? The inbox list has two tasks assigned to it: "c0"
and "s1"
. But "c0"
doesn't even exist!
Whenever a list is created or updated, we loop through the tasks array and throw array any IDs that don't exist on the server.
list.update
message.tasks
property and deletes "c0"
property.task.create
message.tasks
array.task.create
message first, and then waits for the server to return the server ID.list.update
event.tasks
property.One of the features on the client is that you can sort tasks in order you want. We need to be able to keep this order on the server.
So I think the best thing to do is just let the server manage the tasks
array for each list.
The task.create
event requires you send id
and listId
. The server can then check that listId
exists, and will add the task id to it.
Use task.update
and set the listId
to the new list id. The server can remove the task id from the old list and add it to the new one.
Use task.destroy
. The server can remove the task id from the list it was in.
Send list.update
with the tasks array.
The server willl throw array any tasks that don't exist on the server and add the tasks that aren't included. Then it will merge the order with the existing tasks array.
Should be fixed tomorrow.
Error: ER_ROW_IS_REFERENCED_.
Cannot delete or update a parent row: a foreign key constraint fails .
SQL used to delete a list:
delete from `list` where `id` = 1
Constraint that causes the error:
Nitro.list_tasks,
CONSTRAINT `list_tasks_listid_foreign`
FOREIGN KEY (`listId`) REFERENCES `list` (`id`)
At the moment whenever anything on a user is changed, the entire user is written to the database. This can be greatly improved.
However we currently use lodash.throttle to limit writes to once per 5 seconds, so the database doesn't get thrashed during syncing. During this we lose the ability to pass arguments to the write method.
Somehow we need to keep a track of the attributes that changed between writes. So my plan is to modify lodash.throttle and keep a list of arguments that are passed to it, and then pass them all as an array to the actual write method.
This is probably really important when dealing with realtime sync.
No idea how to implement it though.
Maybe ask the client to set their location, or somehow automatically detect which timezone they are in?
Also need to pick a timezone for the server, so we can convert it all that to do checking.
No idea why, will have a look at the logs.
Causes glitches etc when logging back in on the same account.
Not only is auto refresh broken, the soft reload (ui.reload is broken).
This is really important.
Also update npm test
so it runs all tests in the test
folder.
https://github.com/sockjs/sockjs-node
Should make everything faster and more secure.
Also have a new plan on how to do authentication:
https://github.com/petkaantonov/bluebird
It's probably faster than kew and has lots of docs.
Also it's used by knex so we don't have to wrap the promises.
The only thing that should need to be changed is switching from .fail
to .catch
.
HttpOnly
and secure
flags. 1 failed attempt = 5 sec delay
2 failed attempts = 15 sec delay
3+ failed attempts = 45 sec delay
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.