Skip to content

Commit

Permalink
refactor: admin应该能用了
Browse files Browse the repository at this point in the history
  • Loading branch information
bangbang93 committed Oct 24, 2023
1 parent cabca43 commit 6ffdbab
Show file tree
Hide file tree
Showing 7 changed files with 1,526 additions and 1,189 deletions.
2,667 changes: 1,495 additions & 1,172 deletions package-lock.json

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
"@babel/plugin-transform-runtime": "^7.9.0",
"@babel/preset-env": "^7.9.0",
"@bangbang93/eslint-config-recommended": "^0.0.2",
"@bangbang93/eslint-config-recommended": "^1.1.1",
"@nestjs/cli": "^9.1.5",
"@tsconfig/node16": "^1.0.3",
"@types/bcrypt": "^3.0.0",
Expand All @@ -124,8 +124,8 @@
"@types/prismjs": "^1.26.0",
"@types/serve-favicon": "^2.5.0",
"@types/webpack-node-externals": "^2.5.3",
"@typescript-eslint/eslint-plugin": "^5.42.1",
"@typescript-eslint/parser": "^5.42.1",
"@typescript-eslint/eslint-plugin": "^6.9.0",
"@typescript-eslint/parser": "^6.9.0",
"@vue/cli-plugin-babel": "^5.0.1",
"@vue/cli-service": "^5.0.1",
"babel-loader": "^8.1.0",
Expand All @@ -144,7 +144,7 @@
"release-it": "^16.0.0",
"shelljs": "^0.8.5",
"ts-loader": "^4.5.0",
"typescript": "^4.8.4",
"typescript": "^5.2.2",
"url": "^0.11.0",
"url-loader": "^4.0.0",
"vue-loader": "^17.0.1",
Expand Down
1 change: 1 addition & 0 deletions packages/admin/env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/// <reference types="vite/client" />
7 changes: 7 additions & 0 deletions packages/admin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,12 @@
"typescript": "^5.2.2",
"vite": "^4.5.0",
"vue-tsc": "^1.8.20"
},
"dependencies": {
"element-plus": "^2.4.1",
"font-awesome": "^4.7.0",
"vue": "^3.3.6",
"vue-fetch": "^2.0.0",
"vue-router": "^4.2.5"
}
}
7 changes: 7 additions & 0 deletions packages/admin/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,10 @@
<router-view />
</div>
</template>
<script lang="ts">
import {defineComponent} from 'vue'
export default defineComponent({
name: 'FreyjaAdmin',
})
</script>
4 changes: 2 additions & 2 deletions packages/admin/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
/* Bundler mode */
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "preserve",
Expand All @@ -18,7 +17,8 @@
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true
"noFallthroughCasesInSwitch": true,
"allowJs": true
},
"include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.vue"],
"references": [{ "path": "./tsconfig.node.json" }]
Expand Down
21 changes: 10 additions & 11 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ export async function bootstrap(): Promise<void> {
} else {
app.use(morgan('combined'))
}
const RedisStore = connectRedis(session)
const redisStore = connectRedis(session)

app.use(cookieParser())
const sessionConfig = configService.get('session')
const sessionConfig = configService.get('session') as Record<string, string>
app.use(session({
name: 'freyja.sid',
store: new RedisStore({
store: new redisStore({
client: redis,
prefix: 'freyja:session:',
}),
Expand All @@ -69,10 +69,9 @@ export async function bootstrap(): Promise<void> {

const port = parseInt(configService.get('PORT', '3000'), 10)

/* eslint-disable @typescript-eslint/no-require-imports,@typescript-eslint/no-var-requires */
if (configService.get('NODE_ENV') === 'production') {
const appPath = join(__dirname, '../client/dist/server/server.js')
const clientApp = (await import(appPath)).default
const clientApp = (await import(appPath) as typeof import('../client/src/entries/entry-server')).default
app.use(cacheControl({
'/': 3600,
'/article/**': 3600,
Expand All @@ -86,12 +85,12 @@ export async function bootstrap(): Promise<void> {
}
eApp.get('*', express.static(path.join(__dirname, '..', 'client/dist')))

if (configService.get('freyja.fundebug.enable')) {
// eslint-disable-next-line @typescript-eslint/no-require-imports,@typescript-eslint/no-var-requires
const fundebug = require('fundebug-nodejs')
fundebug.apikey = configService.get('freyja.fundebug.apikey')
app.use(fundebug.ExpressErrorHandler)
}
// if (configService.get('freyja.fundebug.enable')) {
// // eslint-disable-next-line @typescript-eslint/no-require-imports,@typescript-eslint/no-var-requires
// const fundebug = require('fundebug-nodejs')
// fundebug.apikey = configService.get('freyja.fundebug.apikey')
// app.use(fundebug.ExpressErrorHandler)
// }

await app.listen(port)
}

0 comments on commit 6ffdbab

Please sign in to comment.