Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
R
Rosekey
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
freelynetwork
Rosekey
Commits
4786214e
Commit
4786214e
authored
3 years ago
by
syuilo
Browse files
Options
Downloads
Patches
Plain Diff
fix bug
parent
0484976a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
packages/backend/src/db/postgre.ts
+23
-7
23 additions, 7 deletions
packages/backend/src/db/postgre.ts
packages/backend/src/server/web/index.ts
+8
-0
8 additions, 0 deletions
packages/backend/src/server/web/index.ts
with
31 additions
and
7 deletions
packages/backend/src/db/postgre.ts
+
23
−
7
View file @
4786214e
...
...
@@ -215,11 +215,27 @@ export function initDb(justBorrow = false, sync = false, forceRecreate = false)
}
export
async
function
resetDb
()
{
const
conn
=
await
getConnection
();
const
tables
=
await
conn
.
query
(
`SELECT relname AS "table"
FROM pg_class C LEFT JOIN pg_namespace N ON (N.oid = C.relnamespace)
WHERE nspname NOT IN ('pg_catalog', 'information_schema')
AND C.relkind = 'r'
AND nspname !~ '^pg_toast';`
);
await
Promise
.
all
(
tables
.
map
(
t
=>
t
.
table
).
map
(
x
=>
conn
.
query
(
`DELETE FROM "
${
x
}
" CASCADE`
)));
const
reset
=
async
()
=>
{
const
conn
=
await
getConnection
();
const
tables
=
await
conn
.
query
(
`SELECT relname AS "table"
FROM pg_class C LEFT JOIN pg_namespace N ON (N.oid = C.relnamespace)
WHERE nspname NOT IN ('pg_catalog', 'information_schema')
AND C.relkind = 'r'
AND nspname !~ '^pg_toast';`
);
await
Promise
.
all
(
tables
.
map
(
t
=>
t
.
table
).
map
(
x
=>
conn
.
query
(
`DELETE FROM "
${
x
}
" CASCADE`
)));
};
for
(
let
i
=
1
;
i
<=
3
;
i
++
)
{
try
{
await
reset
();
}
catch
(
e
)
{
if
(
i
===
3
)
{
throw
e
;
}
else
{
await
new
Promise
(
resolve
=>
setTimeout
(
resolve
,
1000
));
continue
;
}
}
break
;
}
}
This diff is collapsed.
Click to expand it.
packages/backend/src/server/web/index.ts
+
8
−
0
View file @
4786214e
...
...
@@ -23,6 +23,7 @@ const _filename = __filename;
const
_dirname
=
dirname
(
_filename
);
const
staticAssets
=
`
${
_dirname
}
/../../../assets/`
;
const
clientAssets
=
`
${
_dirname
}
/../../../../client/assets/`
;
const
assets
=
`
${
_dirname
}
/../../../../../built/_client_dist_/`
;
// Init app
...
...
@@ -59,6 +60,13 @@ router.get('/static-assets/(.*)', async ctx => {
});
});
router
.
get
(
'
/client-assets/(.*)
'
,
async
ctx
=>
{
await
send
(
ctx
as
any
,
ctx
.
path
.
replace
(
'
/client-assets/
'
,
''
),
{
root
:
clientAssets
,
maxage
:
ms
(
'
7 days
'
),
});
});
router
.
get
(
'
/assets/(.*)
'
,
async
ctx
=>
{
await
send
(
ctx
as
any
,
ctx
.
path
.
replace
(
'
/assets/
'
,
''
),
{
root
:
assets
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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