This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
nginx: | |
restart: always | |
build: ./nginx | |
ports: | |
- "80:80" | |
volumes: | |
- /www/static | |
volumes_from: | |
- web | |
links: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
insertOrderItem(req, reply) { | |
const order_id = req.payload.order_id; | |
const product_id = req.payload.product_id; | |
const msg = new message(); | |
co(function*() { | |
const product = yield Product.get({ _id: product_id }); | |
const menu = yield Menu.get({ _id: product.menu_id }); | |
const order_item_doc = yield new Orderitem({ | |
is_add: true, | |
order_id: order_id, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import gulp from 'gulp'; | |
import gulpLoadPlugins from 'gulp-load-plugins'; | |
import path from 'path'; | |
import del from 'del'; | |
import runSequence from 'run-sequence'; | |
const plugins = gulpLoadPlugins(); | |
const paths = { | |
js: ['./**/*.js', '!dist/**', '!node_modules/**'], |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* with hapi, you should catch request in his way | |
* I am going to build a web Permission System | |
* use hapi's ext func , I can catch req before it get in | |
* route | |
*/ | |
server.ext('onRequest', function(request, reply) { | |
const JWT = require('jsonwebtoken'); | |
const token = request.headers.authorization; | |
const path = request.path; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Author: Magic <[email protected]> | |
* Module description: mongo func helper | |
*/ | |
'use strict'; | |
var mongo_funcs = function (mongo_name) { | |
this.findOne = (data) => { | |
return new Promise((resolve, reject) => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const moment = require('moment'), | |
localTime = require('moment-timezone'); | |
const timeHelp = { | |
//Returns the current time in Shanghai time zone | |
timeShanghai: function () { | |
return localTime.tz(moment(), "Asia/Shanghai").format("YYYY-MM-DD HH:mm"); | |
}, | |
//Passes in a UNIX time value, converts to local Shanghai Time, and returns the value | |
unixToShanghaiTime: function (unixTime) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const router = require('express').Router(), | |
Promise = require("bluebird"), | |
readFileAsync = Promise.promisify(require("fs").readFile), | |
writeFileAsync = Promise.promisify(require("fs").writeFile), | |
request_get = Promise.promisify(require('request').get); | |
router.route('/accesstoken') | |
.get((req, res) => { | |
readFileAsync("accesstoken.txt","utf8") | |
.then(data =>{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const PORT = parseInt(process.env.LEANCLOUD_APP_PORT || 3000); | |
app = express(); | |
const server = require('http').createServer(app); | |
//WebSocket; | |
let clients = []; // list of currently connected clients (users) | |
const WebSocketServer = require('websocket').server; | |
const wsServer = new WebSocketServer({ | |
httpServer: server, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const getOrderById = (_id)=> { | |
return new Promise((resolve, reject)=>{ | |
order_item_mongo.aggregate([{ | |
$match: {order_id: id} | |
}, { | |
$group : { | |
// _id : "$menu_id", | |
_id: { menu_id:"$menu_id", menu_name:"$menu_name"}, | |
products: { $push: { product_name: "$product_name"} } | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function() { | |
$.fn.extend({ | |
modalShow:function () { | |
var btnVal = this.attr('data-val'); | |
var $wantModal = $('[val='+btnVal+']'); | |
this.bind('click', function(event) { | |
/* Act on the event */ | |
$wantModal.removeClass('hide'); | |
}); |