
Research
Security News
Malicious PyPI Package Exploits Deezer API for Coordinated Music Piracy
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
lux-framework
Advanced tools
A MVC style framework for building highly performant, large scale JSON APIs that anybody who knows the JavaScript language and its modern features will understand.
* Inspired by Rails, Ember, and React.
Disclaimer:
This isn't another wrapper around Express or a framework for building frameworks. This also isn't a replacement for server-side frameworks that render DHTML.
Map
not an Array
Lux uses JavaScript's standard library rather than creating a ton of functions you'll have to learn and remember.
After your learn how to use it, you'll rarely need to look at the docs.
Or more appropriately somewhat pure functions are awesome.
Serving content is done by returning objects, arrays, or other primitives rather than calling res.end(/* content */);
and returning nothing.
Rails and Ember are great because they make hard decisions for you and make it possible to submit a PR on your first day at a new company. This is rare with Node server frameworks.
Frameworks like Rails are pretty great. You can build amazing applications in a reasonable amount of time without a ton of developers working on a project. They have their limitations though. They can be slow and sometimes hard to scale. Not to mention WebSocket support being so-so.
It's fast, it allows the developer to get low level with a relatively simple API, WebSockets are stable and supported out of the box, and last but not least it's just JavaScript.
The last bit there "It's just JavaScript" has actually been somewhat of a double-edged sword. This has positioned Node as a "great prototyping tool" or "only used for micro services."
I can somewhat see why people would think that when returning a list of the first 10 records from a SQL database table looks like this:
app.get('/posts', (req, res) => {
Post.findAll()
.then(posts => {
res.status(200).json(posts);
}, err => {
console.error(err);
res.status(500).send(err.message);
});
});
Could you imagine how ugly that gets when you have to implement pagination, filtering, sorting, or—better yet—formatting the response for JSON API?
Also, where does that code live? In what file and folder would I find it? What pattern do you use for organizing this code?
😲Ok ok give me back Rails I'll worry about performance and scaling later. After all, premature optimization is the root of all evil.
Shouldn't there be a better way to do this? Can't I just return a promise or a JavaScript primitive instead of basically using the native Node http server API?
Fortunately ES2015+ has introduced great new features to the JavaScript language, especially when it comes to meta programming.
With Lux your code from before can now look like this:
class PostsController extends Controller {
index(req, res) {
return Post.all();
}
}
Except CRUD actions are taken care of automatically so it would actually look like this:
class PostsController extends Controller {
}
It's about time a Node server framework learned something from client-side JS frameworks.
npm install -g lux-framework
Use the new
command to create your first project.
lux new <app-name>
To run your application use the serve
command.
cd <app-name>
lux serve
For more information checkout out the Guides.
git clone https://github.com/postlight/lux
cd lux
npm install
git clone https://github.com/postlight/lux
# Install Lux dependencies
cd lux
npm install
# Install test app dependencies
cd test/test-app
npm install
# Run the test suite
cd ../../
npm test
1.1.0 (Dec 10, 2016)
This release introduces a public transaction api to the model class. Changes are backwards compatible with the previous model api.
Internally, all methods that modify the state of the database are wrapped in
transactions. If the transaction fails, all calls to create
, save
, or
update
will be rolled back to the state before the transaction began.
Example:
import User from 'app/models/user';
// This internally uses a transaction.
await User.create({
firstName: 'New',
lastName: 'User'
});
You have the ability to manually specify the transaction that will be used for a
create
, update
, or save
call with the static and instance method, transacting
.
Example:
import { Model } from 'lux-framework';
import Profile from 'app/models/profile';
class User extends Model {
static hasOne = {
profile: {
inverse: 'user'
}
};
static hooks = {
async beforeCreate(user, trx) {
// If the transaction fails the profile instance will not be persisted.
user.profile = await Profile
.transacting(trx)
.create();
}
};
}
You can also manually trigger create a transaction if you plan on creating many model instances as once.
Example:
import User from 'app/models/user';
User.transaction(trx => (
Promise.all([
User
.transacting(trx)
.create({
firstName: 'New',
lastName: 'User'
}),
User
.transacting(trx)
.create({
firstName: 'New',
lastName: 'User'
}),
User
.transacting(trx)
.create({
firstName: 'New',
lastName: 'User'
})
])
));
3f15362600
] - deps: update babel-core to version 6.20.0 (#556) (Greenkeeper)9a20c5ce11
] - deps: update eslint to version 3.12.0 (#557) (Greenkeeper)7f53cd230c
] - docs: fix broken logo in readme (#555) (Zachary Golba)590956ed52
] - docs: add preliminary guide files (#554) (Zachary Golba)16d224b4e7
] - feat: use transactions when writing to the database (#527) (Zachary Golba)9e89b042cd
] - deps: update eslint-plugin-flowtype to version 2.29.1 (#549) (Greenkeeper)5b3e91e5f9
] - deps: update eslint to version 3.11.1 (#547) (Greenkeeper)4eb0c9b926
] - deps: update eslint-plugin-flowtype to version 2.28.2 (#546) (Greenkeeper)42f1707ac8
] - deps: update eslint to version 3.11.0 🚀 (#539) (Greenkeeper)39adf76c3a
] - deps: update rollup to version 0.36.4 (#536) (Greenkeeper)23189f535b
] - deps: update flow-bin to version 0.36.0 🚀 (#537) (Greenkeeper)394d3132e7
] - deps: update nyc to version 10.0.0 (#535) (Greenkeeper)ef33526860
] - deps: update mocha to version 3.2.0 (#538) (Greenkeeper)760ae5f68c
] - release: 1.0.5 🔧 (#534) (Zachary Golba)FAQs
Build scalable, Node.js-powered REST APIs with almost no code.
The npm package lux-framework receives a total of 18 weekly downloads. As such, lux-framework popularity was classified as not popular.
We found that lux-framework demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.
Security News
Newly introduced telemetry in devenv 1.4 sparked a backlash over privacy concerns, leading to the removal of its AI-powered feature after strong community pushback.