Permalink
Browse files

added requirejs example

  • Loading branch information...
1 parent 35591f1 commit ca44f83fab0cfd14c764188ae300b32d55c5ba0f siedrix committed Nov 21, 2012
Showing with 51 additions and 0 deletions.
  1. +3 −0 .gitignore
  2. +12 −0 requirejs/example.js
  3. +7 −0 requirejs/modules/models.js
  4. +11 −0 requirejs/modules/server.js
  5. +9 −0 requirejs/modules/user.js
  6. +9 −0 requirejs/package.json
View
@@ -12,3 +12,6 @@ logs
results
npm-debug.log
+
+.DS_Store
+*/node_modules
View
@@ -0,0 +1,12 @@
+var requirejs = require('requirejs');
+
+requirejs.config({
+ baseUrl: 'modules',
+ nodeRequire: require
+});
+
+requirejs(['server'], function(server){
+ server.listen(3000);
+
+ console.log('server running at http://localhost:3000');
+});
@@ -0,0 +1,7 @@
+define(['resourceful'], function (resourceful) {
+ resourceful.use('couchdb', {
+ database : 'test'
+ });
+
+ return resourceful;
+});
@@ -0,0 +1,11 @@
+define(['express','user'], function (express, User) {
+ var server = express();
+
+ server.get('/', function (req,res) {
+ User.all(function(err, docs){
+ res.send(err || docs);
+ });
+ });
+
+ return server;
+});
@@ -0,0 +1,9 @@
+define(['models'], function(models){
+ var User = models.define('user', function () {
+ //Properties
+ this.string('username');
+ this.object('password');
+ });
+
+ return User;
+});
View
@@ -0,0 +1,9 @@
+{
+ "name": "requirejs-example",
+ "version": "0.0.1",
+ "dependencies": {
+ "requirejs" : "2.1.1",
+ "resourceful" : "0.3.3",
+ "express" : "3.0.3"
+ }
+}

0 comments on commit ca44f83

Please sign in to comment.