https://github.com/11ways/alchemy
๐งช A node.js framework
https://github.com/11ways/alchemy
mvc-framework nodejs
Last synced: 6 months ago
JSON representation
๐งช A node.js framework
- Host: GitHub
- URL: https://github.com/11ways/alchemy
- Owner: 11ways
- License: mit
- Created: 2013-03-08T08:44:59.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2024-11-28T13:40:38.000Z (6 months ago)
- Last Synced: 2024-11-28T14:36:11.499Z (6 months ago)
- Topics: mvc-framework, nodejs
- Language: JavaScript
- Homepage:
- Size: 3.65 MB
- Stars: 2
- Watchers: 4
- Forks: 2
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
![]()
Alchemy
A node.js MVC framework
# Getting started
You can create a new, empty app by executing this npm command:
```bash
npm init alchemy your-app-name
```Then `npm install` the package.json contents.
This is only `alchemymvc` by default.# Installation
Just installing the npm package can be done like this:
$ npm install alchemymvc
# Quick start guide
You can find all the documentation on [https://alchemy.elevenways.be](https://alchemy.elevenways.be)
## Base class
Most Alchemy classes inherit from the `Base` class (which in turn inherits from the `Informer` class, a custom event emitter class)
Here are some important static methods:
### Base.setProperty([key,] getter, setter)
This will create a property getter/setter on the class. For example:
```js
MyClass.setProperty(function test_me() {
return 'test!'
});
```Will create a property getter called 'test_me' that will always return the string "test!"
```js
var instance = new MyClass();
instance.test_me;
// ยปยปยป "test!"
```### Base.setMethod([key,] fnc)
This will add a method to the class. For example:
```js
MyClass.setMethod(function testMe() {
return 'test!'
});
```Now you can call this method:
```js
var instance = new MyClass();
instance.testMe();
// ยปยปยป "test!"
```## Models
Creating a server-side model is easy, you need to inherit from the `Alchemy.Model.App`:
```js
var Block = Function.inherits('Alchemy.Model.App', function Block(conduit, options) {
Block.super.call(this, conduit, options);
});
```### Model schema
After that you probably want to define the schema to use, that has to be done in a `constitute` call:
```js
Block.constitute(function addFields() {// Add a simple unique string field
this.addField('name', 'String', {unique: true});// Another string field, that is not unique
this.addField('title', 'String');// Longer piece of text
this.addField('content', 'Text');
});
```By default 3 fields are already added to the schema:
* **_id**: An ObjectID field
* **created**: A datetime field with the creation date
* **updated**: A datetime field that gets updated whenever the record is saved## Authors
AlchemyMVC is developed at [Eleven Ways](https://www.elevenways.be/), a team of [IAAP Certified Accessibility Specialists](https://www.accessibilityassociation.org/).