Commit 2c7f3f8f authored by 刘松's avatar 刘松

v2

parent b0cb1a7a
...@@ -15,7 +15,13 @@ RUN npm i --only=production --registry https://registry.npm.taobao.org ...@@ -15,7 +15,13 @@ RUN npm i --only=production --registry https://registry.npm.taobao.org
ENV SERVICE_PORT=6662 ENV SERVICE_PORT=6662
ENV PROJECT_LEVEL=production ENV PROJECT_LEVEL=production
ENV MONGO='mongodb://mongo-adpro-ssp-v2-rs-1.localhost:1301/remarketing?replicaSet=adpro_ssp_v2_rs' ENV MONGO='mongodb://mongo-adpro-ssp-v2-rs-2.localhost:1301/remarketing?replicaSet=adpro_ssp_v2_rs'
ENV MONGO_OEM='mongodb://bjwjh:OhzFH7t7Qn0T@mongo-bjwjh-rs-1.localhost:1302,mongo-bjwjh-rs-2.localhost:1302,mongo-bjwjh-rs-3.localhost:1302/'
ENV MONGO_DB_MTTY='oem_mtty_remarketing'
ENV MONGO_DB_XIBAO='oem_xibao_remarketing'
ENV NODE_ENV='production' ENV NODE_ENV='production'
EXPOSE 6662 EXPOSE 6662
CMD node server.js CMD node server.js
const mongodb = require("mongodb");
const MongoClient = mongodb.MongoClient;
let db = {};
let oem_db = { mtty:{}, xibao:{} };
const dbpath = process.env.MONGO || "mongodb://127.0.0.1:27017/remarketing";
const oem_dbpath = ( process.env.MONGO_OEM + process.env.MONGO_DB_MTTY || "mongodb://127.0.0.1:27017/remarketing" ) + (process.env.MONGO_OEM ? "?replicaSet=bjwjh-rs&authSource=admin" : '');
//const xibao_dbpath = process.env.MONGO_OEM +process.env.MONGO_DB_XIBAO + "?replicaSet=bjwjh-rs&authSource=admin";
const salt = ",tom";
const EXPIRATION = 60 * 30;
// TODO ! put into init
/*console.dir(dbpath);
console.dir(oem_dbpath);*/
/*MongoClient.connect(dbpath, (err, conn) => {
if (err) return console.log(err);
console.log("#### DB CONNECTED");
db = conn.db("remarketing");
db
.collection("tokenSession")
.createIndex({ createdAt: 1 }, { expireAfterSeconds: 3600 * 24 });
});*/
/*MongoClient.connect(oem_dbpath, (err, conn) => {
if (err) return console.log(err);
console.log("#### OEM DB CONNECTED");
oem_db.mtty = conn.db(process.env.MONGO_DB_MTTY);
oem_db.xibao = conn.db(process.env.MONGO_DB_XIBAO);
oem_db.mtty
.collection("tokenSession")
.createIndex({ createdAt: 1 }, { expireAfterSeconds: 3600 * 24 });
oem_db.xibao
.collection("tokenSession")
.createIndex({ createdAt: 1 }, { expireAfterSeconds: 3600 * 24 });
});*/
module.exports = {
getDb: async () => {
const conn = await MongoClient.connect(dbpath);
db = conn.db("remarketing");
console.log("#### DB CONNECTED");
db
.collection("tokenSession")
.createIndex({ createdAt: 1 }, { expireAfterSeconds: 3600 * 24 });
return db;
},
getOemDb: async () => {
const conn = await MongoClient.connect(oem_dbpath);
oem_db.mtty = conn.db(process.env.MONGO_DB_MTTY);
oem_db.xibao = conn.db(process.env.MONGO_DB_XIBAO);
return oem_db;
}
};
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -5,6 +5,7 @@ var fs = require('fs'); ...@@ -5,6 +5,7 @@ var fs = require('fs');
var http = require('http'); var http = require('http');
var app = express(); var app = express();
const api = require('./api'); const api = require('./api');
const apiV2 = require('./api/v2');
var server = http.Server(app); var server = http.Server(app);
...@@ -16,6 +17,7 @@ app.use(cookieParser()); ...@@ -16,6 +17,7 @@ app.use(cookieParser());
app.use(express.static(__dirname + '/dist')); app.use(express.static(__dirname + '/dist'));
app.use('/api', api); app.use('/api', api);
app.use('/v2/api', apiV2);
server.listen(6662, function() { server.listen(6662, function() {
console.log('server started'); console.log('server started');
......
...@@ -23,7 +23,7 @@ const getters = { ...@@ -23,7 +23,7 @@ const getters = {
const actions = { const actions = {
[types.SEND_JOB]({ commit }, { templateId, unikeyArray, sendTime, accountID, callback }) { [types.SEND_JOB]({ commit }, { templateId, unikeyArray, sendTime, accountID, callback }) {
fetch('/api/job/msg', { //短信任务 fetch('/v2/api/job/msg', { //短信任务
method: 'POST', method: 'POST',
headers: { headers: {
'Content-Type': 'application/json;charset=UTF-8', 'Content-Type': 'application/json;charset=UTF-8',
...@@ -43,7 +43,7 @@ const actions = { ...@@ -43,7 +43,7 @@ const actions = {
}, },
[types.GET_JOBS]({ commit }, { accountID, skip = 0, limit = 50, callback, page }) { [types.GET_JOBS]({ commit }, { accountID, skip = 0, limit = 50, callback, page }) {
commit(types.JOB_LOADING, true); commit(types.JOB_LOADING, true);
fetch(`/api/jobs?accountID=${accountID}&skip=${skip}&limit=${limit}`).then((res) => { //短信任务获取 fetch(`/v2/api/jobs?accountID=${accountID}&skip=${skip}&limit=${limit}`).then((res) => { //短信任务获取
if (res.ok) { if (res.ok) {
return res.json(); return res.json();
} }
......
...@@ -66,7 +66,7 @@ const getters = { ...@@ -66,7 +66,7 @@ const getters = {
const actions = { const actions = {
[types.GET_RECOGNITIONS]({ commit }, { sessionID, skip = 0, limit = 50, date, refresh = false, called =false, callback }) { [types.GET_RECOGNITIONS]({ commit }, { sessionID, skip = 0, limit = 50, date, refresh = false, called =false, callback }) {
commit(types.NUMBERS_LOADING, true); commit(types.NUMBERS_LOADING, true);
fetch(`/api/recognitions?sessionID=${sessionID}&skip=${skip}&limit=${limit}&date=${date}&called=${called}`, { fetch(`/v2/api/recognitions?sessionID=${sessionID}&skip=${skip}&limit=${limit}&date=${date}&called=${called}`, {
}).then((res) => { }).then((res) => {
if (res.ok) { if (res.ok) {
return res.json(); return res.json();
...@@ -82,7 +82,7 @@ const actions = { ...@@ -82,7 +82,7 @@ const actions = {
}); });
}, },
[types.CALL_BEGIN]({ commit }, { slotID, pubID, unikey, phone, expiration= 30*60, callback }) { [types.CALL_BEGIN]({ commit }, { slotID, pubID, unikey, phone, expiration= 30*60, callback }) {
fetch('/api/job/call', { fetch('/v2/api/job/call', {
method: 'POST', method: 'POST',
headers: { headers: {
'Content-Type': 'application/json;charset=UTF-8', 'Content-Type': 'application/json;charset=UTF-8',
......
...@@ -33,7 +33,7 @@ const getters = { ...@@ -33,7 +33,7 @@ const getters = {
const actions = { const actions = {
login({ commit }, { phone, token, sessionID, callback }) { login({ commit }, { phone, token, sessionID, callback }) {
fetch('/api/login', { fetch('/v2/api/login', {
method: 'POST', method: 'POST',
headers: { headers: {
'Content-Type': 'application/json;charset=UTF-8', 'Content-Type': 'application/json;charset=UTF-8',
...@@ -54,7 +54,7 @@ const actions = { ...@@ -54,7 +54,7 @@ const actions = {
}, },
// check session when fresh // check session when fresh
session({ commit }, callback) { session({ commit }, callback) {
fetch('/api/session', { fetch('/v2/api/session', {
method: 'POST', method: 'POST',
headers: { headers: {
'Content-Type': 'application/json;charset=UTF-8', 'Content-Type': 'application/json;charset=UTF-8',
...@@ -74,7 +74,7 @@ const actions = { ...@@ -74,7 +74,7 @@ const actions = {
}); });
}, },
delSession({ commit }, callback) { delSession({ commit }, callback) {
fetch('/api/logout', { fetch('/v2/api/logout', {
method: 'POST', method: 'POST',
headers: { headers: {
'Content-Type': 'application/json;charset=UTF-8', 'Content-Type': 'application/json;charset=UTF-8',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment