Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Hello World example for Nodejitsu deployment

  • Loading branch information...
commit 5ac7dbe254511cb6a7e9a6a57ca4d8bf1bf37cd4 1 parent 37cb070
Prathamesh Satpute authored
3  .gitignore
View
@@ -1 +1,2 @@
-node_modules
+node_modules
+.c9revisions
8 .travis.yml
View
@@ -1,3 +1,9 @@
language: node_js
node_js:
- - 0.8
+ - 0.8
+notifications:
+ webhooks:
+ urls:
+ - http://webhooks.nodejitsu.com/1/deploy
+ on_success: always
+ on_failure: never
2  Makefile
View
@@ -4,7 +4,7 @@ REPORTER = dot
build: jshint test
jshint:
- jshint lib/ test/ examples/ --config .jshintrc
+ jshint lib/ test/ --config .jshintrc
test:
@./node_modules/.bin/mocha \
16 examples/app.js
View
@@ -1,12 +1,14 @@
var Coral = require('../lib/coral'),
- application;
+ application;
application = {
- root: __dirname,
- corals: [{
- name: "",
- model: {}
- }]
+ root: __dirname,
+ corals: [{
+ url: "/",
+ model: {
+ message: "Hello World"
+ }
+ }]
};
-return new Coral(application);
+var app = new Coral(application);
12 examples/views/index.jade
View
@@ -7,29 +7,29 @@ block content
span(class='icon-bar')
span(class='icon-bar')
span(class='icon-bar')
- a(class='brand', href='#') Coral
+ a(class='brand', href='/') Coral
.nav-collapse
ul(class='nav')
li(class='active')
a(href='/') Home
li
- a(href='about') About
- li
- a(href='about')
- br
+ a(href='/') About
br
br
+ br
.container-fluid
.row-fluid
.span3
div(class='well sidebar-nav')
ul(id='exampleList', class='nav nav-list')
li(class='nav-header') Examples
+ li
+ a(href='/') Hello World
.span9
.hero-unit
h1 Coral
p Dyanmic Node, Express, Mongoose, Backbone framework
br
br
- h2= model
+ h2= model.message
#mainArea
40 lib/coral.js
View
@@ -1,7 +1,6 @@
var createApp = function(site) {
- var express = require('express'),
- _ = require('underscore'),
- mongoose = require('mongoose');
+ var express = require('express'),
+ _ = require('underscore');
var configureApp = function(app) {
return function() {
@@ -19,46 +18,25 @@ var createApp = function(site) {
var createRoutes = function(coral, app) {
- var Model = createModel(coral);
-
- app.get('/' + coral.name, function(req, res) {
- Model.find({}, function(err, model) {
- if(err) {
- return next(err);
- }
- res.render('index', { model: "Hello World" });
+ app.get(coral.url, function(req, res) {
+ res.render('index', {
+ model: coral.model
});
});
- app.post('/' + coral.name, function(req, res) {
- var model = new Model();
- model.save(function(err) {
- if(err) {
- return next(err);
- }
- return res.send(model);
- });
- });
};
- var createModel = function(coral) {
- var properties = _.extend({
- _id: mongoose.Schema.ObjectId
- }, coral.model);
- var schema = new mongoose.Schema(properties);
- return mongoose.model(coral.name, schema);
- };
var initApp = function() {
var app = express();
app.configure(configureApp(app));
- mongoose.connect('mongodb://localhost/coral');
+
_.each(site.corals, function(coral, key) {
createRoutes(coral, app);
});
- app.listen(80);
- console.log("Listning app on port 80");
+ app.listen(8080);
+ console.log("Listning app on port 8080");
return app;
};
@@ -70,4 +48,4 @@ var createApp = function(site) {
exports = module.exports = createApp;
-exports.version = '0.0.3';
+exports.version = '0.0.4';
5 package.json
View
@@ -1,14 +1,14 @@
{
"name": "Coral",
"description": "Node JS framework to dynamically create REST apps",
- "version": "0.0.3",
+ "version": "0.0.4",
"author": {
"name": "Prathamesh Satpute (A-1 Enterprises)",
"email": "prathamesh.satpute@a-1enterprises.in"
},
"keywords": ["node", "backbone","mongoose"],
"scripts": {
- "test": "make test"
+ "start": "node ./examples/app.js"
},
"repository": {
"type": "git",
@@ -16,7 +16,6 @@
},
"dependencies": {
"express": "3.0.x",
- "mongoose": "2.7.x",
"jade": "0.27.x",
"underscore": "1.3.x"
},
Please sign in to comment.
Something went wrong with that request. Please try again.