Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
siibra-explorer
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Xiao Gui
siibra-explorer
Commits
81fe8c60
Commit
81fe8c60
authored
3 years ago
by
Xiao Gui
Browse files
Options
Downloads
Patches
Plain Diff
bugfix: disable saneurl
parent
77821044
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
deploy/app.js
+4
-7
4 additions, 7 deletions
deploy/app.js
deploy/saneUrl/index.js
+26
-9
26 additions, 9 deletions
deploy/saneUrl/index.js
deploy/saneUrl/store.js
+14
-26
14 additions, 26 deletions
deploy/saneUrl/store.js
with
44 additions
and
42 deletions
deploy/app.js
+
4
−
7
View file @
81fe8c60
...
...
@@ -8,8 +8,7 @@ const cookieParser = require('cookie-parser')
const
bkwdMdl
=
require
(
'
./bkwdCompat
'
)()
const
{
router
:
regionalFeaturesRouter
,
regionalFeatureIsReady
}
=
require
(
'
./regionalFeatures
'
)
const
{
router
:
datasetRouter
,
ready
:
datasetRouteIsReady
}
=
require
(
'
./datasets
'
)
const
{
ready
:
saneUrlIsReady
}
=
require
(
'
./saneUrl
'
)
const
{
router
:
datasetRouter
}
=
require
(
'
./datasets
'
)
const
LOCAL_CDN_FLAG
=
!!
process
.
env
.
PRECOMPUTED_SERVER
...
...
@@ -109,7 +108,8 @@ const _ = (async () => {
/**
* saneUrl end points
*/
app
.
use
(
'
/saneUrl
'
,
require
(
'
./saneUrl
'
))
const
{
router
:
saneUrlRouter
}
=
require
(
'
./saneUrl
'
)
app
.
use
(
'
/saneUrl
'
,
saneUrlRouter
)
})()
const
PUBLIC_PATH
=
process
.
env
.
NODE_ENV
===
'
production
'
...
...
@@ -204,13 +204,10 @@ app.use('/logo', require('./logo'))
app
.
get
(
'
/ready
'
,
async
(
req
,
res
)
=>
{
const
authIsReady
=
authReady
?
await
authReady
()
:
false
const
regionalFeatureReady
=
await
regionalFeatureIsReady
()
const
datasetReady
=
await
datasetRouteIsReady
()
const
saneUrlReady
=
await
saneUrlIsReady
()
const
allReady
=
[
authIsReady
,
regionalFeatureReady
,
datasetReady
,
saneUrlReady
,
/**
* add other ready endpoints here
* call sig is await fn(): boolean
...
...
This diff is collapsed.
Click to expand it.
deploy/saneUrl/index.js
+
26
−
9
View file @
81fe8c60
...
...
@@ -2,9 +2,8 @@ const express = require('express')
const
router
=
express
.
Router
()
const
RateLimit
=
require
(
'
express-rate-limit
'
)
const
RedisStore
=
require
(
'
rate-limit-redis
'
)
const
{
Store
,
NotFoundError
}
=
require
(
'
./store
'
)
const
{
redisURL
}
=
require
(
'
../lruStore
'
)
const
{
readUserData
,
saveUserData
}
=
require
(
'
../user/store
'
)
const
{
FallbackStore
:
Store
,
NotFoundError
}
=
require
(
'
./store
'
)
const
lruStore
=
require
(
'
../lruStore
'
)
const
{
Store
:
DepcStore
}
=
require
(
'
./depcObjStore
'
)
const
{
readUserData
,
saveUserData
}
=
require
(
'
../user/store
'
)
...
...
@@ -12,11 +11,29 @@ const store = new Store()
const
depStore
=
new
DepcStore
()
const
{
DISABLE_LIMITER
,
HOSTNAME
,
HOST_PATHNAME
}
=
process
.
env
const
limiter
=
new
RateLimit
({
windowMs
:
1
e3
*
5
,
max
:
5
,
...(
redisURL
?
{
store
:
new
RedisStore
({
redisURL
})
}
:
{}
)
})
let
limiter
const
getLimiter
=
async
()
=>
{
if
(
DISABLE_LIMITER
)
return
passthrough
if
(
!!
limiter
)
return
limiter
await
lruStore
.
_initPr
if
(
lruStore
.
redisURL
)
{
limiter
=
new
RateLimit
({
windowMs
:
1
e3
*
5
,
max
:
5
,
store
:
new
RedisStore
({
redisURL
})
})
}
else
{
limiter
=
new
RateLimit
({
windowMs
:
1
e3
*
5
,
max
:
5
,
})
}
return
limiter
}
const
passthrough
=
(
_
,
__
,
next
)
=>
next
()
...
...
@@ -88,7 +105,7 @@ router.get('/:name', async (req, res) => {
})
router
.
post
(
'
/:name
'
,
DISABLE_LIMITER
?
passthrough
:
l
imiter
,
getL
imiter
,
async
(
req
,
res
,
next
)
=>
{
const
{
name
}
=
req
.
params
try
{
...
...
This diff is collapsed.
Click to expand it.
deploy/saneUrl/store.js
+
14
−
26
View file @
81fe8c60
...
...
@@ -17,36 +17,11 @@ const {
HBP_V2_REFRESH_TOKEN
,
HBP_V2_ACCESS_TOKEN
,
REDIS_PROTO
,
REDIS_ADDR
,
REDIS_PORT
,
REDIS_RATE_LIMITING_DB_EPHEMERAL_PORT_6379_TCP_PROTO
,
REDIS_RATE_LIMITING_DB_EPHEMERAL_PORT_6379_TCP_ADDR
,
REDIS_RATE_LIMITING_DB_EPHEMERAL_PORT_6379_TCP_PORT
,
REDIS_USERNAME
,
REDIS_PASSWORD
,
DATA_PROXY_URL
,
DATA_PROXY_BUCKETNAME
,
}
=
process
.
env
const
redisProto
=
REDIS_PROTO
||
REDIS_RATE_LIMITING_DB_EPHEMERAL_PORT_6379_TCP_PROTO
||
'
redis
'
const
redisAddr
=
REDIS_ADDR
||
REDIS_RATE_LIMITING_DB_EPHEMERAL_PORT_6379_TCP_ADDR
||
null
const
redisPort
=
REDIS_PORT
||
REDIS_RATE_LIMITING_DB_EPHEMERAL_PORT_6379_TCP_PORT
||
6379
const
userPass
=
(()
=>
{
let
returnString
=
''
if
(
REDIS_USERNAME
)
returnString
+=
REDIS_USERNAME
if
(
REDIS_PASSWORD
)
returnString
+=
`:
${
REDIS_PASSWORD
}
`
if
(
returnString
.
length
>
0
)
returnString
+=
`@`
return
returnString
})()
const
redisURL
=
redisAddr
&&
`
${
redisProto
}
://
${
userPass
}${
redisAddr
}
:
${
redisPort
}
`
class
NotFoundError
extends
Error
{}
// not part of class, since class is exported, and prototype of class can be easily changed
...
...
@@ -78,8 +53,21 @@ function _checkValid(urlString){
return
(
new
Date
()
-
new
Date
(
expiry
))
<
1
e3
*
10
}
class
FallbackStore
{
async
get
(){
throw
new
Error
(
`saneurl is currently offline for maintainence.`
)
}
async
set
(){
throw
new
Error
(
`saneurl is currently offline for maintainence.`
)
}
async
healthCheck
()
{
return
false
}
}
class
Store
{
constructor
(){
throw
new
Error
(
`Not implemented`
)
this
.
healthFlag
=
false
this
.
seafileHandle
=
null
...
...
@@ -427,6 +415,6 @@ class Store {
}
}
exports
.
FallbackStore
=
FallbackStore
exports
.
Store
=
Store
exports
.
NotFoundError
=
NotFoundError
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment