forked from Mirrors/keyoxide-web
Restructure src, add modular design
This commit is contained in:
parent
34f34c3d6f
commit
79a259f028
16 changed files with 22 additions and 16 deletions
|
@ -49,8 +49,8 @@
|
||||||
"build:server": "ncc build ./src/index.js -e jsdom -o dist",
|
"build:server": "ncc build ./src/index.js -e jsdom -o dist",
|
||||||
"build:static": "webpack --config webpack.config.js --env static=true --env mode=production",
|
"build:static": "webpack --config webpack.config.js --env static=true --env mode=production",
|
||||||
"build:static:dev": "webpack --config webpack.config.js --env static=true --env mode=development",
|
"build:static:dev": "webpack --config webpack.config.js --env static=true --env mode=development",
|
||||||
"standard:check": "./node_modules/.bin/standard ./src ./api ./routes ./server",
|
"standard:check": "./node_modules/.bin/standard ./src",
|
||||||
"standard:fix": "./node_modules/.bin/standard --fix ./src ./api ./routes ./server",
|
"standard:fix": "./node_modules/.bin/standard --fix ./src",
|
||||||
"license:check": "./node_modules/.bin/license-check-and-add check",
|
"license:check": "./node_modules/.bin/license-check-and-add check",
|
||||||
"license:add": "./node_modules/.bin/license-check-and-add add",
|
"license:add": "./node_modules/.bin/license-check-and-add add",
|
||||||
"license:remove": "./node_modules/.bin/license-check-and-add remove"
|
"license:remove": "./node_modules/.bin/license-check-and-add remove"
|
||||||
|
|
|
@ -33,7 +33,11 @@ import proxyGetApiRouter from './proxy_get.js'
|
||||||
|
|
||||||
const router = express.Router()
|
const router = express.Router()
|
||||||
|
|
||||||
router.use('/profile', keyoxideProfileApiRouter)
|
if (process.env.ENABLE_MAIN_MODULE ?? true) {
|
||||||
router.use('/get', proxyGetApiRouter)
|
router.use('/profile', keyoxideProfileApiRouter)
|
||||||
|
}
|
||||||
|
if (process.env.ENABLE_PROXY_MODULE ?? true) {
|
||||||
|
router.use('/get', proxyGetApiRouter)
|
||||||
|
}
|
||||||
|
|
||||||
export default router
|
export default router
|
26
src/index.js
26
src/index.js
|
@ -34,11 +34,11 @@ import { stringReplace } from 'string-replace-middleware'
|
||||||
import * as pug from 'pug'
|
import * as pug from 'pug'
|
||||||
import 'dotenv/config.js'
|
import 'dotenv/config.js'
|
||||||
|
|
||||||
import apiRoute from '../routes/api.js'
|
import apiRoute from './routes/api.js'
|
||||||
import mainRoute from '../routes/main.js'
|
import mainRoute from './routes/main.js'
|
||||||
import profileRoute from '../routes/profile.js'
|
import profileRoute from './routes/profile.js'
|
||||||
import staticRoute from '../routes/static.js'
|
import staticRoute from './routes/static.js'
|
||||||
import utilRoute from '../routes/util.js'
|
import utilRoute from './routes/util.js'
|
||||||
|
|
||||||
const app = express()
|
const app = express()
|
||||||
const packageData = JSON.parse(readFileSync('./package.json'))
|
const packageData = JSON.parse(readFileSync('./package.json'))
|
||||||
|
@ -72,17 +72,19 @@ app.use(stringReplace({
|
||||||
}))
|
}))
|
||||||
|
|
||||||
// Routes
|
// Routes
|
||||||
app.use('/favicon.svg', express.static('./static/favicon.svg'))
|
if (process.env.ENABLE_MAIN_MODULE ?? true) {
|
||||||
app.use('/robots.txt', express.static('./static/robots.txt'))
|
app.use('/favicon.svg', express.static('./static/favicon.svg'))
|
||||||
|
app.use('/robots.txt', express.static('./static/robots.txt'))
|
||||||
|
|
||||||
app.use('/', mainRoute)
|
app.use('/', mainRoute)
|
||||||
|
app.use('/static', staticRoute)
|
||||||
|
app.use('/util', utilRoute)
|
||||||
|
app.use('/', profileRoute)
|
||||||
|
}
|
||||||
app.use('/api', apiRoute)
|
app.use('/api', apiRoute)
|
||||||
app.use('/static', staticRoute)
|
|
||||||
app.use('/util', utilRoute)
|
|
||||||
app.use('/', profileRoute)
|
|
||||||
|
|
||||||
app.listen(app.get('port'), () => {
|
app.listen(app.get('port'), () => {
|
||||||
console.log(`Node server listening at http://localhost:${app.get('port')}`)
|
console.log(`Server listening at http://localhost:${app.get('port')}`)
|
||||||
})
|
})
|
||||||
|
|
||||||
export default app
|
export default app
|
||||||
|
|
Loading…
Reference in a new issue