| @@ -0,0 +1,215 @@ | ||
| // Get the packages we need | ||
| var express = require('express'); | ||
| var mongoose = require('mongoose'); | ||
| var Llama = require('./models/llama'); | ||
| var User = require('./models/users'); | ||
| var Task = require('./models/tasks'); | ||
| var bodyParser = require('body-parser'); | ||
| var router = express.Router(); | ||
|
|
||
| //replace this with your Mongolab URL | ||
| //mongoose.connect('mongodb://localhost/mp3'); | ||
| mongoose.connect('mongodb://root:root@ds061621.mongolab.com:61621/mp3', function(err) { | ||
| if(err) { | ||
| console.log('connection error', err); | ||
| } else { | ||
| console.log('connection successful'); | ||
| } | ||
| }); | ||
|
|
||
| // Create our Express application | ||
| var app = express(); | ||
|
|
||
| // Use environment defined port or 4000 | ||
| var port = process.env.PORT || 4000; | ||
|
|
||
| //Allow CORS so that backend and frontend could pe put on different servers | ||
| var allowCrossDomain = function(req, res, next) { | ||
| res.header("Access-Control-Allow-Origin", "*"); | ||
| res.header("Access-Control-Allow-Headers", "X-Requested-With, X-HTTP-Method-Override, Content-Type, Accept"); | ||
| res.header("Access-Control-Allow-Methods", "POST, GET, OPTIONS, PUT, DELETE"); | ||
| next(); | ||
| }; | ||
| app.use(allowCrossDomain); | ||
|
|
||
| // Use the body-parser package in our application | ||
| app.use(bodyParser.urlencoded({ | ||
| extended: true | ||
| })); | ||
|
|
||
| // All our routes will start with /api | ||
| app.use('/api', router); | ||
|
|
||
| //Default route here | ||
| var homeRoute = router.route('/'); | ||
|
|
||
| homeRoute.get(function(req, res) { | ||
| res.json({ message: 'Hello World!' }); | ||
| }); | ||
| //----------------------------------------------------------------------------------- | ||
| router.get('/llamas',function(req, res,next) { | ||
| var q = JSON.stringify(req.query); | ||
| console.log("q"+q); | ||
| var ret = 'Llama' | ||
| if (typeof req.query.where === 'undefined') ret = ret+'.find({})'; | ||
| else ret = ret+'.find('+req.query.where+')'; | ||
| if (typeof req.query.sort != 'undefined') ret = ret+'.sort('+req.query.sort+')'; | ||
| if (typeof req.query.select != 'undefined') ret = ret+'.select('+req.query.select+')'; | ||
| if (typeof req.query.skip != 'undefined') ret = ret+'.skip('+req.query.skip+')'; | ||
| if (typeof req.query.limit != 'undefined') ret = ret+'.limit('+req.query.limit+')'; | ||
| if (typeof req.query.count != 'undefined') ret = ret+'.count('+req.query.count+')'; | ||
| ret = ret + ".exec(function(err,get){if(err) return next(err); res.json(get);});" | ||
| console.log(ret); | ||
| console.log("----"); | ||
| eval(ret); | ||
| }); | ||
|
|
||
| router.post('/llamas',function(req,res,next){ | ||
| Llama.create(req.body,function(err,post){ | ||
| if(err) return next(err); | ||
| res.json(post); | ||
| }); | ||
| }); | ||
|
|
||
| router.options('/llamas',function(req,res,next){ | ||
| res.writeHead(200); | ||
| res.end(); | ||
| }); | ||
|
|
||
| router.get('/llamas/:id',function(req,res,next){ | ||
| Llama.findOne({_id:req.params.id},function(err,get){ | ||
| if(err) return next(err); | ||
| res.json(get); | ||
| }); | ||
| }); | ||
|
|
||
| router.put('/llamas/:id',function(req,res,next){ | ||
| Llama.findOneAndUpdate({_id:req.params.id},req.body,function(err,put){ | ||
| if(err) return next(err); | ||
| res.json(put); | ||
| }); | ||
| }); | ||
|
|
||
| router.delete('/llamas/:id',function(req,res,next){ | ||
| Llama.findByIdAndRemove({_id:req.params.id},req.body,function(err,del){ | ||
| if(err) return next(err); | ||
| res.json(del); | ||
| }); | ||
| }); | ||
| //----------------------------------------------------------------------------------- | ||
| router.get('/users',function(req, res,next) { | ||
| var q = JSON.stringify(req.query); | ||
| console.log("q"+q); | ||
| var ret = 'User' | ||
| if (typeof req.query.where === 'undefined') ret = ret+'.find({})'; | ||
| else ret = ret+'.find('+req.query.where+')'; | ||
| if (typeof req.query.sort != 'undefined') ret = ret+'.sort('+req.query.sort+')'; | ||
| if (typeof req.query.select != 'undefined') ret = ret+'.select('+req.query.select+')'; | ||
| if (typeof req.query.skip != 'undefined') ret = ret+'.skip('+req.query.skip+')'; | ||
| if (typeof req.query.limit != 'undefined') ret = ret+'.limit('+req.query.limit+')'; | ||
| if (typeof req.query.count != 'undefined') ret = ret+'.count('+req.query.count+')'; | ||
| ret = ret + ".exec(function(err,get){if(err) return next(err); var id = '{\"message\": '+res.statusCode+',\"data\":'+JSON.stringify(get)+'}';id = JSON.parse(id);res.json(id);});" | ||
| //ret = ret + ".exec(function(err,get){if(err) return next(err);res.json(get);});" | ||
| console.log(ret); | ||
| eval(ret); | ||
| console.log('---------------------------------------------------------------'); | ||
| }); | ||
|
|
||
| router.post('/users',function(req,res,next){ | ||
| User.create(req.body,function(err,post){ | ||
| if(err) return next(err); | ||
| var id = '{"message": '+res.statusCode+',"data":'+JSON.stringify(post)+'}'; | ||
| id = JSON.parse(id); | ||
| res.json(id); | ||
| }); | ||
| }); | ||
|
|
||
| router.options('/users',function(req,res,next){ | ||
| res.writeHead(200); | ||
| res.end(); | ||
| }); | ||
|
|
||
| router.get('/users/:id',function(req,res,next){ | ||
| User.findOne({_id:req.params.id},function(err,get){ | ||
| if(err) return next(err); | ||
| var id = '{"message": '+res.statusCode+','+ | ||
| '"data":'+JSON.stringify(get)+'}'; | ||
| id = JSON.parse(id); | ||
| res.json(id); | ||
| }); | ||
| }); | ||
|
|
||
| router.put('/users/:id',function(req,res,next){ | ||
| User.findOneAndUpdate({_id:req.params.id},req.body,function(err,put){ | ||
| if(err) return next(err); | ||
| var id = '{"message": '+res.statusCode+','+ | ||
| '"data":'+JSON.stringify(put)+'}'; | ||
| id = JSON.parse(id); | ||
| res.json(id); | ||
| }); | ||
| }); | ||
|
|
||
| router.delete('/users/:id',function(req,res,next){ | ||
| User.findOneAndRemove({_id:req.params.id},req.body,function(err,del){ | ||
| if(err) return next(err); | ||
| var id = '{"message": '+res.statusCode+','+ | ||
| '"data":'+JSON.stringify(del)+'}'; | ||
| id = JSON.parse(id); | ||
| res.json(id); | ||
| }); | ||
| }); | ||
| //----------------------------------------------------------------------------------- | ||
| router.get('/tasks',function(req, res,next) { | ||
| var q = JSON.stringify(req.query); | ||
| console.log("q"+q); | ||
| var ret = 'Task' | ||
| if (typeof req.query.where === 'undefined') ret = ret+'.find({})'; | ||
| else ret = ret+'.find('+req.query.where+')'; | ||
| if (typeof req.query.sort != 'undefined') ret = ret+'.sort('+req.query.sort+')'; | ||
| if (typeof req.query.select != 'undefined') ret = ret+'.select('+req.query.select+')'; | ||
| if (typeof req.query.skip != 'undefined') ret = ret+'.skip('+req.query.skip+')'; | ||
| if (typeof req.query.limit != 'undefined') ret = ret+'.limit('+req.query.limit+')'; | ||
| if (typeof req.query.count != 'undefined') ret = ret+'.count('+req.query.count+')'; | ||
| ret = ret + ".exec(function(err,get){if(err) return next(err); var id = '{\"message\": '+res.statusCode+',\"data\":'+JSON.stringify(post)+'}';id = JSON.parse(id);res.json(id);});" | ||
| eval(ret); | ||
| console.log(id); | ||
| console.log('---------------------------------------------------------------'); | ||
| }); | ||
|
|
||
| router.post('/tasks',function(req,res,next){ | ||
| Task.create(req.body,function(err,post){ | ||
| if(err) return next(err); | ||
| var id = '{"message": '+res.statusCode+',"data":'+JSON.stringify(post)+'}'; | ||
| id = JSON.parse(id); | ||
| res.json(id); | ||
| }); | ||
| }); | ||
|
|
||
| router.options('/tasks',function(req,res,next){ | ||
| res.writeHead(200); | ||
| res.end(); | ||
| }); | ||
|
|
||
| router.get('/tasks/:id',function(req,res,next){ | ||
| Task.findOne({_id:req.params.id},function(err,get){ | ||
| if(err) return next(err); | ||
| res.json(get); | ||
| }); | ||
| }); | ||
|
|
||
| router.put('/tasks/:id',function(req,res,next){ | ||
| Task.findOneAndUpdate({_id:req.params.id},req.body,function(err,put){ | ||
| if(err) return next(err); | ||
| res.json(put); | ||
| }); | ||
| }); | ||
|
|
||
| router.delete('/tasks/:id',function(req,res,next){ | ||
| Task.findOneAndRemove({_id:req.params.id},req.body,function(err,del){ | ||
| if(err) return next(err); | ||
| res.json(del); | ||
| }); | ||
| }); | ||
| // Start the server | ||
| app.listen(port); | ||
| console.log('Server running on port ' + port); |
| @@ -0,0 +1,304 @@ | ||
| A backflip | ||
| Abduct kitten | ||
| Actually do some work whilst currently in work | ||
| Alphabetise the cheese collection | ||
| Analyse firm-wide billings to clients | ||
| Apply for that job; Closing date tomorrow | ||
| Apprendre à mieux chiller | ||
| Arrêter d'envoyer des conneries dans kazaa | ||
| Ask about ownership of drum kit downstairs | ||
| Ask out Alice | ||
| Become a Doctor | ||
| Book that surfing trip | ||
| Build a nuclear bomb and send it to the moon | ||
| Buy a new smartphone | ||
| Buy a newspaper | ||
| Buy more post-its | ||
| Buy new underwear | ||
| Buy some new post-it notes | ||
| Call my old friend | ||
| Call potential clients to try to sell them our products | ||
| Call the bank and explain why I can't repay my loan just yet | ||
| Change Career | ||
| Change the baby | ||
| Change the bed sheets it's been 3 months | ||
| Change the saw dust in the Quails house | ||
| Clean out the broken glass out of the fridge | ||
| Clean out the loft space | ||
| Clean the bathroom | ||
| Clean the fish tank | ||
| Clean the guinea rat cage | ||
| Clean the tissue that the puppy shredded | ||
| Clean the wear | ||
| Clean up after The US Army | ||
| Clean up dog poo | ||
| Clean, everything needs cleaning always and forever | ||
| Cleaning up my room | ||
| Clear the spare bedroom | ||
| Click "LOG OFF" and go home! | ||
| Collect dust | ||
| Come up with get rich quick scheme and retire in a year | ||
| Come up with more ideas like this | ||
| Complete my coursework, it's already late | ||
| Cooking tea- yumy sausages | ||
| Create the world's smallest to-do list | ||
| Create WoW character | ||
| Cut left foot nails | ||
| Dallas, or has Debbie already covered that? | ||
| Danser la javanaise avec Mégane Fox | ||
| De oude vijver volstorten met zand | ||
| De-fluff my belly buton | ||
| Decorate the bathroom wall | ||
| Deep nose-picking in order pleasantly to scratch my brain | ||
| DENTIST!!! | ||
| Destroy human civilisation | ||
| Deutsch lernen! Bitte schön! | ||
| Dire à cette meuf ce que j'en pense | ||
| Do coursework without being distracted and having a wank | ||
| Do my homeworks in japanese :( | ||
| Do my taxes | ||
| Do not go to the pub after work or put a bet on | ||
| Do stuff on to-do list | ||
| Do the laundry | ||
| Do the required reading | ||
| Do the sound engineering work | ||
| Do what my dumb supervisor asking me to do | ||
| Don't forget to breathe | ||
| Don't put off until tomorrow what I can do the day after! | ||
| Drop off dry cleaning | ||
| Dat more cheesecake | ||
| Eat pork All the pork | ||
| Dmail my uncle in Norway | ||
| Dxercise more, eat better and get rid of this cold! | ||
| Fence more, work less | ||
| File careworker paperwork away | ||
| File taxes | ||
| Fill apples with helium, get money from store, repeat | ||
| Fill in the census | ||
| Fill out my passport forms | ||
| Fill out the insurance claim form | ||
| Finally learn that bass line | ||
| Find a flat | ||
| Find a job | ||
| Find a job | ||
| Find a summer job | ||
| Find a way to change the world | ||
| Find an income | ||
| Find Jesus | ||
| Find some pills for my attention defecit disorder | ||
| Find something interesting to do on the net | ||
| Find that photo | ||
| Finish essay | ||
| Finish my book | ||
| Finish my degree seriously | ||
| Finish off the chocolate before anyone else can get some | ||
| Finish Persona 3 | ||
| Finish PhD | ||
| Finish writing that physical report | ||
| Finish writing this opera | ||
| Flush the toilet | ||
| Fly to USA | ||
| Forget Carre Viiip | ||
| French kiss with bibo chaw9i | ||
| Get a cat | ||
| Get a proper job | ||
| Get dressed would be a good start | ||
| Get married soome time later, get a divorce | ||
| Get my bass face on | ||
| Get my diary written fully | ||
| Get my husband a birthday present | ||
| Get one of those things for getting the knots out of sheep | ||
| Get over my hangover | ||
| Get some revision done before watching more X Files | ||
| Get some sleep | ||
| Get the girl | ||
| Give my boyfriend a dog | ||
| Give some good food to my fishes | ||
| Go for a 40 min run | ||
| Go for a walk instead of having a third gin & tonic | ||
| Go to bed | ||
| Go to my local pub for a delicious meal | ||
| Go to the dentist | ||
| Go to the doctor | ||
| Have a shower | ||
| Help | ||
| Implement world peace, end poverty, wash up | ||
| Jailbreak iOS | ||
| Join balticlab | ||
| Jump | ||
| Kill | ||
| Kiss my baby more instead of cleaning | ||
| Laugh riotously at the state of fish that eat cabbage | ||
| Learn about metacognition and how to defeat procrastination | ||
| Learn c++ | ||
| Learn how to anticrastinate | ||
| Learn stuff and then relax | ||
| Learn to fly | ||
| Learn to play my bass guitar I bought last year | ||
| Learn to play the keyboards | ||
| Learn to spell porcastination | ||
| Leave my abusive girlfriend | ||
| Look for an apartment I can afford | ||
| Lose about ten stone | ||
| Love Jesus | ||
| Ma déclaration de revenus pour les impôts | ||
| Make (and complete) a revision timetable | ||
| Make a To-do list | ||
| Make an inventory of my stuff so I can sell it all | ||
| Make an inventory of my stuff so I can sell it all | ||
| Make diagram of how to load the dishwasher, for my husband | ||
| Make little models of houses | ||
| Me mettre au français | ||
| Meeting a nice woman | ||
| Memorise an 7 minute English oral | ||
| Meow | ||
| Moisturise skanky dry feet | ||
| Move in with my Girlfriend | ||
| Moving out of my parents' house | ||
| Murder a pineapple | ||
| My homework from two weeks ago X( | ||
| My laundry | ||
| Not get caught | ||
| Not play Settlers instead of doing work | ||
| Open all the things I bought & left in the boxes for years | ||
| Order a massage for our exhausted colleague Olivier | ||
| Ouvrir mes syllabus | ||
| Pack my bags to take home | ||
| Pack my travel case for my trip to Turkey | ||
| Pay my 2009 income taxes | ||
| Pay my taxes | ||
| Pay the mafia | ||
| Phone insurance company | ||
| Play guitar | ||
| Play my ukulele | ||
| Play tennis with Rach after work | ||
| Playing drums | ||
| Polish my flute | ||
| Pppaaaaarrrrtttyyyyyy!!!!! | ||
| Prepare invoices and send them | ||
| Presenation on COPD before Tuesday | ||
| Procrastinate tomorrow | ||
| Put a load of washing on | ||
| Put away Christmas decorations | ||
| Put my dvds in the right cases | ||
| Put my iphone in the garbage! | ||
| Put new cover sheets on all TPS reports | ||
| quit job enjoy life | ||
| Quit my job and go living in Dakar with my girlfriend | ||
| Quit my Job Again | ||
| Read every one of these, then forget what it was I was doing | ||
| read the 7 books iv just downloaded | ||
| read up on giving birth | ||
| Record my new song | ||
| redevelop our menu for spring including a new vegie option | ||
| Reformat hdd's in PC and laptop then reinstall | ||
| Register with a new doctor before I'm actually ill | ||
| Relocate my invisible monkey | ||
| replace worn-out aglets on shoelaces | ||
| Ring Baz re: Jill | ||
| Ron Ron | ||
| Save the cheerleader, save The World | ||
| Say hello | ||
| say hello | ||
| See if I can walk through walls | ||
| Shave arse | ||
| Shear the sheep | ||
| Shine hills's head | ||
| shower | ||
| sleep before I drop | ||
| sober up | ||
| Socks | ||
| some of my work and get off funny websites | ||
| Some work, while in work | ||
| something with my life besides sleep all day | ||
| sort my e-mails out | ||
| Sort my fucking life out | ||
| sort my garden fence out before the puppy runs away | ||
| Sort my life out | ||
| sort out canadian tax | ||
| sort out life insurance policy | ||
| sort out this wedding malarky | ||
| sort the insurance out before it's too late | ||
| sta y sober | ||
| Stare out of the window for 2 minutes | ||
| start being happy happy happy and giving less shit | ||
| start my master thesis!!!!! | ||
| start my own business | ||
| start taking responsibility for bigger things | ||
| stop being a jerk | ||
| stop being in love | ||
| stop drinking so much | ||
| stop eating three packets of crisps in one lunch time | ||
| stop ignoring my to-do list | ||
| Stop looking at this bloody website | ||
| Stop looking at this list and actually start my task | ||
| Stop looking for trivia on the internet | ||
| stop making lists | ||
| stop somking | ||
| stop surfing time-wasting sites | ||
| stop thinking about her YAY EMO POST | ||
| stop thinking about him | ||
| stop wasting time on facebook! | ||
| Stop wasting time on the internet and go outside - it's hot! | ||
| Stop working! | ||
| Study | ||
| Study for Advanced Linear Algebra | ||
| study for english test tomorrow | ||
| study for finals, finish my homework, sleep | ||
| study for mock exams fucking shit! | ||
| study for my exams | ||
| Supermarket shopping | ||
| ta-da | ||
| Take over the world | ||
| take over the world starting with Wales | ||
| take the cat for a walk | ||
| tell every girl I know what I really think about her | ||
| Tell to my best friend that I date her college sinds 1 year | ||
| that is the question | ||
| think of something to do | ||
| tidy my room | ||
| tidy the bedroom | ||
| to bay iped | ||
| to be a better artist | ||
| to do to go to the doctor | ||
| to get a new job | ||
| to go on diet | ||
| To learn to love the I Phone | ||
| to live | ||
| to live | ||
| To wake up early | ||
| To-do my to-do list | ||
| Make a list of things I need to do urgently | ||
| toke a reefer, take a hit, smoke that shit! | ||
| travel to alfa 456-E in spiral galaxy | ||
| try my home perpetual motion machine | ||
| try to loose my keys | ||
| Trying not to break anymore bones by skateboarding | ||
| Turn back garden into a new Eden | ||
| Unblock the bathroom sink | ||
| Uni assignment about assessment strategies | ||
| Unpack one of the many full boxes here in my new home | ||
| Update my team's resource schedule with all the gap requests | ||
| view a house I don't want to live in | ||
| Wash my car | ||
| wash my bedsheets before the big date on Friday | ||
| Wash up 3 weeks worth of plates and pans | ||
| Waste less time online | ||
| Watch an old person fall off a shop mobility scooter | ||
| Watch the Godfather trilogy | ||
| watching the all blacks trash everybody | ||
| Wear a pointy hat | ||
| Work for the university | ||
| Work Actual work | ||
| Workout | ||
| Write a to do list | ||
| Write an article on bank accounts | ||
| Write an article on procrastination | ||
| Write different tedious code | ||
| Write list | ||
| Write my PhD thesis | ||
| Write my thesis | ||
| Write proposals | ||
| Write tedious code | ||
| Write up a decent treatment for the MyHeartLog documentary | ||
| Write up my weekly progam and send it to my boss |