Merge pull request #28 from IT4Change/import-order-sbcomp

refactor(frontend): import order + sbcomp + some types
This commit is contained in:
Ulf Gebhardt 2023-12-14 01:19:29 +01:00 committed by GitHub
commit 6a6b7f0163
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 41 additions and 32 deletions

View File

@ -135,15 +135,15 @@
"vuepress": "^2.0.0-rc.0"
},
"imports": {
"#root/*": "./*",
"#src/*": "./src/*",
"#components/*": "./src/components/*",
"#pages/*": "./src/pages/*",
"#assets/*": "./src/assets/*",
"#layouts/*": "./src/layouts/*",
"#stores/*": "./src/stores/*",
"#src/*": "./src/*",
"#plugins/*": "./renderer/plugins/*",
"#context/*": "./renderer/context/*",
"#types/*": "./types/*"
"#types/*": "./types/*",
"#root/*": "./*"
}
}

View File

@ -52,27 +52,29 @@ async function startServer() {
// Vike middleware. It should always be our last middleware (because it's a
// catch-all middleware superseding any middleware placed after it).
// eslint-disable-next-line @typescript-eslint/no-misused-promises
app.get('*', async (req, res, next) => {
app.get('*', (req, res, next) => {
void (async (req, res, next) => {
const pageContextInit = {
urlOriginal: req.originalUrl,
}
const pageContext = await renderPage(pageContextInit)
const { httpResponse } = pageContext
if (!httpResponse) {
return next()
next()
} else {
const { body, statusCode, headers, earlyHints } = httpResponse
if (res.writeEarlyHints) res.writeEarlyHints({ link: earlyHints.map((e) => e.earlyHintLink) })
if (res.writeEarlyHints)
res.writeEarlyHints({ link: earlyHints.map((e) => e.earlyHintLink) })
headers.forEach(([name, value]) => res.setHeader(name, value))
res.status(statusCode)
// For HTTP streams use httpResponse.pipe() instead, see https://vike.dev/stream
res.send(body)
}
})(req, res, next)
})
const port = process.env.PORT || 3000
app.listen(port)
// eslint-disable-next-line no-console
console.log(`Server running at http://localhost:${port}`)
console.log(`🚀 Server running at http://localhost:${port}`)
}

View File

@ -1,3 +1,5 @@
import { SBComp } from '#types/SBComp'
import ExampleButton from './ExampleButton.vue'
import type { Meta, StoryObj } from '@storybook/vue3'
@ -5,8 +7,7 @@ import type { Meta, StoryObj } from '@storybook/vue3'
// More on how to set up stories at: https://storybook.js.org/docs/vue/writing-stories/introduction
const meta = {
title: 'Example/Button',
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
component: ExampleButton,
component: ExampleButton as SBComp,
// This component will have an automatically generated docsPage entry: https://storybook.js.org/docs/vue/writing-docs/autodocs
tags: ['autodocs'],
argTypes: {

View File

@ -1,3 +1,5 @@
import { SBComp } from '#types/SBComp'
import ExampleHeader from './ExampleHeader.vue'
import type { Meta, StoryObj } from '@storybook/vue3'
@ -8,8 +10,7 @@ const meta = {
* to learn how to generate automatic titles
*/
title: 'Example/Header',
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
component: ExampleHeader,
component: ExampleHeader as SBComp,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
render: (args: any) => ({
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment

View File

@ -1,13 +1,14 @@
import { within, userEvent } from '@storybook/testing-library'
import { SBComp } from '#types/SBComp'
import ExamplePage from './ExamplePage.vue'
import type { Meta, StoryObj } from '@storybook/vue3'
const meta = {
title: 'Example/Page',
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
component: ExamplePage,
component: ExamplePage as SBComp,
render: () => ({
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
components: { ExamplePage },

View File

@ -11,16 +11,16 @@
"esModuleInterop": true,
"resolveJsonModule": true,
"paths": {
"#root/*": ["./*"],
"#src/*": ["./src/*"],
"#components/*": ["./src/components/*"],
"#pages/*": ["./src/pages/*"],
"#assets/*": ["./src/assets/*"],
"#layouts/*": ["./src/layouts/*"],
"#stores/*": ["./src/stores/*"],
"#src/*": ["./src/*"],
"#plugins/*": ["./renderer/plugins/*"],
"#context/*": ["./renderer/context/*"],
"#types/*": ["./types/*"]
"#types/*": ["./types/*"],
"#root/*": ["./*"]
}
},
"ts-node": {

4
types/SBComp.ts Normal file
View File

@ -0,0 +1,4 @@
import { ConcreteComponent } from 'vue'
// Storybook Component Type
export type SBComp = Omit<ConcreteComponent<unknown>, 'props'>

View File

@ -28,16 +28,16 @@ const config: UserConfig = {
ssr: { noExternal: ['vuetify'] },
resolve: {
alias: {
'#root': __dirname,
'#src': path.join(__dirname, '/src'),
'#components': path.join(__dirname, '/src/components'),
'#pages': path.join(__dirname, '/src/pages'),
'#assets': path.join(__dirname, '/src/assets'),
'#layouts': path.join(__dirname, '/src/layouts'),
'#stores': path.join(__dirname, '/src/stores'),
'#src': path.join(__dirname, '/src'),
'#plugins': path.join(__dirname, '/renderer/plugins'),
'#context': path.join(__dirname, '/renderer/context'),
'#types': path.join(__dirname, '/types'),
'#root': __dirname,
},
},
}