remove console.log, add cross-platform del, optimize prod config for DB

pull/152/merge
Bosn 7 years ago
parent 48eacfebfc
commit c36171cef4

@ -7,9 +7,9 @@
"description": "",
"main": "dist/dispatch.js",
"scripts": {
"build": "rm -rf dist/ && tsc",
"build": "rimraf -rf dist/ && tsc",
"test": "cross-env NODE_ENV=development cross-env TEST_MODE=true nyc mocha --exit --reporter nyan",
"check": "echo \"Checking...\" && npm run tslint",
"check": "echo \"Checking...\" && tsc && npm run tslint",
"dev": "cross-env NODE_ENV=development nodemon --watch scripts --watch dist dist/scripts/dev.js",
"create-db": "cross-env NODE_ENV=development node dist/scripts/init",
"tslint": "tslint -c tslint.json -p tsconfig.json",
@ -74,6 +74,7 @@
"nyc": "^11.4.1",
"pm2": "^2.10.2",
"pre-commit": "^1.2.2",
"rimraf": "^2.6.2",
"source-map-support": "^0.5.0",
"standard": "^10.0.2",
"supertest": "^3.0.0",

@ -15,13 +15,14 @@ let config: IConfigOptions = {
port: 3306,
username: 'root',
password: '',
database: 'RAP2_DELOS_APP',
database: 'rap',
pool: {
max: 5,
max: 80,
min: 0,
idle: 10000,
idle: 20000,
acquire: 20000,
},
logging: true,
logging: false,
},
}

@ -68,8 +68,6 @@ router.get('/account/info', async (ctx) => {
router.post('/account/login', async (ctx) => {
let { email, password, captcha } = ctx.request.body
let result, errMsg
console.log(`captcha=${captcha} ctx.session.captcha=${ctx.session.captcha}`)
if (process.env.TEST_MODE !== 'true' &&
(!captcha || !ctx.session.captcha || captcha.trim().toLowerCase() !== ctx.session.captcha.toLowerCase())) {
errMsg = '错误的验证码'
@ -235,6 +233,15 @@ router.post('/account/notification/read', async (ctx) => {
// TODO 2.3 账户日志
router.get('/account/logger', async (ctx) => {
if (!ctx.session.id) {
ctx.body = {
data: {
isOk: false,
errMsg: 'not login'
}
}
return
}
let auth = await User.findById(ctx.session.id)
let repositories: Model<Repository>[] = [...(<Model<Repository>[]>await auth.$get('ownedRepositories')), ...(<Model<Repository>[]>await auth.$get('joinedRepositories'))]
let organizations: Model<Organization>[] = [...(<Model<Organization>[]>await auth.$get('ownedOrganizations')), ...(<Model<Organization>[]>await auth.$get('joinedOrganizations'))]

@ -182,13 +182,10 @@ router.all('/app/mock/(\\d+)/(.+)', async (ctx) => {
const data = Tree.ArrayToTreeToTemplateToData(properties, requestData)
ctx.type = 'json'
ctx.body = JSON.stringify(data, undefined, 2)
console.log(itf.url)
if (itf && itf.url.indexOf('[callback]=') > -1) {
const query = querystring.parse(itf.url.substring(itf.url.indexOf('?') + 1))
console.log(query)
const cbName = query['[callback]']
const cbVal = ctx.request.query[`${cbName}`]
console.log(cbName + '|' + cbVal)
if (cbVal) {
let body = typeof ctx.body === 'object' ? JSON.stringify(ctx.body, undefined, 2) : ctx.body
ctx.type = 'application/x-javascript'

@ -54,6 +54,15 @@ router.get('/organization/list', async (ctx) => {
}
})
router.get('/organization/owned', async (ctx) => {
if (!ctx.session.id) {
ctx.body = {
data: {
isOk: false,
errMsg: 'not login'
}
}
return
}
let where = {}
let { name } = ctx.query
if (name) {
@ -79,6 +88,15 @@ router.get('/organization/owned', async (ctx) => {
}
})
router.get('/organization/joined', async (ctx) => {
if (!ctx.session.id) {
ctx.body = {
data: {
isOk: false,
errMsg: 'not login'
}
}
return
}
let where = {}
let { name } = ctx.query
if (name) {

@ -25,7 +25,6 @@ router.get('/test/test.status', (ctx) => {
// proxy
router.get('/proxy', async(ctx) => {
let { target } = ctx.query
console.log(` <=> ${target}`)
let json = await fetch(target).then(res => res.json())
ctx.type = 'json'
ctx.body = json

@ -5,7 +5,6 @@ export enum ACCESS_TYPE { ORGANIZATION, REPOSITORY, USER }
export class AccessUtils {
public static async canUserAccess(accessType: ACCESS_TYPE, curUserId: number, entityId: number): Promise<boolean> {
console.log(`accessType=${accessType}&curUserId=${curUserId}&&entityId=${entityId}`)
if (accessType === ACCESS_TYPE.ORGANIZATION) {
return await OrganizationService.canUserAccessOrganization(curUserId, entityId)
} else if (accessType === ACCESS_TYPE.REPOSITORY) {

@ -14,7 +14,7 @@ appAny.counter = { users: {}, mock: 0 }
app.keys = config.keys
app.use(session(config.session, app))
if (process.env.NODE_ENV === 'development') app.use(logger())
app.use(logger())
app.use(async(ctx, next) => {
await next()
if (ctx.path === '/favicon.ico') return

@ -16,7 +16,6 @@ export default class Migrate {
return
}
for (const user of users) {
console.log(`load user ${user.id}`)
if (!isMd5(user.password)) {
user.password = md5(md5(user.password))
await user.save()

@ -17,7 +17,6 @@ export default class OrganizationService {
) as result
WHERE id = ${organizationId}
`
console.log(sql)
return new Promise(resolve => {
seq.query(sql).spread((result: any) => {
resolve(+result[0].num > 0)
@ -46,7 +45,6 @@ export default class OrganizationService {
`
return new Promise(resolve => {
seq.query(sql).spread((result: { id: number }[]) => {
console.log(result)
resolve(result.map(item => item.id))
})
})

Loading…
Cancel
Save