diff options
| author | Akihiko Odaki <nekomanma@pixiv.co.jp> | 2018-03-29 01:20:40 +0900 |
|---|---|---|
| committer | Akihiko Odaki <nekomanma@pixiv.co.jp> | 2018-03-29 01:54:41 +0900 |
| commit | 90f8fe7e538bb7e52d2558152a0390e693f39b11 (patch) | |
| tree | 0f830887053c8f352b1cd0c13ca715fd14c1f030 /src/web/server.ts | |
| parent | Implement remote account resolution (diff) | |
| download | sharkey-90f8fe7e538bb7e52d2558152a0390e693f39b11.tar.gz sharkey-90f8fe7e538bb7e52d2558152a0390e693f39b11.tar.bz2 sharkey-90f8fe7e538bb7e52d2558152a0390e693f39b11.zip | |
Introduce processor
Diffstat (limited to 'src/web/server.ts')
| -rw-r--r-- | src/web/server.ts | 77 |
1 files changed, 0 insertions, 77 deletions
diff --git a/src/web/server.ts b/src/web/server.ts deleted file mode 100644 index b117f6ae81..0000000000 --- a/src/web/server.ts +++ /dev/null @@ -1,77 +0,0 @@ -/** - * Web Server - */ - -import * as path from 'path'; -import ms = require('ms'); - -// express modules -import * as express from 'express'; -import * as bodyParser from 'body-parser'; -import * as favicon from 'serve-favicon'; -import * as compression from 'compression'; - -/** - * Init app - */ -const app = express(); -app.disable('x-powered-by'); - -app.use('/docs', require('./docs/server')); - -app.use(bodyParser.urlencoded({ extended: true })); -app.use(bodyParser.json({ - type: ['application/json', 'text/plain'] -})); -app.use(compression()); - -/** - * Initialize requests - */ -app.use((req, res, next) => { - res.header('X-Frame-Options', 'DENY'); - next(); -}); - -/** - * Static assets - */ -app.use(favicon(`${__dirname}/assets/favicon.ico`)); -app.get('/apple-touch-icon.png', (req, res) => res.sendFile(`${__dirname}/assets/apple-touch-icon.png`)); -app.use('/assets', express.static(`${__dirname}/assets`, { - maxAge: ms('7 days') -})); -app.use('/assets/*.js', (req, res) => res.sendFile(`${__dirname}/assets/404.js`)); -app.use('/assets', (req, res) => { - res.sendStatus(404); -}); - -app.use('/recover', (req, res) => res.sendFile(`${__dirname}/assets/recover.html`)); - -/** - * ServiceWroker - */ -app.get(/^\/sw\.(.+?)\.js$/, (req, res) => - res.sendFile(`${__dirname}/assets/sw.${req.params[0]}.js`)); - -/** - * Manifest - */ -app.get('/manifest.json', (req, res) => - res.sendFile(`${__dirname}/assets/manifest.json`)); - -/** - * Common API - */ -app.get(/\/api:url/, require('./service/url-preview')); - -/** - * Routing - */ -app.get('*', (req, res) => { - res.sendFile(path.resolve(`${__dirname}/app/base.html`), { - maxAge: ms('7 days') - }); -}); - -module.exports = app; |