Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Sharkey
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
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
Essem
Sharkey
Commits
61f21594
Commit
61f21594
authored
7 years ago
by
syuilo
Browse files
Options
Downloads
Patches
Plain Diff
wip
parent
c54ff5b2
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
src/server/api/index.ts
+2
-0
2 additions, 0 deletions
src/server/api/index.ts
src/server/file/pour.ts
+3
-2
3 additions, 2 deletions
src/server/file/pour.ts
src/server/index.ts
+7
-9
7 additions, 9 deletions
src/server/index.ts
src/server/web/index.ts
+8
-9
8 additions, 9 deletions
src/server/web/index.ts
with
20 additions
and
20 deletions
src/server/api/index.ts
+
2
−
0
View file @
61f21594
...
...
@@ -5,6 +5,7 @@
import
*
as
Koa
from
'
koa
'
;
import
*
as
Router
from
'
koa-router
'
;
import
*
as
multer
from
'
koa-multer
'
;
import
*
as
bodyParser
from
'
koa-bodyparser
'
;
import
endpoints
from
'
./endpoints
'
;
...
...
@@ -12,6 +13,7 @@ const handler = require('./api-handler').default;
// Init app
const
app
=
new
Koa
();
app
.
use
(
bodyParser
);
// Init multer instance
const
upload
=
multer
({
...
...
This diff is collapsed.
Click to expand it.
src/server/file/pour.ts
+
3
−
2
View file @
61f21594
...
...
@@ -80,10 +80,11 @@ export default function(readable: stream.Readable, type: string, ctx: Koa.Contex
}
if
(
ctx
.
query
.
download
!==
undefined
)
{
ctx
.
header
(
'
Content-Disposition
'
,
'
attachment
'
);
ctx
.
set
(
'
Content-Disposition
'
,
'
attachment
'
);
}
ctx
.
header
(
'
Content-Type
'
,
data
.
contentType
);
ctx
.
set
(
'
Cache-Control
'
,
'
max-age=31536000, immutable
'
);
ctx
.
set
(
'
Content-Type
'
,
data
.
contentType
);
data
.
stream
.
pipe
(
ctx
.
res
);
...
...
This diff is collapsed.
Click to expand it.
src/server/index.ts
+
7
−
9
View file @
61f21594
...
...
@@ -4,10 +4,9 @@
import
*
as
fs
from
'
fs
'
;
import
*
as
http
from
'
http
'
;
import
*
as
http
s
from
'
http
s
'
;
import
*
as
http
2
from
'
http
2
'
;
import
*
as
Koa
from
'
koa
'
;
import
*
as
Router
from
'
koa-router
'
;
import
*
as
bodyParser
from
'
koa-bodyparser
'
;
import
*
as
mount
from
'
koa-mount
'
;
import
activityPub
from
'
./activitypub
'
;
...
...
@@ -17,14 +16,13 @@ import config from '../config';
// Init app
const
app
=
new
Koa
();
app
.
proxy
=
true
;
app
.
use
(
bodyParser
);
// HSTS
// 6months (15552000sec)
if
(
config
.
url
.
startsWith
(
'
https
'
))
{
app
.
use
((
ctx
,
next
)
=>
{
app
.
use
(
async
(
ctx
,
next
)
=>
{
ctx
.
set
(
'
strict-transport-security
'
,
'
max-age=15552000; preload
'
);
next
();
await
next
();
});
}
...
...
@@ -38,20 +36,20 @@ const router = new Router();
router
.
use
(
activityPub
.
routes
());
router
.
use
(
webFinger
.
routes
());
app
.
use
(
mount
(
require
(
'
./web
'
)));
// Register router
app
.
use
(
router
.
routes
());
app
.
use
(
mount
(
require
(
'
./web
'
)));
function
createServer
()
{
if
(
config
.
https
)
{
const
certs
=
{};
Object
.
keys
(
config
.
https
).
forEach
(
k
=>
{
certs
[
k
]
=
fs
.
readFileSync
(
config
.
https
[
k
]);
});
return
http
s
.
createServer
(
certs
,
app
.
callback
);
return
http
2
.
createSe
cureSe
rver
(
certs
,
app
.
callback
()
);
}
else
{
return
http
.
createServer
(
app
.
callback
);
return
http
.
createServer
(
app
.
callback
()
);
}
}
...
...
This diff is collapsed.
Click to expand it.
src/server/web/index.ts
+
8
−
9
View file @
61f21594
...
...
@@ -2,15 +2,13 @@
* Web Client Server
*/
import
*
as
path
from
'
path
'
;
import
ms
=
require
(
'
ms
'
);
import
*
as
Koa
from
'
koa
'
;
import
*
as
Router
from
'
koa-router
'
;
import
*
as
send
from
'
koa-send
'
;
import
*
as
favicon
from
'
koa-favicon
'
;
const
client
=
path
.
resolve
(
`
${
__dirname
}
/../../client/`
)
;
const
client
=
`
${
__dirname
}
/../../client/`
;
// Init app
const
app
=
new
Koa
();
...
...
@@ -19,10 +17,10 @@ const app = new Koa();
app
.
use
(
favicon
(
`
${
client
}
/assets/favicon.ico`
));
// Common request handler
app
.
use
((
ctx
,
next
)
=>
{
app
.
use
(
async
(
ctx
,
next
)
=>
{
// IFrameの中に入れられないようにする
ctx
.
set
(
'
X-Frame-Options
'
,
'
DENY
'
);
next
();
await
next
();
});
// Init router
...
...
@@ -30,9 +28,9 @@ const router = new Router();
//#region static assets
router
.
get
(
'
/assets
'
,
async
ctx
=>
{
router
.
get
(
'
/assets
/*
'
,
async
ctx
=>
{
await
send
(
ctx
,
ctx
.
path
,
{
root
:
`
${
client
}
/assets`
,
root
:
client
,
maxage
:
ms
(
'
7 days
'
),
immutable
:
true
});
...
...
@@ -63,8 +61,9 @@ router.get('url', require('./url-preview'));
// Render base html for all requests
router
.
get
(
'
*
'
,
async
ctx
=>
{
await
send
(
ctx
,
`
${
client
}
/app/base.html`
,
{
maxage
:
ms
(
'
7 days
'
),
await
send
(
ctx
,
`app/base.html`
,
{
root
:
client
,
maxage
:
ms
(
'
3 days
'
),
immutable
:
true
});
});
...
...
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