-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Made it a luarocks - Builtin make luarocks - Better project structure
- Loading branch information
1 parent
3390710
commit 284ae92
Showing
23 changed files
with
141 additions
and
165 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
nginx_tmp | ||
tmp/ |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,75 +1,35 @@ | ||
PREFIX ?= /usr/local | ||
OPENRESTY_PREFIX ?= $(PREFIX)/openresty | ||
INSTALL ?= @install | ||
LUA_INCLUDE_DIR ?= $(PREFIX)/include | ||
LUA_LIB_DIR ?= $(PREFIX)/lib/lua/$(LUA_VERSION) | ||
CURRENT_FOLDER ?= `pwd` | ||
|
||
# Env variables | ||
DEV_DAEMON=off | ||
PROD_DAEMON=on | ||
|
||
DEV_LUA_CODE_CACHE=off | ||
PROD_LUA_CODE_CACHE=on | ||
|
||
DEV_LUA_PATH ?= $(CURRENT_FOLDER)/lib/?.lua;; | ||
PROD_LUA_PATH ?= $(LUA_LIB_DIR)/?.lua;; | ||
|
||
PROD_CONF_DIR ?= /etc/apenode | ||
|
||
DEV_CONF_PATH ?= $(CURRENT_FOLDER)/etc/conf.yaml | ||
PROD_CONF_PATH ?= $(PROD_CONF_DIR)/conf.yaml | ||
|
||
.PHONY: all test install | ||
|
||
all: ; | ||
|
||
install: all | ||
|
||
############################## | ||
# Install the base structure # | ||
############################## | ||
|
||
$(INSTALL) -d $(LUA_LIB_DIR)/resty/apenode | ||
@cp -R lib/resty/apenode/ $(LUA_LIB_DIR)/resty/apenode/ | ||
|
||
############################# | ||
# Install the configuration # | ||
############################# | ||
|
||
# - nginx.conf | ||
@sed \ | ||
-e "s/{DAEMON}/$(PROD_DAEMON)/g" \ | ||
-e "s/{LUA_CODE_CACHE}/$(PROD_LUA_CODE_CACHE)/g" \ | ||
-e "s@{LUA_PATH}@$(PROD_LUA_PATH)@g" \ | ||
-e "s@{CONF_PATH}@$(PROD_CONF_PATH)@g" nginx.conf > $(OPENRESTY_PREFIX)/nginx/conf/nginx.conf; | ||
@if [ -a $(OPENRESTY_PREFIX)/nginx/conf/nginx.conf ]; then \ | ||
cp $(OPENRESTY_PREFIX)/nginx/conf/nginx.conf $(OPENRESTY_PREFIX)/nginx/conf/nginx.conf.old; \ | ||
fi; | ||
|
||
# - conf.yaml | ||
$(INSTALL) -d $(PROD_CONF_DIR) | ||
$(INSTALL) etc/conf.yaml $(PROD_CONF_DIR) | ||
|
||
uninstall: all | ||
|
||
@rm -rf $(LUA_LIB_DIR)/resty/apenode | ||
@rm -rf $(PROD_CONF_DIR) | ||
@mv $(OPENRESTY_PREFIX)/nginx/conf/nginx.conf.old $(OPENRESTY_PREFIX)/nginx/conf/nginx.conf | ||
|
||
run-dev: all | ||
@rm -rf nginx_tmp | ||
@mkdir -p nginx_tmp/logs | ||
@echo "" > nginx_tmp/logs/error.log | ||
@echo "" > nginx_tmp/logs/access.log | ||
|
||
PWD = `pwd` | ||
# Dev environment variables | ||
DEV_DAEMON ?= off | ||
DEV_LUA_LIB ?= lua_package_path \"$(PWD)/src/?.lua\;\;\"\; | ||
DEV_LUA_CODE_CACHE ?= off | ||
DEV_APENODE_CONF ?= $(PWD)/tmp/apenode.dev.yaml | ||
DEV_APENODE_PORT ?= 8000 | ||
DEV_APENODE_WEB_PORT ?= 8001 | ||
|
||
.PHONY: test local global | ||
|
||
test: | ||
@echo "Tests with busted" | ||
|
||
local: | ||
@luarocks make apenode-0.0-1.rockspec --local | ||
|
||
global: | ||
@sudo luarocks make apenode-0.0-1.rockspec | ||
|
||
run: | ||
@mkdir -p tmp/nginx/logs | ||
@cp templates/apenode.yaml $(DEV_APENODE_CONF) | ||
@echo "" > tmp/nginx/logs/error.log | ||
@echo "" > tmp/nginx/logs/access.log | ||
@sed \ | ||
-e "s/{DAEMON}/$(DEV_DAEMON)/g" \ | ||
-e "s/{LUA_CODE_CACHE}/$(DEV_LUA_CODE_CACHE)/g" \ | ||
-e "s@{LUA_PATH}@$(DEV_LUA_PATH)@g" \ | ||
-e "s@{CONF_PATH}@$(DEV_CONF_PATH)@g" nginx.conf > nginx_tmp/nginx_dev.conf; | ||
|
||
@nginx -p ./nginx_tmp -c nginx_dev.conf | ||
|
||
test: all | ||
PATH=$(OPENRESTY_PREFIX)/nginx/sbin:$$PATH prove -I../test-nginx/lib -r t | ||
-e "s/{{DAEMON}}/$(DEV_DAEMON)/g" \ | ||
-e "s@{{LUA_LIB_PATH}}@$(DEV_LUA_LIB)@g" \ | ||
-e "s/{{LUA_CODE_CACHE}}/$(DEV_LUA_CODE_CACHE)/g" \ | ||
-e "s/{{PORT}}/$(DEV_APENODE_PORT)/g" \ | ||
-e "s/{{WEB_PORT}}/$(DEV_APENODE_WEB_PORT)/g" \ | ||
-e "s@{{APENODE_CONF}}@$(DEV_APENODE_CONF)@g" \ | ||
templates/nginx.conf > tmp/nginx/nginx.conf; | ||
|
||
@nginx -p ./tmp/nginx -c nginx.conf |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,18 @@ | ||
# Apenode | ||
## Apenode | ||
|
||
lua-resty-apenode - Lua Apenode core dependencies | ||
|
||
[![The beginning of a new era](http://img.youtube.com/vi/U2iiPpcwfCA/0.jpg)](http://www.youtube.com/watch?v=U2iiPpcwfCA) | ||
|
||
# Installation | ||
### Requirements | ||
- Lua `5.1` | ||
- Luarocks for Lua `5.1` | ||
- Openrestify ([Download](http://openresty.com/#Download) the latest version of OpenResty and install it.) | ||
|
||
* [Download](http://openresty.com/#Download) the latest version of OpenResty and install it. | ||
* Execute `make install` to install the Apenode | ||
### Installation | ||
- `make global` or `make local` | ||
|
||
# Running | ||
|
||
You can run the Apenode in two different modes: | ||
|
||
* In background, with: `sudo nginx` | ||
* Or in foreground, with: `sudo nginx -g "daemon off;"` | ||
### Running for development | ||
- `make run` | ||
|
||
By default it will be running on port `8000`, so navigate to [http://localhost:8000/](http://localhost:8000/) after starting it. |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package = "apenode" | ||
version = "0.0-1" | ||
source = { | ||
url = "git://github.com/Mashape/lua-resty-apenode", | ||
branch = "master" | ||
} | ||
description = { | ||
summary = "Apenode, the fastest and most installed API layer in the universe", | ||
detailed = [[ | ||
The Apenode is the most popular API layer in the world | ||
that provides API management and analytics for any kind | ||
of API. | ||
]], | ||
homepage = "http://apenode.com", | ||
license = "MIT" | ||
} | ||
dependencies = { | ||
"lua ~> 5.1", | ||
|
||
"luasec ~> 0.5-2", | ||
"uuid ~> 0.2-1", | ||
"yaml ~> 1.1.1-1", | ||
"lapis ~> 1.0.6-1", | ||
"inspect ~> 3.0-1", | ||
"luaxml ~> 101012-1", | ||
"busted ~> 2.0.rc3-0" | ||
} | ||
build = { | ||
type = "builtin", | ||
modules = { | ||
["apenode"] = "src/main.lua", | ||
["apenode.core.access"] = "src/core/access.lua", | ||
["apenode.core.handler"] = "src/core/handler.lua", | ||
["apenode.core.handler_filter"] = "src/core/header_filter.lua", | ||
["apenode.core.log"] = "src/core/log.lua", | ||
["apenode.core.utils"] = "src/core/utils.lua", | ||
|
||
["apenode.web.app"] = "src/web/app.lua", | ||
|
||
["apenode.dao.memory"] = "src/dao/memory/factory.lua", | ||
["apenode.dao.memory.api"] = "src/dao/memory/api.lua", | ||
["apenode.dao.memory.application"] = "src/dao/memory/application.lua", | ||
|
||
["apenode.plugins.transformations.handler"] = "src/plugins/transformations/handler.lua", | ||
["apenode.plugins.transformations.header_filter"] = "src/plugins/transformations/header_filter.lua", | ||
["apenode.plugins.transformations.body_filter"] = "src/plugins/transformations/body_filter.lua" | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
6 changes: 3 additions & 3 deletions
6
lib/resty/apenode/plugins/core/handler.lua → src/apenode/core/handler.lua
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
File renamed without changes.
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
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
File renamed without changes.
File renamed without changes.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
-- Copyright (C) Mashape, Inc. | ||
|
||
|
||
local application_dao = require "apenode.dao.memory.application" | ||
local api_dao = require "apenode.dao.memory.api" | ||
|
||
|
||
local _M = { | ||
|
||
_VERSION = '0.1', | ||
api = api_dao, | ||
application = application_dao | ||
|
||
} | ||
|
||
|
||
return _M |
File renamed without changes.
4 changes: 2 additions & 2 deletions
4
...enode/plugins/transformations/handler.lua → ...enode/plugins/transformations/handler.lua
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
File renamed without changes.
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
File renamed without changes.
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
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.