
Research
/Security News
npm Author Qix Compromised via Phishing Email in Major Supply Chain Attack
npm author Qix’s account was compromised, with malicious versions of popular packages like chalk-template, color-convert, and strip-ansi published.
final-server
Advanced tools
A component-based server framework for ES6+, with a React-like lifecycle. Experimental.
This is a very experimental proof of concept for a server framework. It takes ideas from ES6+ and React to see if there's a more enjoyable, versatile way to create APIs.
Key concepts are:
Each endpoint has a class, which extends the component class. The main method of the class is respond
which decides what is returned upon each request.
Each component has a lifecycle, with names similar to the lifecycle components of React components.
Decorators are used to add actions and in-memory state to components. The example decorator that's included is for ArangoDB. A reduxConnect
decorator is also currently part of the library.
WebSocket-functionality is built-in (at present). Depending on how you wish to use the library, you can have components that repeat their lifecycle whenever state is changed. This is most useful for WebSocket servers becuase there may be multiple responses per connection. An http
request will fire response
onece, but a WebSocket connection might do it many times.
Use yarn
or npm
to install like so. Arango is optional, and it may also be possible to use without Babel, but documentation assumes you can use decorators and class properties.
yarn add final-server final-arango
yarn add --dev @babel/core @babel/preset-env @babel/plugin-proposal-class-properties @babel/preset-stage-0
See the /examples
and files matching the patter **/*.test.js
for more usage and explanation. Be warned the API will change a lot.
import Final, { reduxConnect, database } from './src/index'
import { bindActionCreators } from 'redux'
import { middleware, store } from './example/middleware'
import { moveUp } from './redux/modules/player'
import { UserSchema } from './schemas' // not an actual thing that's included
/*
The `findDecorator` adds a few funtions to the class, like `this.findOne`.
*/
@database({
// this decorator will verify collection or create new one
collection: 'Post',
url: 'http://root:@127.0.0.1:8529', // this value is the default
arangoVersion: 30300 // this is also the default
})
@reduxConnect(
(state) => ({
players: state
}),
(dispatch) => ({
moveUp
})
)
class Post extends Final.Component {
/*
The path decides what requests will match this component and the params.
*/
path = '/post/:post?'
/*
Define the schema which is enforced by the arango decorator on `save` commands.
*/
schema = UserSchema
uniques = ['email']
async respond () {
console.log('this.props.params', this.props.params)
console.log('this.actions.moveUp', this.action.moveUp)
const output = await this.actions.findOne({
where: {"body": "Updated!"} // The `database` has special find functions with query-building
})
return {
data: {
players: this.props.players,
output
}
}
}
}
Final.createServer({
components: [Post],
port: 3001,
store, // optional, see `examples/game-server.js`
// middleware, /* Removed. Purpose needs to be decided. */
})
FAQs
A component-based server framework for ES6+, with a React-like lifecycle. Experimental.
The npm package final-server receives a total of 0 weekly downloads. As such, final-server popularity was classified as not popular.
We found that final-server 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
npm author Qix’s account was compromised, with malicious versions of popular packages like chalk-template, color-convert, and strip-ansi published.
Research
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.