震撼 AdHoc 世界! ?
git clone https://github.com/FoundersFactory/AdRock.git
npm install forever -g
.env
檔: cd Server && touch .env
.env
檔案: AUTH0_CLIENT_ID=
AUTH0_CLIENT_SECRET=
AUTH0_DOMAIN=<your-company-name>.eu.auth0.com
AUTH0_CALLBACK_URL=http://localhost:3000/adrock
PORT=3000
HOST=localhost
EXTERNAL_URL=https://example.com
/Server
): forever stopall && git pull && npm install --save &&
NODE_ENV=production forever --minUptime 1000 --spinSleepTime 1000 start ./forever.json
這將:
3000
上啟動預設的express
應用程式GET <domain>/adrock/<full-app-bundle-id>
端點POST <domain>/adrock/upload
端點來接收應用程式如果您已經有一個 Express 應用程式並希望將AdRock整合到其中:
//Requires
const dotenv = require("dotenv");
const jwt = require("express-jwt");
const cors = require("cors");
//Other stuff you might want to do
{...}
//Loading the environment variables and Auth0
dotenv.load();
const authenticate = jwt({
secret: new Buffer(process.env.AUTH0_CLIENT_SECRET, 'base64'),
audience: process.env.AUTH0_CLIENT_ID
});
//Other stuff you might want to do, especially creating your express app
{...}
//ADROCK!!!
//Getting apps
app.use("/adrock", require("./routes/get"));
//Auth
app.use("/adrock/upload", authenticate);
//Uploading apps
app.use("/adrock/upload", require("./routes/post"));
app.use(function (err, req, res, next) {
if (err.name === 'UnauthorizedError') {
res.status(401).send('Invalid token...');
return;
}
next(err);
});
如果使用 Nginx,請將其新增至您的主.conf
檔案:
location /adrock {
include /<path-to-adrock>/Server/nginx.conf;
}
若要上傳新應用程式或現有應用程式的新版本,您需要向<domain>/adrock/upload
發出多部分錶單POST
請求,其中包含:
app
=> 大小不超過 512mb 的.ipa
或.apk
文件icon
=> 應用程式圖示的.png
檔案(僅在首次上傳和 iOS 應用程式時需要)bundleId
=> 應用程式的完整捆綁包 ID(例如com.example.raddest-app-ever )version
=> 應用程式的版本(例如0.3.1 )name
=> 應用程式的名稱(例如Raddest App Ever )成功後,您將獲得應用程式的index.html
的 URL,這與呼叫<domain>/adrock/<full-app-bundle-id>
相同。
curl -X POST <domain>/adrock/upload
-H Authorization=Bearer <your-jwt>
-F app=<path/to/ipa>
-F icon=<path/to/icon>
-F bundleId=<full-app-bundle-id>
-F name='The App's Name'
-F version=0.3.1