From de773972a98ab1946efb7b0902bd2a3d6878443b Mon Sep 17 00:00:00 2001 From: Amir Jafarian Date: Fri, 11 Nov 2016 16:39:56 -0500 Subject: [PATCH] Add a custom Express route --- client/index.html | 2 +- common/models/coffee-shop.js | 8 ++++---- server/boot/create-sample-models.js | 10 +++++----- server/boot/routes.js | 9 +++++++++ server/middleware.json | 2 +- 5 files changed, 20 insertions(+), 11 deletions(-) create mode 100644 server/boot/routes.js diff --git a/client/index.html b/client/index.html index fa01bbb..d805393 100644 --- a/client/index.html +++ b/client/index.html @@ -2,4 +2,4 @@

LoopBack Rocks!

Hello World...

- \ No newline at end of file + diff --git a/common/models/coffee-shop.js b/common/models/coffee-shop.js index 1f6178a..f04fbb0 100644 --- a/common/models/coffee-shop.js +++ b/common/models/coffee-shop.js @@ -19,12 +19,12 @@ module.exports = function(CoffeeShop) { 'status', { http: { path: '/status', - verb: 'get' + verb: 'get', }, returns: { arg: 'status', - type: 'string' - } + type: 'string', + }, } ); -}; \ No newline at end of file +}; diff --git a/server/boot/create-sample-models.js b/server/boot/create-sample-models.js index 10cec31..06473ab 100644 --- a/server/boot/create-sample-models.js +++ b/server/boot/create-sample-models.js @@ -6,17 +6,17 @@ module.exports = function(app) { app.models.CoffeeShop.create([{ name: 'Bel Cafe', - city: 'Vancouver' + city: 'Vancouver', }, { name: 'Three Bees Coffee House', - city: 'San Mateo' + city: 'San Mateo', }, { name: 'Caffe Artigiano', - city: 'Vancouver' - }, ], function(err, coffeeShops) { + city: 'Vancouver', + }], function(err, coffeeShops) { if (err) throw err; console.log('Models created: \n', coffeeShops); }); }); -}; \ No newline at end of file +}; diff --git a/server/boot/routes.js b/server/boot/routes.js new file mode 100644 index 0000000..8f0aa92 --- /dev/null +++ b/server/boot/routes.js @@ -0,0 +1,9 @@ +'use strict'; + +module.exports = function(app) { + // Install a "/ping" route that returns "pong" + app.get('/ping', function(req, res) { + res.send('pong'); + }); +}; + diff --git a/server/middleware.json b/server/middleware.json index f5b8de2..98aa07a 100644 --- a/server/middleware.json +++ b/server/middleware.json @@ -43,7 +43,7 @@ "files": { "loopback#static": { "params": "$!../client" - } + } }, "final": { "loopback#urlNotFound": {}