- produtos-api
- compras-api
Realização de uma venda utilizando as duas api's.
| angular.module('blogjs.post').run(function($rootScope, $location){ | |
| var paginasLivres = [ | |
| '/posts', | |
| '/usuario/cadastro', | |
| '/login' | |
| ]; | |
| $rootScope.$on("$locationChangeStart",function(event, next, current){ | |
| var path = next.split('/#')[1]; |
| def init = [name:'Leonardo', age:26] | |
| Async(vertx, init).waterfall([{ data -> | |
| next(data + [job:'dev']) | |
| }, { data -> | |
| next(data + [langs:['groovy', 'java']]) | |
| }, { | |
| fail(new RuntimeException('any error') |
| angular.module('blogjs.autorizacao', ['blogjs.interceptadores']).config(function($httpProvider){ | |
| $httpProvider.interceptors.push('AutorizadorInterceptor'); | |
| }); |
| //Cria um Index do tipo 2dsphere | |
| db.people.createIndex({location:"2dsphere"}) | |
| //Longitude, Latitude | |
| db.people.insert({location:[-9.1368980,38.7639020]}) | |
| db.users.find({ | |
| location:{ | |
| $near: { | |
| $geometry:{ |
| var doc = require('dynamodb-doc'); | |
| var dynamo = new doc.DynamoDB(); | |
| function handleResult(context, event){ | |
| return function(){ | |
| var result = this.data || {Count:0, Items:[]}; | |
| var data = {total:result.Count}; | |
| data.items = result.Items.map(function(result){ | |
| return {email:result.Email, tenant:result.Tenant}; |
| app.get('/usuarios', function(req, res){ | |
| var nome = req.query.nome; | |
| var query = model.Usuario.find(); | |
| if(nome) | |
| query.where('nome').equals(nome); | |
| query.limit(10).sort('-nome') | |
| query.exec(function(err, usuarios){ | |
| res.status(200).json(usuarios); |
| app.post('/usuarios', function(req, res){ | |
| new model.Usuario({nome:'Qualquer'}}).save(function(error, data){ | |
| if(error){ | |
| res.status(400).json({message:error.message}); | |
| } else { | |
| res.status(201).json(data); | |
| } | |
| }); | |
| }); |
| var mongoose = require('mongoose'); | |
| var Schema = mongoose.Schema; | |
| var TelefoneSchema = new Schema({ | |
| _id:false, | |
| ddd: Number, | |
| numero: Number | |
| }); | |
| var ContatoSchema = new Schema({ |
| var express = require('express'); | |
| var expressValidator = require('express-validator'); | |
| var app = express(); | |
| var bodyParser = require('body-parser'); | |
| app.use(bodyParser.json()); | |
| app.use(expressValidator({ | |
| customValidators: { | |
| isPhones: function(values) { | |
| var ehArray = Array.isArray(values); |