-
-
Notifications
You must be signed in to change notification settings - Fork 125
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(examples): new_defineEntries (#993)
Migrating examples: - [x] 38_cookies - [x] 39_api - [x] 35_nesting
- Loading branch information
Showing
17 changed files
with
122 additions
and
136 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// This is a temporary file while experimenting new_defineEntries | ||
|
||
import { defineConfig } from 'waku/config'; | ||
|
||
export default defineConfig({ | ||
middleware: () => [ | ||
import('waku/middleware/context'), | ||
import('waku/middleware/dev-server'), | ||
import('waku/middleware/handler'), | ||
], | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
/** @type {import('waku/config').Config} */ | ||
export default { | ||
import { defineConfig } from 'waku/config'; | ||
|
||
export default defineConfig({ | ||
middleware: () => [ | ||
import('waku/middleware/context'), | ||
import('./src/middleware/cookie.js'), | ||
import('waku/middleware/dev-server'), | ||
import('waku/middleware/rsc'), | ||
import('waku/middleware/ssr'), | ||
import('waku/middleware/handler'), | ||
], | ||
}; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,31 @@ | ||
import { defineEntries } from 'waku/server'; | ||
import { Slot } from 'waku/client'; | ||
import { new_defineEntries } from 'waku/minimal/server'; | ||
import { Slot } from 'waku/minimal/client'; | ||
|
||
import App from './components/App'; | ||
|
||
export default defineEntries( | ||
// renderEntries | ||
async (rscPath) => { | ||
return { | ||
App: <App name={rscPath || 'Waku'} />, | ||
}; | ||
}, | ||
// getBuildConfig | ||
async () => [{ pathname: '/', entries: [{ rscPath: '' }] }], | ||
// getSsrConfig | ||
async (pathname) => { | ||
switch (pathname) { | ||
case '/': | ||
return { | ||
rscPath: '', | ||
html: <Slot id="App" />, | ||
}; | ||
default: | ||
return null; | ||
const stringToStream = (str: string): ReadableStream => { | ||
const encoder = new TextEncoder(); | ||
return new ReadableStream({ | ||
start(controller) { | ||
controller.enqueue(encoder.encode(str)); | ||
controller.close(); | ||
}, | ||
}); | ||
}; | ||
|
||
export default new_defineEntries({ | ||
unstable_handleRequest: async (input, { renderRsc, renderHtml }) => { | ||
if (input.type === 'component') { | ||
return renderRsc({ App: <App name={input.rscPath || 'Waku'} /> }); | ||
} | ||
if (input.type === 'custom' && input.pathname === '/') { | ||
return renderHtml({ App: <App name="Waku" /> }, <Slot id="App" />, ''); | ||
} | ||
if (input.type === 'custom' && input.pathname === '/api/hello') { | ||
return stringToStream('world'); | ||
} | ||
}, | ||
); | ||
unstable_getBuildConfig: async () => [ | ||
{ pathSpec: [], entries: [{ rscPath: '' }] }, | ||
], | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
/** @type {import('waku/config').Config} */ | ||
export default { | ||
// This is a temporary file while experimenting new_defineEntries | ||
|
||
import { defineConfig } from 'waku/config'; | ||
|
||
export default defineConfig({ | ||
middleware: () => [ | ||
import('waku/middleware/context'), | ||
import('./src/middleware/api.js'), | ||
import('waku/middleware/dev-server'), | ||
import('waku/middleware/rsc'), | ||
import('waku/middleware/ssr'), | ||
import('waku/middleware/handler'), | ||
], | ||
}; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.