From 17512f6e77d78f731189ae22a18168cd1f049132 Mon Sep 17 00:00:00 2001 From: Amir Jafarian Date: Tue, 22 Nov 2016 13:56:46 -0500 Subject: [PATCH] Remove `example/context` * Remove `example/context` since it is deprecated in LB 3.0 --- example/context/app.js | 36 ------------------------------------ 1 file changed, 36 deletions(-) delete mode 100644 example/context/app.js diff --git a/example/context/app.js b/example/context/app.js deleted file mode 100644 index 81ad0594..00000000 --- a/example/context/app.js +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright IBM Corp. 2014,2016. All Rights Reserved. -// Node module: loopback -// This file is licensed under the MIT License. -// License text available at https://opensource.org/licenses/MIT - -'use strict'; -var g = require('../../lib/globalize'); -var loopback = require('../../'); -var app = loopback(); - -// Create a LoopBack context for all requests -app.use(loopback.context()); - -// Store a request property in the context -app.use(function saveHostToContext(req, res, next) { - var ns = loopback.getCurrentContext(); - ns.set('host', req.host); - next(); -}); - -app.use(loopback.rest()); - -var Color = loopback.createModel('color', {'name': String}); -Color.beforeRemote('**', function(ctx, unused, next) { - // Inside LoopBack code, you can read the property from the context - var ns = loopback.getCurrentContext(); - g.log('Request to host %s', ns && ns.get('host')); - next(); -}); - -app.dataSource('db', {connector: 'memory'}); -app.model(Color, {dataSource: 'db'}); - -app.listen(3000, function() { - g.log('A list of colors is available at {{http://localhost:3000/colors}}'); -});