postlight / lux Goto Github PK
View Code? Open in Web Editor NEWBuild scalable, Node.js-powered REST JSON APIs with almost no code.
Home Page: https://lux.postlight.com
License: MIT License
Build scalable, Node.js-powered REST JSON APIs with almost no code.
Home Page: https://lux.postlight.com
License: MIT License
Hi,
I like framework and looks awesome. I don't want to use MySQL as I am writing service which calls another XML service via HTTP so don't need MySQL. How can I skip mySQL?
Parameters passed to controllers for filtering, creating and updating records must be sanitized by whitelisting an array of attribute keys to prevent security risks.
class PostsController extends Controller {
params = [
'title',
'body'
];
}
The best part of a framework arguably is the cli taking care of boilerplate and common tasks for you.
We actually want this behavior for GET
requests and do this parsing on purpose.
Conditionally parse strings with commas as arrays based on the request method.
Currently {model}/:id
is the only supported dynamic segment when defining routes and resources. We should be able to do something like posts/:id/comments/:commentId
.
[7/14/16 12:6:08 PM] Adding worker process: 18653
[7/14/16 12:6:08 PM] Lux Server listening on port: 4000
SQLite:
date: 1463699426284
bool: '1'
MySQL:
date: "2016-05-19T23:10:26.284Z"
bool: true
The CLI should check for existing files when generating the file with the same name and ask for user input before replacing any, with the option to skip if they deny the permission.
We should return Promises when a relationship is accessed on an instance of Model
in case the related records were not eager loaded.
const user = await User.find(1);
const posts = await user.posts;
Passing invalid JSON to a POST/PATCH requests crashes lux, and generates no response.
/Users/kevin/Documents/lux-todo/node_modules/lux-framework/src/packages/server/utils/body-parser.js:13
JSON.parse(body) : parseQueryString(body);
^
SyntaxError: Unexpected token ; in JSON at position 96
at Object.parse (native)
at IncomingMessage.onEnd (/Users/kevin/Documents/lux-todo/node_modules/lux-framework/src/packages/server/utils/body-parser.js:13:12)
at IncomingMessage.g (events.js:286:16)
at emitNone (events.js:86:13)
at IncomingMessage.emit (events.js:185:7)
at endReadableNT (_stream_readable.js:934:12)
at _combinedTickCallback (internal/process/next_tick.js:74:11)
at process._tickCallback (internal/process/next_tick.js:98:9)
Creating this issue just to document it.
Pagination links served in Lux:
"links": {
"self": "http://example.com/articles?page=3",
"first": "http://example.com/articles?page=1",
"prev": "http://example.com/articles?page=2",
"next": "http://example.com/articles?page=4",
"last": "http://example.com/articles?page=13"
}
Pagination links according to JSON API spec:
"links": {
"self": "http://example.com/articles?page[number]=3&page[size]=1",
"first": "http://example.com/articles?page[number]=1&page[size]=1",
"prev": "http://example.com/articles?page[number]=2&page[size]=1",
"next": "http://example.com/articles?page[number]=4&page[size]=1",
"last": "http://example.com/articles?page[number]=13&page[size]=1"
}
Currently SQL logging is disabled due to errors in strict mode caused by node-orm2's connection.debug
setting.
This was introduced in 0.0.1-beta.8
. The issue comes from an attempt to read beforeAction
and set the private middleware
property on the Controller
class within it's constructor
.
Lux beta7 | Node v4.2.1 | MariaDB v10.1.11
I'm new to this. I'm also interested in contributing when I get my bearings.
I noticed this:
on default npm install and after generating user
, post
and account
models with CLI resource
I took the user
model from the guides:
class User extends Model {
static hasOne = {
account: {
model: 'account',
reverse: 'user'
}
};
static hasMany = {
posts: {
model: 'post',
reverse: 'author'
}
};
}
I get this lovely error when starting the server, and I'm not sure where I should look to debug it:
[5/12/16 7:48:48 PM] Starting Lux Server with 4 worker processes
{ [ORMError: Unknown property type: undefined]
message: 'Unknown property type: undefined',
code: 4,
literalCode: 'NO_SUPPORT' }
However, when I remove the hasMany
from the user model, everything seems to work as expected.
I've attempted this on 2 machines. Any initial ideas on the reason for the error?
An uncaught error in serializing a hasMany
many relationship prevents requests from completing.
The following request body should update Post
with the id: 1
based on the attributes in the resource object.
// PATCH => '/posts/1'
{
"id": 1,
"type":"posts",
"attributes": {
"title": "My First Post",
"body": "lorem ipsum..."
}
}
Fill out README with:
When switching between two different Lux projects with the same sessionKey
without a clean session or domain you get 500 error because of the key/secret miss-match.
We should catch the miss-match error here and ignore the offending cookie allowing the request to pass through as if no session previously existed (in turn writing a new Set-Cookie
header).
See #72
Tables are named with the following convention Posts
. Should be posts
.
Columns are named with the following convention createdAt
. Should be created_at
.
Lux looks to be a very cool project, and I'm currently evaluating whether I can use it to build the core data APIs for my project. Kudos to a great effort thus far!
That said, I've gotten bitten following some outdated information in the wiki, most notably the first statement on the Models page:
Models wrap a typical node-orm2 model in a ES2015 class to provide a more modern syntax.
It was only after a couple of days of R&D into node-orm2
& things not working as I'd expect that I noticed in the commit log that node-orm2 had been replaced by an custom ORM wrapping knex
.
I'm also finding myself reading through Lux's source code to determine whether some features I'll need are A) not (yet) implemented, or B) not documented well enough for me to figure out how to use them. It'd be really great to see JSDoc (or similar) incorporated into the source code and generated API docs.
If I decide I'm able to use Lux for my project, I'll be happy to contribute to that effort.
Generating a new Lux App with the following name
lux new lux-test-app
Then calling lux s
produces the following error.
{ SyntaxError: /Users/kevin/Documents/lux-test-app/app/index.js: Unexpected token (3:13)
1 | import { Application } from 'lux-framework';
2 |
> 3 | class LuxTest-app extends Application {
| ^
4 |
5 | }
6 |
I've been banging my head against a wall trying to run lux in docker. Do you happen to have a docker/docker-compose setup that you use? If not, I can keep trying to "dockerize" this.
Ignore all files that have a . in front of the file name regardless of extension. And also ignore any other file that doesn't have a .js extension.
Related: #103
There currently is no request and exception logging
Did 'npm install -g' but 'lux new' fails with the following error:
~/projects/ember $ lux new lux-test
c:\Users\xxxx\AppData\Roaming\npm\node_modules\lux-framework\dist\cli.js:198
let rescue = arguments.length <= 1 || arguments[1] === undefined ? K : arguments[1];
^^^
SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:387:25)
at Object.Module._extensions..js (module.js:422:10)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Module.require (module.js:367:17)
at require (internal/module.js:16:19)
at Object.<anonymous> (c:\Users\bwyse\AppData\Roaming\npm\node_modules\lux-framework\bin\lux:9:3)
at Module._compile (module.js:413:34)
at Object.Module._extensions..js (module.js:422:10)
~/projects/ember $ npm -v
3.6.0
~/projects/ember $ node -v
v5.6.0
~/projects/ember $
This is extremely useful when troubleshooting bugs between versions or for people considering upgrading to a newer version.
This could probably wait until lux
is out of beta, but I think it is important to include eventually.
PATCH '/tasks/1'
does not invalidate other forked processes instance cache resulting in stale payloads. It's best we disable the cache on ORM2 (perf hit isn't bad enough to matter).
So creating multiple objects with same unique field would not get caught.
Currently we do not support Windows.
Most reasons why Windows does not currently work is related to path differences between UNIX and Windows (/
vs \
).
All quotes should be single or backticks if it's a template string.
Examples need updated to reflect the API changes brought on by #65.
I can't figure out how to access the payload of the request.
I can see the following attributes of the request object
"readable",
"domain",
"socket",
"connection",
"httpVersionMajor",
"httpVersionMinor",
"httpVersion",
"complete",
"headers",
"rawHeaders",
"trailers",
"rawTrailers",
"upgrade",
"url",
"method",
"statusCode",
"statusMessage",
"client",
"read",
"route",
"params"
It would be nice if there was a task that batches editing the routes.js, creates the controller, model and serializer.
lux generate resource user
Followed instructions from: https://github.com/postlight/lux/wiki/Getting-Started
After creating a new app, 'lux serve' fails:
~/projects/ember/lux-test-2 (master) $ lux serve
Error: Cannot find module '../appindex.js' from 'c:/Users/xxxxx/projects/ember/lux-test-2/dist'
at C:\Users\xxxx\projects\ember\lux-test-2\node_modules\resolve\lib\async.js:55:21
at load (C:\Users\xxxx\projects\ember\lux-test-2\node_modules\resolve\lib\async.js:69:43)
at onex (C:\Users\xxxx\projects\ember\lux-test-2\node_modules\resolve\lib\async.js:92:31)
at C:\Users\xxxx\projects\ember\lux-test-2\node_modules\resolve\lib\async.js:22:47
at FSReqWrap.oncomplete (fs.js:117:15)
~/projects/ember/lux-test-2 (master) $
Since we no longer are using node-orm2 we need to include unit test for model hooks, validations, querying, etc.
At the moment you require a route, controller, model and a serializer to exist to be able to return some sort of content.
From the README.md
Automatic CRUD actions in controllers
Automatic pagination, sorting, filtering via query params in controllers
I misunderstood this by thinking controllers and serializers where autogenerated on the fly the way it works on Ember (Ember spoils you). And there weren't any good error messages when they didn't exist.
Would definitely consider these files optional since they work by being empty. Eg.
import { Controller } from 'lux-framework';
class UsersController extends Controller {
}
export default UsersController;
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.