Skip to content

Commit fe360a5

Browse files
committed
add new files
1 parent d13b781 commit fe360a5

File tree

1,508 files changed

+253178
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,508 files changed

+253178
-0
lines changed

BootstrapFactory/index.html

Lines changed: 496 additions & 0 deletions
Large diffs are not rendered by default.

CitizenIdentityAuthService/app.js

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
var express = require('express');
2+
var path = require('path');
3+
var favicon = require('serve-favicon');
4+
var logger = require('morgan');
5+
var cookieParser = require('cookie-parser');
6+
var bodyParser = require('body-parser');
7+
8+
var routes = require('./routes/index');
9+
var users = require('./routes/users');
10+
11+
var mongoose = require('mongoose');
12+
13+
var Bear = require('./app/models/bear');
14+
15+
var app = express();
16+
17+
// view engine setup
18+
app.set('views', path.join(__dirname, 'views'));
19+
app.set('view engine', 'jade');
20+
21+
// uncomment after placing your favicon in /public
22+
//app.use(favicon(__dirname + '/public/favicon.ico'));
23+
app.use(logger('dev'));
24+
//app.use(bodyParser.json());
25+
//app.use(bodyParser.urlencoded({ extended: false }));
26+
app.use(cookieParser());
27+
app.use(express.static(path.join(__dirname, 'public')));
28+
29+
30+
// ROUTES FOR OUR API
31+
// =============================================================================
32+
var router = express.Router(); // get an instance of the express Router
33+
34+
// middleware to use for all requests
35+
router.use(function (req, res, next) {
36+
// do logging
37+
console.log('Something is happening.');
38+
next(); // make sure we go to the next routes and don't stop here
39+
});
40+
41+
// test route to make sure everything is working (accessed at GET http://localhost:8080/api)
42+
router.get('/', function (req, res) {
43+
res.json({ message: 'hooray! welcome to our api!' });
44+
});
45+
46+
// more routes for our API will happen here
47+
app.use('/', routes);
48+
app.use('/users', users);
49+
50+
// on routes that end in /bears
51+
// ----------------------------------------------------
52+
router.route('/bears')
53+
// create a bear (accessed at POST http://localhost:8080/api/bears)
54+
.post(function (req, res) {
55+
console.log(req.body);
56+
57+
var bear = new Bear(); // create a new instance of the Bear model
58+
bear.name = req.body.name; // set the bears name (comes from the request)
59+
60+
61+
// save the bear and check for errors
62+
bear.save(function (err) {
63+
if (err)
64+
res.send(err);
65+
66+
res.json({ message: 'Bear created!' });
67+
});
68+
69+
})
70+
71+
// get all the bears (accessed at GET http://localhost:8080/api/bears)
72+
.get(function(req, res) {
73+
Bear.find(function(err, bears) {
74+
if (err)
75+
res.send(err);
76+
77+
res.json(bears);
78+
});
79+
});
80+
81+
// on routes that end in /bears/:bear_id
82+
// ----------------------------------------------------
83+
router.route('/bears/:bear_id')
84+
85+
// get the bear with that id (accessed at GET http://localhost:8080/api/bears/:bear_id)
86+
.get(function(req, res) {
87+
Bear.findById(req.params.bear_id, function(err, bear) {
88+
if (err)
89+
res.send(err);
90+
res.json(bear);
91+
});
92+
})
93+
94+
// update the bear with this id (accessed at PUT http://localhost:8080/api/bears/:bear_id)
95+
.put(function(req, res) {
96+
97+
// use our bear model to find the bear we want
98+
Bear.findById(req.params.bear_id, function(err, bear) {
99+
100+
if (err)
101+
res.send(err);
102+
103+
bear.name = req.body.name; // update the bears info
104+
105+
// save the bear
106+
bear.save(function(err) {
107+
if (err)
108+
res.send(err);
109+
110+
res.json({ message: 'Bear updated!' });
111+
});
112+
113+
});
114+
});
115+
116+
// all of our routes will be prefixed with /api
117+
app.use('/api', router);
118+
119+
// catch 404 and forward to error handler
120+
app.use(function (req, res, next) {
121+
var err = new Error('Not Found');
122+
err.status = 404;
123+
next(err);
124+
});
125+
126+
// error handlers
127+
128+
// development error handler
129+
// will print stacktrace
130+
if (app.get('env') === 'development') {
131+
app.use(function (err, req, res, next) {
132+
res.status(err.status || 500);
133+
res.render('error', {
134+
message: err.message,
135+
error: err
136+
});
137+
});
138+
}
139+
140+
// production error handler
141+
// no stacktraces leaked to user
142+
app.use(function (err, req, res, next) {
143+
res.status(err.status || 500);
144+
res.render('error', {
145+
message: err.message,
146+
error: {}
147+
});
148+
});
149+
150+
mongoose.connect('mongodb://node:[email protected]:27017/hebo2Wor'); // connect to our database
151+
152+
module.exports = app;
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// app/models/bear.js
2+
3+
var mongoose = require('mongoose');
4+
var Schema = mongoose.Schema;
5+
6+
var BearSchema = new Schema({
7+
name: String
8+
});
9+
10+
module.exports = mongoose.model('Bear', BearSchema);

CitizenIdentityAuthService/bin/www

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/usr/bin/env node
2+
var debug = require('debug')('CitizenIdentityAuthService');
3+
var app = require('../app');
4+
5+
app.set('port', process.env.PORT || 3000);
6+
7+
var server = app.listen(app.get('port'), function() {
8+
debug('Express server listening on port ' + server.address().port);
9+
});

CitizenIdentityAuthService/node_modules/.bin/jade

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

CitizenIdentityAuthService/node_modules/.bin/jade.cmd

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)