diff options
| author | syuilo <syuilotan@yahoo.co.jp> | 2017-11-21 03:40:09 +0900 |
|---|---|---|
| committer | syuilo <syuilotan@yahoo.co.jp> | 2017-11-21 03:40:09 +0900 |
| commit | 1436617aab030fa5b3760a3eeae37a1cdeeba2df (patch) | |
| tree | 5ac701a811de8be79e8e83643752818ee4b2cd1d /src/web/server.ts | |
| parent | v3165 (diff) | |
| download | sharkey-1436617aab030fa5b3760a3eeae37a1cdeeba2df.tar.gz sharkey-1436617aab030fa5b3760a3eeae37a1cdeeba2df.tar.bz2 sharkey-1436617aab030fa5b3760a3eeae37a1cdeeba2df.zip | |
wip
Diffstat (limited to 'src/web/server.ts')
| -rw-r--r-- | src/web/server.ts | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/src/web/server.ts b/src/web/server.ts index dde4eca5ec..300f3ed477 100644 --- a/src/web/server.ts +++ b/src/web/server.ts @@ -37,29 +37,46 @@ app.use((req, res, next) => { * Static assets */ app.use(favicon(`${__dirname}/assets/favicon.ico`)); -app.get('/manifest.json', (req, res) => res.sendFile(`${__dirname}/assets/manifest.json`)); 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.get('/sw.js', (req, res) => res.sendFile(`${__dirname}/assets/sw.js`)); + /** - * Common API + * Manifest */ -app.get(/\/api:url/, require('./service/url-preview')); +app.get('/manifest.json', (req, res) => { + const manifest = require((`${__dirname}/assets/manifest.json`)); + + // Service Worker + if (config.sw) { + manifest['gcm_sender_id'] = config.sw.gcm_sender_id; + } + + res.send(manifest); +}); /** * Serve config */ app.get('/config.json', (req, res) => { - res.send({ + const conf = { recaptcha: { siteKey: config.recaptcha.siteKey } - }); + }; + + res.send(conf); }); /** + * Common API + */ +app.get(/\/api:url/, require('./service/url-preview')); + +/** * Routing */ app.get('*', (req, res) => { |