mirror of
https://codeberg.org/keyoxide/keyoxide-web.git
synced 2024-12-22 14:59:29 -07:00
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: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",
|
||||
"standard:check": "./node_modules/.bin/standard ./src ./api ./routes ./server",
|
||||
"standard:fix": "./node_modules/.bin/standard --fix ./src ./api ./routes ./server",
|
||||
"standard:check": "./node_modules/.bin/standard ./src",
|
||||
"standard:fix": "./node_modules/.bin/standard --fix ./src",
|
||||
"license:check": "./node_modules/.bin/license-check-and-add check",
|
||||
"license:add": "./node_modules/.bin/license-check-and-add add",
|
||||
"license:remove": "./node_modules/.bin/license-check-and-add remove"
|
||||
|
|
|
@ -33,7 +33,11 @@ import proxyGetApiRouter from './proxy_get.js'
|
|||
|
||||
const router = express.Router()
|
||||
|
||||
router.use('/profile', keyoxideProfileApiRouter)
|
||||
router.use('/get', proxyGetApiRouter)
|
||||
if (process.env.ENABLE_MAIN_MODULE ?? true) {
|
||||
router.use('/profile', keyoxideProfileApiRouter)
|
||||
}
|
||||
if (process.env.ENABLE_PROXY_MODULE ?? true) {
|
||||
router.use('/get', proxyGetApiRouter)
|
||||
}
|
||||
|
||||
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 'dotenv/config.js'
|
||||
|
||||
import apiRoute from '../routes/api.js'
|
||||
import mainRoute from '../routes/main.js'
|
||||
import profileRoute from '../routes/profile.js'
|
||||
import staticRoute from '../routes/static.js'
|
||||
import utilRoute from '../routes/util.js'
|
||||
import apiRoute from './routes/api.js'
|
||||
import mainRoute from './routes/main.js'
|
||||
import profileRoute from './routes/profile.js'
|
||||
import staticRoute from './routes/static.js'
|
||||
import utilRoute from './routes/util.js'
|
||||
|
||||
const app = express()
|
||||
const packageData = JSON.parse(readFileSync('./package.json'))
|
||||
|
@ -72,17 +72,19 @@ app.use(stringReplace({
|
|||
}))
|
||||
|
||||
// Routes
|
||||
app.use('/favicon.svg', express.static('./static/favicon.svg'))
|
||||
app.use('/robots.txt', express.static('./static/robots.txt'))
|
||||
if (process.env.ENABLE_MAIN_MODULE ?? true) {
|
||||
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('/static', staticRoute)
|
||||
app.use('/util', utilRoute)
|
||||
app.use('/', profileRoute)
|
||||
|
||||
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
|
||||
|
|
Loading…
Reference in a new issue