-
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added reproduce project based on nuxt
- Loading branch information
1 parent
f4621cd
commit c1d1932
Showing
18 changed files
with
16,269 additions
and
417 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -121,3 +121,5 @@ docs/.vitepress/cache | |
lib | ||
|
||
.DS_Store | ||
*/.output | ||
e2e/esmCompatibility/.output |
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,42 @@ | ||
# Nuxt 3 Minimal Starter | ||
|
||
Look at the [Nuxt 3 documentation](https://nuxt.com/docs/getting-started/introduction) to learn more. | ||
|
||
## Setup | ||
|
||
Make sure to install the dependencies: | ||
|
||
```bash | ||
# yarn | ||
yarn install | ||
|
||
# npm | ||
npm install | ||
|
||
# pnpm | ||
pnpm install | ||
``` | ||
|
||
## Development Server | ||
|
||
Start the development server on http://localhost:3000 | ||
|
||
```bash | ||
npm run dev | ||
``` | ||
|
||
## Production | ||
|
||
Build the application for production: | ||
|
||
```bash | ||
npm run build | ||
``` | ||
|
||
Locally preview production build: | ||
|
||
```bash | ||
npm run preview | ||
``` | ||
|
||
Check out the [deployment documentation](https://nuxt.com/docs/getting-started/deployment) for more information. |
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,9 @@ | ||
<script lang="ts" setup> | ||
const { data } = useFetch('/counter/1'); | ||
</script> | ||
|
||
<template> | ||
<div> | ||
<pre>{{ data }}</pre> | ||
</div> | ||
</template> |
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,100 @@ | ||
import type { Event, Command } from '@event-driven-io/emmett'; | ||
import { IllegalStateError, CommandHandler } from '@event-driven-io/emmett'; | ||
import { match } from "ts-pattern" | ||
|
||
export type CounterIncremented = Event<"CounterIncremented", { by: number }> | ||
export type CounterDecremented = Event<"CounterDecremented", { by: number }> | ||
export type CounterSubmitted = Event<"CounterSubmitted"> | ||
|
||
export type CounterEvent = CounterIncremented | CounterDecremented | CounterSubmitted; | ||
|
||
export type IncrementCounter = Command<"IncrementCounter", { counterId: string, by?: number }> | ||
export type DecrementCounter = Command<"DecrementCounter", { counterId: string, by?: number }> | ||
export type SubmitCounter = Command<"SubmitCounter"> | ||
|
||
export type CounterCommand = IncrementCounter | DecrementCounter | SubmitCounter; | ||
|
||
export type OpenedCounter = { status: "opened", value: number } | ||
export type SubmittedCounter = { status: "submitted", value: number } | ||
export type Counter = OpenedCounter | SubmittedCounter; | ||
|
||
export const incrementCounter = (command: IncrementCounter, state: Counter) => { | ||
if (state.status === "submitted") { | ||
throw new IllegalStateError("Cannot increment a submitted counter"); | ||
} | ||
|
||
const { data } = command; | ||
|
||
return { | ||
type: "CounterIncremented", | ||
data: { | ||
by: data.by ?? 1 | ||
} | ||
} satisfies CounterIncremented; | ||
} | ||
|
||
export const decrementCounter = (command: DecrementCounter, state: Counter) => { | ||
if (state.status === "submitted") { | ||
throw new IllegalStateError("Cannot decrement a submitted counter"); | ||
} | ||
|
||
const { data } = command; | ||
|
||
return { | ||
type: "CounterDecremented", | ||
data: { | ||
by: data.by ?? 1 | ||
} | ||
} satisfies CounterDecremented; | ||
} | ||
|
||
export const submitCounter = (command: SubmitCounter, state: Counter) => { | ||
if (state.status === "submitted") { | ||
throw new IllegalStateError("Cannot submit a submitted counter"); | ||
} | ||
|
||
return { | ||
type: "CounterSubmitted", | ||
data: {} | ||
} satisfies CounterSubmitted; | ||
} | ||
|
||
export const decide = (rawCommand: CounterCommand, state: Counter) => { | ||
return match(rawCommand) | ||
.with({ type: "IncrementCounter" }, (command) => incrementCounter(command, state)) | ||
.with({ type: "DecrementCounter" }, (command) => decrementCounter(command, state)) | ||
.with({ type: "SubmitCounter" }, (command) => submitCounter(command, state)) | ||
.exhaustive(); | ||
}; | ||
|
||
export const getInitialState = () => { | ||
return { | ||
status: "opened", | ||
value: 0 | ||
} as OpenedCounter; | ||
} | ||
|
||
export const evolve = (state: Counter, event: CounterEvent) => { | ||
return match(event) | ||
.with({ type: "CounterIncremented" }, ({ data }) => { | ||
return { | ||
...state, | ||
value: state.value + data.by | ||
} as OpenedCounter; | ||
}) | ||
.with({ type: "CounterDecremented" }, ({ data }) => { | ||
return { | ||
...state, | ||
value: state.value - data.by | ||
} as OpenedCounter; | ||
}) | ||
.with({ type: "CounterSubmitted" }, () => { | ||
return { | ||
...state, | ||
status: "submitted" | ||
} as SubmittedCounter; | ||
}) | ||
.exhaustive(); | ||
} | ||
|
||
export const handle = CommandHandler(evolve, getInitialState); |
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,3 @@ | ||
import { getInMemoryEventStore } from '@event-driven-io/emmett'; | ||
|
||
export const eventStore = getInMemoryEventStore(); |
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,4 @@ | ||
// https://nuxt.com/docs/api/configuration/nuxt-config | ||
export default defineNuxtConfig({ | ||
devtools: { enabled: false }, | ||
}); |
Oops, something went wrong.