diff --git a/index.js b/index.js deleted file mode 100755 index b57ac1e..0000000 --- a/index.js +++ /dev/null @@ -1,53 +0,0 @@ -#!/usr/bin/env node - -'use strict' - -const yargs = require('yargs') -const fs = require('fs').promises -const path = require('path') - -const config = yargs - .env('OASIS') - .usage('Usage: $0 [options]') - .options('open', { - describe: 'Automatically open app in web browser', - default: true, - type: 'boolean' - }) - .options('host', { - describe: 'Hostname for web app to listen on', - default: 'localhost', - type: 'string' - }) - .options('port', { - describe: 'Port for web app to listen on', - default: 3000, - type: 'number' - }) - .options('debug', { - describe: 'Use verbose output for debugging', - default: false, - type: 'boolean' - }) - .argv - -// This hides arguments from other upstream modules who might parse them. -// -// Unfortunately some modules think that our CLI options are meant for them, -// and since there's no way to disable that behavior (!) we have to hide them -// manually by setting the args property to an empty array. -process.argv = [] - -if (config.debug) { - process.env.DEBUG = 'oasis,oasis:*' -} - -const app = require('./src/app') - -const start = async () => { - const filePath = path.join(__dirname, 'README.md') - config.readme = await fs.readFile(filePath, 'utf8') - app(config) -} - -start() diff --git a/package.json b/package.json index ac220a5..899b4b2 100644 --- a/package.json +++ b/package.json @@ -5,15 +5,15 @@ "repository": "git@github.com:fraction/oasis.git", "license": "AGPL-3.0", "author": "Christian Bundy ", - "main": "index.js", + "main": "src/index.js", "bin": { - "oasis": "./index.js" + "oasis": "./src/index.js" }, "scripts": { - "dev": "nodemon --inspect index.js --debug --no-open", + "dev": "nodemon --inspect src/index.js --debug --no-open", "fix": "standard --fix && stylelint --fix src/assets/*.css", - "start": "node index.js", - "test": "standard && dependency-check ./package.json --unused --no-dev --ignore-module highlight.js --ignore-module @fraction/base16-css && cspell --no-summary '**/*.{js,md}' && stylelint src/assets/*.css && tsc --allowJs --resolveJsonModule --lib dom --checkJs --noEmit --skipLibCheck index.js", + "start": "node src/index.js", + "test": "standard && dependency-check ./package.json --unused --no-dev --ignore-module highlight.js --ignore-module @fraction/base16-css && cspell --no-summary '**/*.{js,md}' && stylelint src/assets/*.css && tsc --allowJs --resolveJsonModule --lib dom --checkJs --noEmit --skipLibCheck src/index.js", "preversion": "npm test" }, "dependencies": { diff --git a/src/app.js b/src/app.js deleted file mode 100644 index 46883b0..0000000 --- a/src/app.js +++ /dev/null @@ -1,251 +0,0 @@ -'use strict' - -const Koa = require('koa') -const path = require('path') -const router = require('koa-router')() -const koaStatic = require('koa-static') -const mount = require('koa-mount') -const open = require('open') -const koaBody = require('koa-body') -const debug = require('debug')('oasis') -const ssbRef = require('ssb-ref') -const requireStyle = require('require-style') - -const author = require('./pages/author') -const hashtag = require('./pages/hashtag') -const publicPopularPage = require('./pages/public-popular') -const publicLatestPage = require('./pages/public-latest') -const profile = require('./pages/profile') -const json = require('./pages/json') -const thread = require('./pages/thread') -const like = require('./pages/like') -const likesPage = require('./pages/likes') -const meta = require('./pages/meta') -const mentions = require('./pages/mentions') -const reply = require('./pages/reply') -const comment = require('./pages/comment') -const publishReply = require('./pages/publish-reply') -const publishComment = require('./pages/publish-comment') -const image = require('./pages/image') -const blob = require('./pages/blob') -const publish = require('./pages/publish') -const markdown = require('./pages/markdown') -const inboxPage = require('./pages/inbox') -const searchPage = require('./pages/search') - -const defaultTheme = 'atelier-sulphurPool-light'.toLowerCase() - -module.exports = (config) => { - const assets = new Koa() - assets.use(koaStatic(path.join(__dirname, 'assets'))) - - const app = new Koa() - module.exports = app - - app.on('error', (e) => { - // Output full error objects - e.message = e.stack - e.expose = true - return null - }) - - app.use(mount('/assets', assets)) - - // headers - app.use(async (ctx, next) => { - await next() - - const csp = [ - 'default-src \'none\'', - 'img-src \'self\'', - 'form-action \'self\'', - 'media-src \'self\'', - 'style-src \'self\' \'unsafe-inline\'' - ].join('; ') - - // Disallow scripts. - ctx.set('Content-Security-Policy', csp) - - // Disallow