-
src
-
- core // 核心/公共类库
-
-
- app.ts // 暴露一个koa application实例对象 和一个由logjs提供的logger工具类
-
-
-
- redis.ts // redis client的封装 promisified by bluebird
-
-
-
- sequelize.ts // 建立数据库链接 实例化数据模型 绑定模型关系
-
-
-
- (mongoose.ts) // 暂时不在库里
-
-
- middlewares // 抽取公用的中间件,例如上传 权限控制 头部检查 passport封装等
-
- models // model层
This file contains hidden or 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 path = require('path'); | |
| const nodeExternals = require('webpack-node-externals') | |
| module.exports = { | |
| entry: './src/app.ts', | |
| module: { | |
| rules: [ | |
| { | |
| test: /\.tsx?$/, | |
| use: 'ts-loader', |
This file contains hidden or 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
| <?xml version="1.0" encoding="UTF-8"?> | |
| <Configuration status="INFO"> | |
| <Appenders> | |
| <Console name="ConsoleStream" target="SYSTEM_OUT"> | |
| <PatternLayout pattern="%d{yyyy-dd-MM HH:mm:ss,SSS XXX}{GMT+0} [%t] %-5level %logger{36} - %msg%n" /> | |
| </Console> | |
| <RollingFile | |
| name="AppStream" | |
| fileName="runtime/logs/app.log" | |
| filePattern="runtime/logs/app-%d{yyyy-MM-dd}.log.gz" |
This file contains hidden or 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
| var diff = $(this).data('time')*1000 - Date.parse(new Date()); | |
| if (diff < 0 ) { $(this).text('竞猜结束');return; } | |
| var sec = diff/1000%60; | |
| var min = Math.floor(diff%(24*3600*1000)%(3600*1000)/(60*1000)) || ''; | |
| var hour = Math.floor(diff%(24*3600*1000)/(3600*1000)) || ''; | |
| var day = Math.floor(diff/(24*3600*1000)) || ''; | |
| day = day.length === 0 ? '' : day + '天'; | |
| hour = hour.length === 0 ? '' : hour + '小时'; | |
| min = min.length === 0 ? '' : min + '分钟'; | |
| sec = sec.length === 0 ? '' : sec + '秒'; |
This file contains hidden or 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
| var http = require('http') | |
| function callAPI() { | |
| return new Promise((resolve, reject) => { | |
| http.get('http://www.jb51.net', (res) => { | |
| resolve(res.statusCode) | |
| }) | |
| }) | |
| } |
This file contains hidden or 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 path = require('path') | |
| const ExtractTextPlugin = require("extract-text-webpack-plugin") | |
| const prod = process.argv.indexOf('-p') !== -1 | |
| const theme = 'geil' | |
| const ProjectRoot = path.dirname(path.dirname(path.dirname(__dirname))) | |
| const TargetWebRoot = path.join(ProjectRoot, 'blog', 'web', 'themes', theme) | |
| const ResourceRoot = path.join(__dirname, 'resources') |
This file contains hidden or 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
| $allControllers = []; | |
| function scanControllers($path, &$result) { | |
| $dirs = scandir($path); | |
| foreach($dirs as $dir){ | |
| if ($dir{0} == '.') { //todo: 适配linux下.开头的隐藏文件 | |
| continue; | |
| } | |
| if (substr($dir, -4) == '.php') { | |
| $result[] = $path. DIRECTORY_SEPARATOR .$dir; |
This file contains hidden or 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
| def load_apps(apps): | |
| import importlib | |
| GlobalUrls = [] | |
| for app in apps: | |
| module = importlib.import_module('app.{AppName}.urls'.format(AppName=app)) | |
| GlobalUrls += getattr(module,'urls') | |
| return GlobalUrls |
This file contains hidden or 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
| 'use strict'; | |
| var fn_use_rest = function(...rest){console.log(rest);} | |
| var fn_use_args = function(){console.log(arguments);} | |
| fn_use_rest(1,2,3,a=4,b=5); | |
| /* | |
| * OUTPUT | |
| * Array [1,2,3,4,5] |
This file contains hidden or 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
| public function getTestPjax(Request $request) { | |
| if($request->header('X-PJAX')){ | |
| return "here shoud render html snippts"; | |
| } else { | |
| return "here shoud render full documents"; | |
| } | |
| } |